From 1474caa8f624aa568ea011629d1aec4ae2aca3c1 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:03:12 +0530 Subject: Using fzf as the application launcher. --- modules/tools/editor/neovim/config/keybindings.lua | 3 --- modules/tools/editor/neovim/config/options.lua | 16 ++++++++-------- modules/tools/editor/neovim/plugins/config/default.nix | 1 + modules/tools/editor/neovim/plugins/config/dressing.lua | 1 + .../tools/editor/neovim/plugins/config/lsp-config.lua | 17 +++++++++-------- .../tools/editor/neovim/plugins/config/nvim-tree.lua | 2 ++ modules/tools/editor/neovim/plugins/default.nix | 2 ++ 7 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 modules/tools/editor/neovim/plugins/config/dressing.lua (limited to 'modules/tools/editor/neovim') diff --git a/modules/tools/editor/neovim/config/keybindings.lua b/modules/tools/editor/neovim/config/keybindings.lua index 3e8e0fa..3f2c9bf 100644 --- a/modules/tools/editor/neovim/config/keybindings.lua +++ b/modules/tools/editor/neovim/config/keybindings.lua @@ -3,6 +3,3 @@ vim.keymap.set("n", "", ":wincmd h", { silent = true }); vim.keymap.set("n", "", ":wincmd j", { silent = true }); vim.keymap.set("n", "", ":wincmd k", { silent = true }); vim.keymap.set("n", "", ":wincmd l", { silent = true }); - --- NvimTree -vim.keymap.set("n", "", ":NvimTreeToggle", { silent = true }); diff --git a/modules/tools/editor/neovim/config/options.lua b/modules/tools/editor/neovim/config/options.lua index 450e613..bd475c7 100644 --- a/modules/tools/editor/neovim/config/options.lua +++ b/modules/tools/editor/neovim/config/options.lua @@ -31,11 +31,11 @@ vim.api.nvim_create_autocmd("FileType", { }); -- Exception that use spaces --- vim.api.nvim_create_autocmd("FileType", { --- pattern = {}, --- callback = function() --- vim.bo.expandtab = true; --- vim.bo.tabstop = 2; --- vim.bo.shiftwidth = 2; --- end, --- }); +vim.api.nvim_create_autocmd("FileType", { + pattern = { "yaml" }, + callback = function() + vim.bo.expandtab = true; + vim.bo.tabstop = 2; + vim.bo.shiftwidth = 2; + end, +}); diff --git a/modules/tools/editor/neovim/plugins/config/default.nix b/modules/tools/editor/neovim/plugins/config/default.nix index 6dff0b9..81407d7 100644 --- a/modules/tools/editor/neovim/plugins/config/default.nix +++ b/modules/tools/editor/neovim/plugins/config/default.nix @@ -4,6 +4,7 @@ let extra = if config.tools.editor.neovim.configuration == "full" then '' ${builtins.readFile ./lsp-config.lua} +${builtins.readFile ./dressing.lua} ${builtins.readFile (config.scheme { template = builtins.readFile ./noice.mustache.lua; })} diff --git a/modules/tools/editor/neovim/plugins/config/dressing.lua b/modules/tools/editor/neovim/plugins/config/dressing.lua new file mode 100644 index 0000000..6d14d47 --- /dev/null +++ b/modules/tools/editor/neovim/plugins/config/dressing.lua @@ -0,0 +1 @@ +require("dressing").setup(); diff --git a/modules/tools/editor/neovim/plugins/config/lsp-config.lua b/modules/tools/editor/neovim/plugins/config/lsp-config.lua index 88f063d..d440c67 100644 --- a/modules/tools/editor/neovim/plugins/config/lsp-config.lua +++ b/modules/tools/editor/neovim/plugins/config/lsp-config.lua @@ -45,23 +45,24 @@ local lsp_setup_done = {}; -- Function to setup LSP based on filetype local function setup_lsp(filetype) local lsp = filetype_to_lsp[filetype]; - if lsp and not lsp_setup_done[lsp.server] then + if lsp ~= nil and not lsp_setup_done[lsp.server] then lsp_setup_done[lsp.server] = true; - if vim.fn.executable(lsp.executable) then + if vim.fn.executable(lsp.executable) == 1 then lspconfig[lsp.server].setup({}); - vim.lsp.start(); end end end -vim.keymap.set("n", "gd", vim.lsp.buf.definition, { noremap = true, silent = true }); -vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { noremap = true, silent = true }); -vim.keymap.set("n", "gr", vim.lsp.buf.references, { noremap = true, silent = true }); -vim.keymap.set("n", "gk", vim.lsp.buf.hover, { noremap = true, silent = true }); - vim.api.nvim_create_autocmd("FileType", { pattern = "*", -- Match all file types callback = function() setup_lsp(vim.bo.filetype); -- Call the setup_lsp function only if the filetype is in the mapping end, }); + +local lsp_keymap_opts = { noremap = true, silent = true }; + +vim.keymap.set("n", "d", vim.lsp.buf.definition, lsp_keymap_opts); +vim.keymap.set("n", "i", vim.lsp.buf.implementation, lsp_keymap_opts); +vim.keymap.set("n", "r", vim.lsp.buf.references, lsp_keymap_opts); +vim.keymap.set("n", "k", vim.lsp.buf.hover, lsp_keymap_opts); diff --git a/modules/tools/editor/neovim/plugins/config/nvim-tree.lua b/modules/tools/editor/neovim/plugins/config/nvim-tree.lua index c6c4102..cdbef6a 100644 --- a/modules/tools/editor/neovim/plugins/config/nvim-tree.lua +++ b/modules/tools/editor/neovim/plugins/config/nvim-tree.lua @@ -11,3 +11,5 @@ require("nvim-tree").setup { end, }, }; + +vim.keymap.set("n", "", ":NvimTreeToggle", { silent = true }); diff --git a/modules/tools/editor/neovim/plugins/default.nix b/modules/tools/editor/neovim/plugins/default.nix index d2a58b1..61c046c 100644 --- a/modules/tools/editor/neovim/plugins/default.nix +++ b/modules/tools/editor/neovim/plugins/default.nix @@ -10,6 +10,7 @@ nvim-treesitter nvim-web-devicons nvim-tree-lua + which-key-nvim (base16-vim.overrideAttrs (old: { patchPhase = "ln -s ${config.scheme base16-vim} colors/base16-scheme.vim"; })) @@ -17,6 +18,7 @@ (if config.tools.editor.neovim.configuration == "full" then [ noice-nvim + dressing-nvim nvim-lspconfig ] else null) -- cgit v1.2.3