diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index 1a62efa..f981620 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -1,3 +1,42 @@ +local M = {} + +function M.telescope() + local telescope = require("telescope") + local builtin = require("telescope.builtin") + + vim.keymap.set("", "ff", builtin.find_files) + vim.keymap.set("", "fh", builtin.help_tags) + vim.keymap.set("", "ft", builtin.builtin) + vim.keymap.set("", "fm", builtin.man_pages) + vim.keymap.set("", "fb", telescope.extensions.file_browser.file_browser) + + vim.keymap.set("", "fd", function() builtin.find_files({ + cwd = "$DOTS", + prompt_title = "< Dotfiles >" + }) end) +end + +function M.harpoon() + vim.keymap.set("", "ha", require("harpoon.mark").add_file) + vim.keymap.set("", "ho", require("harpoon.ui").toggle_quick_menu) + + vim.keymap.set("", "hn", function() require("harpoon.ui").nav_file(1) end) + vim.keymap.set("", "hk", function() require("harpoon.ui").nav_file(2) end) + vim.keymap.set("", "hi", function() require("harpoon.ui").nav_file(3) end) +end + +function M.lsp(env) + local opts = { buffer = env.buffer } + + vim.keymap.set("", "en", vim.diagnostic.goto_next, opts) + vim.keymap.set("", "ep", vim.diagnostic.goto_prev, opts) + vim.keymap.set("", "ee", vim.diagnostic.open_float, opts) +end + +------------------------------------------------------------------------------ +-- Not plugin related -- +------------------------------------------------------------------------------ + local function swap(a, b) vim.keymap.set("", a, b) vim.keymap.set("", b, a) @@ -6,26 +45,33 @@ end swap(";", ":") swap("'", "`") -vim.keymap.set("", "q", "conf q") -vim.keymap.set("", "w", "w") -vim.keymap.set("", "x", "x") -vim.keymap.set("n", "J", "mzJ`z") -vim.keymap.set("n", "n", "nzz") -vim.keymap.set("n", "N", "Nzz") -vim.keymap.set("n", "", "zz") -vim.keymap.set("n", "", "zz") -vim.keymap.set("n", "", "nohls") - -vim.keymap.set("n", "w", "") +vim.keymap.set("", "w", "") local function window_map(key, mapping) local k = '' local m = 'wincmd ' .. (mapping or key) .. '' - vim.keymap.set({'n', 'i', 't'}, k, m) + vim.keymap.set({"", "i", "t"}, k, m) end window_map("h") window_map("j") window_map("k") window_map("l") + + +vim.keymap.set("", "q", "confirm quit") +vim.keymap.set("", "x", "exit") +vim.keymap.set("", "x", "writesource %") + +vim.keymap.set("", "n", "nzz") +vim.keymap.set("", "N", "Nzz") +vim.keymap.set("", "", "nohls") + +vim.keymap.set("", "", "zz") +vim.keymap.set("", "", "zz") + +vim.keymap.set("i", "jk", "") +vim.keymap.set("i", "kj", "") + +return M diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index ce21fe2..460a417 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -14,6 +14,13 @@ return { end }, + { + "ThePrimeagen/harpoon", + config = function() + require("keymaps").harpoon() + end + }, + { "abecodes/tabout.nvim", dependencies = { "nvim-treesitter" }, config = true }, { "numToStr/Comment.nvim", config = true }, @@ -21,6 +28,5 @@ return { { "windwp/nvim-autopairs", config = true }, "fladson/vim-kitty", - "tpope/vim-unimpaired", - "neovim/nvim-lspconfig" + "tpope/vim-unimpaired" } diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..6b940ad --- /dev/null +++ b/nvim/lua/plugins/lsp.lua @@ -0,0 +1,16 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "nvim-telescope/telescope.nvim" + }, + config = function() + local lspconfig = require("lspconfig") + + lspconfig.ccls.setup {} + + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = require("keymaps").lsp + }) + end +} diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 9fd9cd1..7f7329a 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -8,7 +8,6 @@ return { }, config = function() local telescope = require("telescope") - local fb_actions = require("telescope").extensions.file_browser.actions telescope.setup({ pickers = { @@ -19,20 +18,11 @@ return { extensions = { file_browser = { grouped = true, - hide_parent_dir = true, - hijack_netrw = true, - initial_mode = "normal", + hidden = true, respect_gitignore = false, sorting_strategy = "ascending", layout_config = { prompt_position = "top" - }, - mappings = { - n = { - ["h"] = fb_actions.goto_parent_dir, - ["l"] = "select_default", - ["g"] = fb_actions.toggle_hidden - } } } } @@ -41,16 +31,7 @@ return { telescope.load_extension("file_browser") telescope.load_extension("fzf") - local builtin = require("telescope.builtin") - vim.keymap.set("", "tf", builtin.find_files) - vim.keymap.set("", "th", builtin.help_tags) - vim.keymap.set("", "tr", builtin.buffers) - vim.keymap.set("", "ts", telescope.extensions.file_browser.file_browser) - vim.keymap.set("", "tt", builtin.builtin) + require("keymaps").telescope() - vim.keymap.set("", "tc", function() builtin.find_files({ - cwd = "$DOTS", - prompt_title = "< Dotfiles >" - }) end) - end, + end } diff --git a/zsh/zsh-aliases b/zsh/zsh-aliases index 0118786..0185d06 100644 --- a/zsh/zsh-aliases +++ b/zsh/zsh-aliases @@ -2,8 +2,6 @@ alias p='sudo pacman -S' alias pu='sudo pacman -Syu' alias vi='nvim' -alias vif='nvim +"norm 1 tf" +startinsert' -alias vic='nvim +"norm 1 tc" +startinsert' alias l='exa -x --group-directories-first --icons' alias ll='l -lbh --git --no-time'