Updated config

This commit is contained in:
2024-03-05 13:28:48 +01:00
parent 307d253d9e
commit eca02857ec
11 changed files with 150 additions and 78 deletions

View File

@ -33,8 +33,9 @@ on({ "VimEnter" }, {
callback = function()
-- Change file to its directory if needed
local name = vim.api.nvim_buf_get_name(0)
local is_directory = vim.fn.isdirectory(name)
if vim.fn.isdirectory(name) == 0 then
if is_directory == 0 then
name = vim.fs.dirname(name)
end
@ -50,18 +51,22 @@ on({ "VimEnter" }, {
else
vim.api.nvim_set_current_dir(name)
end
end,
})
on({ "VimEnter" }, {
desc = "Open file explorer if there is enough horizontal space",
group = group,
callback = function()
local files = require("nvim-tree.api")
local width = vim.go.columns
if width > 120 then
files.tree.toggle({ focus = false })
if is_directory ~= 0 then
require("telescope.builtin").find_files()
end
end,
})
-- on({ "VimEnter" }, {
-- desc = "Open file explorer if there is enough horizontal space",
-- group = group,
-- callback = function()
-- local files = require("nvim-tree.api")
-- local width = vim.go.columns
--
-- if width > 120 then
-- files.tree.toggle({ focus = false })
-- end
-- end,
-- })

View File

@ -4,13 +4,12 @@ end
-- Basics
map("n", ";", ":", "Command mode")
map("n", "U", "<cmd>redo<cr>", "Redo")
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", "Clear search")
map({"n", "v"}, "<leader>q", "<cmd>qa!<cr>", "Quit all")
-- Buffer management
map("n", "<C-n>", "<cmd>enew<cr>", "New file")
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr><esc>", "Save file")
map({ "i", "n", "s", "v" }, "<C-s>", "<cmd>w<cr>", "Save file")
map("n", "<C-q>", "<cmd>bd<cr>", "Delete buffer")
-- Copy and paste
@ -35,6 +34,10 @@ map("v", "<C-d>", "y/<C-r>\"<cr>N", "Search selection")
map("n", "<C-r>", "*#:%s//<C-r><C-w>/g<left><left>", "Replace word under cursor")
map("v", "<C-r>", "y/<C-r>\"<cr>N:%s//<C-r>\"/g<left><left>", "Replace selection")
-- Editing words
map("n", "<C-w>", "ciw", "Rewrite word")
map("n", "<Bslash>", "<cmd>ToggleWord<cr>", "Toggle word")
-- Indenting
map("n", "<Tab>", "V>gv<esc>")
map("n", "<S-Tab>", "V<gv<esc>")
@ -46,11 +49,13 @@ map("n", "+", "<C-a>", "Increase number")
map("n", "-", "<C-x>", "Decrease number")
map("n", "<kPlus>", "<C-a>", "Increase number")
map("n", "<kMinus>", "<C-x>", "Decrease number")
map("n", "<Bslash>", "<cmd>ToggleWord<cr>", "Toggle word")
-- Package manager
map("n", "<leader>l", "<cmd>Lazy<cr>", "Lazy")
-- Redo
map("n", "U", "<cmd>redo<cr>", "Redo")
-- Shift arrow selection
map("n", "<S-Up>", "v<Up>")
map("n", "<S-Down>", "v<Down>")