From 814f9a1bea538eff33a49a0eae3f8f5c34799105 Mon Sep 17 00:00:00 2001 From: cswimr Date: Thu, 6 Feb 2025 23:23:02 -0600 Subject: [PATCH] more neovim stuff --- nixos/nvim/default.nix | 6 ++- nixos/nvim/keymaps.nix | 41 +++++++++++--- nixos/nvim/plugins/cmp.nix | 8 ++- nixos/nvim/plugins/codesnap.nix | 39 ++++++++++++++ nixos/nvim/plugins/dap.nix | 13 +++++ nixos/nvim/plugins/floatterm.nix | 36 +++++++++++++ nixos/nvim/plugins/hover.nix | 91 +++++++++++++++++++++++++++++++ nixos/nvim/plugins/lsp.nix | 92 ++++++++++++++------------------ nixos/nvim/plugins/oil.nix | 23 -------- nixos/nvim/plugins/surround.nix | 9 ++++ nixos/nvim/settings.nix | 13 ++++- 11 files changed, 286 insertions(+), 85 deletions(-) create mode 100644 nixos/nvim/plugins/codesnap.nix create mode 100644 nixos/nvim/plugins/dap.nix create mode 100644 nixos/nvim/plugins/floatterm.nix create mode 100644 nixos/nvim/plugins/hover.nix delete mode 100644 nixos/nvim/plugins/oil.nix create mode 100644 nixos/nvim/plugins/surround.nix diff --git a/nixos/nvim/default.nix b/nixos/nvim/default.nix index 9b1c5a7..40e1564 100644 --- a/nixos/nvim/default.nix +++ b/nixos/nvim/default.nix @@ -5,16 +5,20 @@ ./plugins/autoclose.nix ./plugins/cmp.nix + ./plugins/codesnap.nix ./plugins/conform.nix + ./plugins/dap.nix ./plugins/dashboard.nix ./plugins/devcontainer.nix + ./plugins/floatterm.nix + ./plugins/hover.nix ./plugins/lazygit.nix ./plugins/lsp.nix ./plugins/lualine.nix - ./plugins/oil.nix ./plugins/profile.nix ./plugins/rooter.nix ./plugins/snacks.nix + ./plugins/surround.nix ./plugins/telescope.nix ./plugins/treesitter.nix ]; diff --git a/nixos/nvim/keymaps.nix b/nixos/nvim/keymaps.nix index 4570e9c..3ccb16e 100644 --- a/nixos/nvim/keymaps.nix +++ b/nixos/nvim/keymaps.nix @@ -6,7 +6,12 @@ }; keymaps = [ { - mode = "n"; # Normal mode + mode = [ + "n" + "s" + "x" + "v" + ]; key = ""; action = ""; options.silent = true; @@ -50,7 +55,7 @@ { mode = "n"; key = ""; - action = ":bnext"; + action = "bnext"; options = { desc = "Next Buffer"; silent = true; @@ -59,16 +64,38 @@ { mode = "n"; key = ""; - action = ":bprevious"; + action = "bprevious"; options = { desc = "Previous Buffer"; silent = true; }; } + { + mode = "n"; + key = "c"; + action = "%y+"; + options = { + desc = "Copy Buffer to Clipboard"; + silent = true; + }; + } + { + mode = [ + "v" + "x" + "s" + ]; + key = "c"; + action = "\"+y"; + options = { + desc = "Copy Selection to Clipboard"; + silent = true; + }; + } { mode = "n"; key = "w"; - action = ":w"; + action = "w"; options = { desc = "Save Buffer to File"; silent = false; @@ -77,7 +104,7 @@ { mode = "n"; key = "q"; - action = ":bd"; + action = "bd"; options = { desc = "Close Buffer"; silent = false; @@ -86,7 +113,7 @@ { mode = "n"; key = "Q"; - action = ":bd!"; + action = "bd!"; options = { desc = "Force Close Buffer"; silent = false; @@ -95,7 +122,7 @@ { mode = "n"; key = "`"; - action = ":qa"; + action = "qa"; options = { desc = "Quit All"; silent = false; diff --git a/nixos/nvim/plugins/cmp.nix b/nixos/nvim/plugins/cmp.nix index 21c21c4..793b66f 100644 --- a/nixos/nvim/plugins/cmp.nix +++ b/nixos/nvim/plugins/cmp.nix @@ -20,7 +20,13 @@ }; }; }; - copilot-lua.enable = true; + copilot-lua = { + enable = true; + settings = { + suggestion.enabled = false; + panel.enabled = false; + }; + }; copilot-cmp.enable = true; }; }; diff --git a/nixos/nvim/plugins/codesnap.nix b/nixos/nvim/plugins/codesnap.nix new file mode 100644 index 0000000..f42c759 --- /dev/null +++ b/nixos/nvim/plugins/codesnap.nix @@ -0,0 +1,39 @@ +{ + programs.nixvim = { + plugins = { + codesnap = { + enable = true; + settings = { + bg_theme = "grape"; + breadcrumbs_separator = "/"; + has_breadcrumbs = true; + show_workspace = true; + has_line_number = true; + mac_window_bar = false; + # https://github.com/mistricky/codesnap.nvim/issues/135 + # code_font_family = "ComicCodeLigatures Nerd Font"; + title = "Nixvim"; + watermark = ""; + # half of defaults (122, 82) + bg_x_padding = 61; + bg_y_padding = 41; + }; + }; + }; + keymaps = [ + { + mode = [ + "v" + "x" + "s" + ]; + key = "s"; + action = "CodeSnap"; + options = { + desc = "Copy Selection as CodeSnap Image"; + silent = true; + }; + } + ]; + }; +} diff --git a/nixos/nvim/plugins/dap.nix b/nixos/nvim/plugins/dap.nix new file mode 100644 index 0000000..c925b95 --- /dev/null +++ b/nixos/nvim/plugins/dap.nix @@ -0,0 +1,13 @@ +{ pkgs, lib, ... }: +{ + programs.nixvim = { + plugins = { + dap = { + enable = true; + }; + dap-python = { + enable = true; + }; + }; + }; +} diff --git a/nixos/nvim/plugins/floatterm.nix b/nixos/nvim/plugins/floatterm.nix new file mode 100644 index 0000000..62283f2 --- /dev/null +++ b/nixos/nvim/plugins/floatterm.nix @@ -0,0 +1,36 @@ +{ pkgs, ... }: +{ + programs.nixvim = { + extraPlugins = [ + (pkgs.vimUtils.buildVimPlugin { + # https://github.com/EmilOhlsson/FloatTerm.nvim + name = "FloatTerm"; + src = pkgs.fetchFromGitHub { + owner = "EmilOhlsson"; + repo = "FloatTerm.nvim"; + rev = "b6b8f43c097d9edd923a6442e9aca71949cfe6ea"; + sha256 = "sha256-g6qQn2NA3nsTVE8+/9Vc2BCLCcZnKJfryRUXCw/Lp4g="; + }; + }) + ]; + extraConfigLua = # lua + '' + require("FloatTerm").setup({ + window_config = { + title = "Terminal", + }, + }) + ''; + keymaps = [ + { + mode = "n"; + key = "s"; + action = "FloatTerm"; + options = { + desc = "Toggle Floating Terminal"; + silent = true; + }; + } + ]; + }; +} diff --git a/nixos/nvim/plugins/hover.nix b/nixos/nvim/plugins/hover.nix new file mode 100644 index 0000000..92d466c --- /dev/null +++ b/nixos/nvim/plugins/hover.nix @@ -0,0 +1,91 @@ +{ pkgs, ... }: +{ + programs.nixvim = { + extraPlugins = with pkgs.vimPlugins; [ + hover-nvim + ]; + extraConfigLua = # lua + '' + require("hover").setup({ + init = function() + require("hover.providers.lsp") + require("hover.providers.diagnostic") + require("hover.providers.man") + require("hover.providers.dictionary") + end, + preview_opts = { + border = 'single', + }, + preview_window = true, + title = true, + mouse_providers = { + 'LSP', + }, + mouse_delay = 100 + }) + vim.o.mousemoveevent = true + ''; + # autoCmd = [ + # { + # desc = "Open Hover window when hovering over a word"; + # event = "CursorHold"; + # pattern = "*"; + # callback.__raw = '' + # function(_) + # local word = vim.fn.expand("") + # if word ~= "" then + # require('hover').hover() + # end + # end + # ''; + # } + # ]; + keymaps = [ + { + mode = "n"; + key = "K"; + action = "lua require('hover').hover()"; + options = { + desc = "Open Hover Window"; + silent = true; + }; + } + { + mode = "n"; + key = "gK"; + action = "lua require('hover').hover()"; + options = { + desc = "Select Hover Source"; + silent = true; + }; + } + { + mode = "n"; + key = ""; + action = "lua require('hover').hover_switch('previous')"; + options = { + desc = "Previous Hover Source"; + silent = true; + }; + } + { + mode = "n"; + key = ""; + action = "lua require('hover').hover_switch('next')"; + options = { + desc = "Next Hover Source"; + silent = true; + }; + } + { + mode = "n"; + key = ""; + action = "lua require('hover').hover_mouse()"; + options = { + desc = "Hover Mouse Support"; + silent = true; + }; + } + ]; + }; +} diff --git a/nixos/nvim/plugins/lsp.nix b/nixos/nvim/plugins/lsp.nix index a8df9ef..8517d48 100644 --- a/nixos/nvim/plugins/lsp.nix +++ b/nixos/nvim/plugins/lsp.nix @@ -2,21 +2,7 @@ { programs.nixvim = { extraPackages = with pkgs; [ - basedpyright - ruff - nil nixfmt-rfc-style - (callPackage ../../../packages/luau-lsp.nix { inherit pkgs; }) - dockerfile-language-server-nodejs - docker-compose-language-service - csharp-ls - deno - bash-language-server - powershell - powershell-editor-services - vscode-langservers-extracted - tailwindcss-language-server - typos-lsp ]; plugins = { luasnip = { @@ -25,9 +11,47 @@ lsp-status = { enable = true; }; + schemastore = { + enable = true; + json.enable = true; + yaml.enable = true; + }; lsp = { enable = true; - postConfig = # lua + capabilities = # lua + ''capabilities.textDocument.completion.completionItem.snippetSupport = true''; + inlayHints = true; + servers = { + basedpyright = { + enable = true; # Python + settings = { + pyright.disableOrganizeImports = true; + }; + }; + ruff.enable = true; # Python + csharp_ls.enable = true; + nil_ls = { + enable = true; # Nix + settings.formatting.command = [ "${lib.getExe pkgs.nixfmt-rfc-style}" ]; + }; + luau_lsp = { + enable = true; + package = pkgs.callPackage ../../../packages/luau-lsp.nix { inherit pkgs; }; + }; + html.enable = true; + jsonls.enable = true; + yamlls.enable = true; + taplo.enable = true; # TOML + cssls.enable = true; + tailwindcss.enable = true; + dockerls.enable = true; + docker_compose_language_service.enable = true; + bashls.enable = true; + denols.enable = true; # JavaScript / TypeScript (Deno) + eslint.enable = true; # JavaScript / TypeScript + typos_lsp.enable = true; + }; + preConfig = # lua '' vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup('lsp_attach_disable_ruff_hover', { clear = true }), @@ -37,48 +61,12 @@ return end if client.name == 'ruff' then - -- Disable hover in favor of Pyright + -- Disable hover in favor of basedpyright client.server_capabilities.hoverProvider = false end end, desc = 'LSP: Disable hover capability from Ruff', }) - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.completion.completionItem.snippetSupport = true - require('lspconfig').basedpyright.setup { settings = { pyright = { disableOrganizeImports = true } } } - require('lspconfig').ruff.setup { } - require('lspconfig').csharp_ls.setup { } - require('lspconfig').nil_ls.setup { - cmd = { "${lib.getExe pkgs.nil}" }, - settings = { - ['nil'] = { - formatting = { - command = { "${lib.getExe pkgs.nixfmt-rfc-style}" }, - }, - }, - }, - } - require('lspconfig').luau_lsp.setup { } - require('lspconfig').denols.setup { } - require('lspconfig').eslint.setup { } - require('lspconfig').html.setup { - capabilities = capabilities, - } - require('lspconfig').cssls.setup { - capabilities = capabilities, - } - require('lspconfig').jsonls.setup { - capabilities = capabilities, - } - require('lspconfig').tailwindcss.setup { } - require('lspconfig').dockerls.setup { } - require('lspconfig').docker_compose_language_service.setup { } - require('lspconfig').bashls.setup { } - require('lspconfig').powershell_es.setup { - bundle_path = "${lib.getExe pkgs.powershell-editor-services}", - shell = "${lib.getExe pkgs.powershell}", - } - require('lspconfig').typos_lsp.setup { } ''; }; trouble = { diff --git a/nixos/nvim/plugins/oil.nix b/nixos/nvim/plugins/oil.nix deleted file mode 100644 index e4e6f7e..0000000 --- a/nixos/nvim/plugins/oil.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - programs.nixvim = { - plugins = { - oil = { - enable = true; - settings = { - default_file_explorer = false; - }; - }; - }; - keymaps = [ - { - mode = "n"; - key = "o"; - action = "Oil --float"; - options = { - desc = "Manage Files"; - silent = true; - }; - } - ]; - }; -} diff --git a/nixos/nvim/plugins/surround.nix b/nixos/nvim/plugins/surround.nix new file mode 100644 index 0000000..ba3c495 --- /dev/null +++ b/nixos/nvim/plugins/surround.nix @@ -0,0 +1,9 @@ +{ + programs.nixvim = { + plugins = { + nvim-surround = { + enable = true; + }; + }; + }; +} diff --git a/nixos/nvim/settings.nix b/nixos/nvim/settings.nix index 1212689..6cf993c 100755 --- a/nixos/nvim/settings.nix +++ b/nixos/nvim/settings.nix @@ -13,7 +13,7 @@ byteCompileLua = { enable = true; configs = true; - initLua = true; + initLua = false; nvimRuntime = true; plugins = true; }; @@ -61,6 +61,17 @@ sqlite-lua.enable = true; lazydev.enable = true; }; + userCommands = { + ViewInit = { + desc = "Open the Neovim init.lua file"; + command = "lua vim.cmd('view '.. InitPath)"; + }; + }; + extraConfigLua = # lua + '' + InitPath = debug.getinfo(1, "S").source:sub(2) + print("Neovim init file location: " .. InitPath) + ''; extraConfigVim = '' set number " enable number lines '';