From f483bd632cfd4df9df0e31fa1bd71df6bb918bcb Mon Sep 17 00:00:00 2001 From: MFlossmann Date: Fri, 12 Jul 2024 15:18:42 +0200 Subject: [PATCH 01/10] edit the lsp config --- plugins/lsp.nix | 35 +++++++++++++++++++++++++++-------- plugins/telescope.nix | 38 +++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/plugins/lsp.nix b/plugins/lsp.nix index ebea72f..1c8b15f 100644 --- a/plugins/lsp.nix +++ b/plugins/lsp.nix @@ -32,7 +32,26 @@ action = "code_action"; desc = "LSP code action"; }; - + "lr" = { + action = "rename"; + desc = "Rename current symbol"; + }; + "lR" = { + action = "rename"; + desc = "Search references"; + }; + "lh" = { + action = "signature_help"; + desc = "Signature help"; + }; + "lG" = { + action = "workspace_symbol"; + desc = "Search workspace symbols"; + }; + "gK" = { + action = "signature_help"; + desc = "Signature help"; + }; gd = { action = "definition"; desc = "Go to definition"; @@ -80,25 +99,25 @@ # Load all servers definitions servers = { - ansiblels.enable = true; bashls.enable = true; cssls.enable = true; docker-compose-language-service.enable = true; dockerls.enable = true; - eslint.enable = true; - gopls.enable = true; helm-ls.enable = true; html.enable = true; - java-language-server.enable = true; jsonls.enable = true; lua-ls.enable = true; nginx-language-server.enable = true; nixd.enable = true; pyright.enable = true; - sqls.enable = true; - terraformls.enable = true; - tsserver.enable = true; yamlls.enable = true; + clangd.enable = true; + marksman.enable = true; + texlab.enable = true; + + java-language-server.enable = false; + zls.enable = false; + rust-analyzer.enable = false; typos-lsp = { enable = true; diff --git a/plugins/telescope.nix b/plugins/telescope.nix index faa4d37..5cfeb09 100644 --- a/plugins/telescope.nix +++ b/plugins/telescope.nix @@ -35,25 +35,25 @@ # │ │ Preview │ │ # │ └────────────────────────────────────────┘ │ # └──────────────────────────────────────────────────┘ - extraConfigLuaPre = '' - local TelescopeWithTheme = function(fn, args, extension) - args.layout_config = { - anchor = "N", - mirror = true, - width = 0.8, - } - - if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end - - local args_with_theme = require("telescope.themes").get_dropdown(args) - - if extension ~= "" then - require("telescope").extensions[extension][fn](args_with_theme) - else - require("telescope.builtin")[fn](args_with_theme) - end - end - ''; + # extraConfigLuaPre = '' + # local TelescopeWithTheme = function(fn, args, extension) + # args.layout_config = { + # anchor = "N", + # mirror = true, + # width = 0.8, + # } + # + # if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end + # + # local args_with_theme = require("telescope.themes").get_dropdown(args) + # + # if extension ~= "" then + # require("telescope").extensions[extension][fn](args_with_theme) + # else + # require("telescope.builtin")[fn](args_with_theme) + # end + # end + # ''; # Use root keymaps to allow usage of custom TelescopeWithTheme function keymaps = From d49cf6e3ad7d4a648f1befd9df57e03de0d01fca Mon Sep 17 00:00:00 2001 From: MFlossmann Date: Sat, 13 Jul 2024 08:37:13 +0200 Subject: [PATCH 02/10] fix telescope --- plugins/telescope.nix | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/plugins/telescope.nix b/plugins/telescope.nix index 5cfeb09..0e261fb 100644 --- a/plugins/telescope.nix +++ b/plugins/telescope.nix @@ -35,27 +35,28 @@ # │ │ Preview │ │ # │ └────────────────────────────────────────┘ │ # └──────────────────────────────────────────────────┘ - # extraConfigLuaPre = '' - # local TelescopeWithTheme = function(fn, args, extension) - # args.layout_config = { - # anchor = "N", - # mirror = true, - # width = 0.8, - # } - # - # if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end - # - # local args_with_theme = require("telescope.themes").get_dropdown(args) - # - # if extension ~= "" then - # require("telescope").extensions[extension][fn](args_with_theme) - # else - # require("telescope.builtin")[fn](args_with_theme) - # end - # end - # ''; + extraConfigLuaPre = '' + local telescopeWithArgs = function(fn, args, extension) + -- args.layout_config = { + -- anchor = "N", + -- mirror = true, + -- width = 0.8, + -- } + + -- if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end + + -- local args_with_theme = require("telescope.themes").get_dropdown(args) + local args_with_theme = args - # Use root keymaps to allow usage of custom TelescopeWithTheme function + if extension ~= "" then + require("telescope").extensions[extension][fn](args_with_theme) + else + require("telescope.builtin")[fn](args_with_theme) + end + end + ''; + + # Use root keymaps to allow usage of custom telescopeWithArgs function keymaps = let mkTelescopeKeymap = @@ -68,7 +69,7 @@ }: { inherit key mode; - action.__raw = "function() TelescopeWithTheme('${fn}', ${helpers.toLuaObject args}, '${builtins.toString extension}') end"; + action.__raw = "function() telescopeWithArgs('${fn}', ${helpers.toLuaObject args}, '${builtins.toString extension}') end"; options = { inherit desc; }; }; in From f76b55307665c0510aa2bb00c85c8fd397b24ea3 Mon Sep 17 00:00:00 2001 From: MFlossmann Date: Sat, 13 Jul 2024 08:37:22 +0200 Subject: [PATCH 03/10] add keymaps --- plugins/comment.nix | 15 +++++++++++++++ plugins/oil.nix | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/plugins/comment.nix b/plugins/comment.nix index 44a327e..d9b9608 100644 --- a/plugins/comment.nix +++ b/plugins/comment.nix @@ -7,4 +7,19 @@ _: enable = true; settings.pre_hook = "require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook()"; }; + + keymaps = [ + { + key = "/"; + action = "(comment_toggle_linewise_current)"; + options.desc = "Toggle comment line"; + mode = "n"; + } + { + key = "/"; + action = "(comment_toggle_linewise_visual)"; + options.desc = "Toggle comment line"; + mode = "v"; + } + ]; } diff --git a/plugins/oil.nix b/plugins/oil.nix index f7ed885..fdb0f46 100644 --- a/plugins/oil.nix +++ b/plugins/oil.nix @@ -1,3 +1,18 @@ _: { opts.enable = true; + + keymaps = [ + { + key = "O"; + action = "function() require('oil').toggle_float() end"; + options.desc = "Toggle oil floating window"; + mode = "n"; + } + { + key = "to"; + action = "function() require('oil').toggle_float() end"; + options.desc = "Toggle oil floating window"; + mode = "n"; + } + ]; } From 1ca9e8e0169436844b7d4ef0688e7224cdde29bc Mon Sep 17 00:00:00 2001 From: MFlossmann Date: Sat, 13 Jul 2024 11:14:17 +0200 Subject: [PATCH 04/10] add find keymaps --- plugins/telescope.nix | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/plugins/telescope.nix b/plugins/telescope.nix index 0e261fb..d15a11b 100644 --- a/plugins/telescope.nix +++ b/plugins/telescope.nix @@ -37,16 +37,15 @@ # └──────────────────────────────────────────────────┘ extraConfigLuaPre = '' local telescopeWithArgs = function(fn, args, extension) - -- args.layout_config = { - -- anchor = "N", - -- mirror = true, - -- width = 0.8, - -- } + args.layout_config = { + anchor = "N", + mirror = true, + width = 0.8, + } - -- if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end + if fn == "keymaps" or fn == "registers" then args.layout_config.height = function(_, _, max_lines) return max_lines end end - -- local args_with_theme = require("telescope.themes").get_dropdown(args) - local args_with_theme = args + local args_with_theme = require("telescope.themes").get_dropdown(args) if extension ~= "" then require("telescope").extensions[extension][fn](args_with_theme) @@ -109,7 +108,7 @@ fn = "live_grep"; } { - desc = "Find help tags"; + desc = "Find help"; key = "fh"; fn = "help_tags"; } @@ -130,14 +129,33 @@ } { desc = "Find word under cursor"; - key = "fw"; + key = "f*"; fn = "grep_string"; } { desc = "Search references"; - key = "gr"; + key = "lR"; fn = "lsp_references"; } + { + desc = "Find marks"; + key = "f'"; + fn = "marks"; + } + { + desc = "Find commands"; + key = "fC"; + fn = "commands"; + } + { + desc = "Find themes"; + key = "ft"; + fn = "colortheme"; + args = { + enable_preview = true; + ignore_builtins = true; + }; + } ]; }; } From 0d6ddb5b6d77f1517bdfa88afa2f5328428d071c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michi=20Flo=C3=9Fmann?= Date: Sat, 13 Jul 2024 13:38:40 +0200 Subject: [PATCH 05/10] add luasnip loader code --- plugins/luasnip.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/luasnip.nix b/plugins/luasnip.nix index 4701491..a19b3a6 100644 --- a/plugins/luasnip.nix +++ b/plugins/luasnip.nix @@ -1,3 +1,9 @@ _:{ opts.enable = true; + + rootOpts = { + extraConfigLuaPre = '' + require("luasnip.loaders.from_lua").load({paths = "~/.config/snippets/"}) + ''; + }; } From 556f20bb3e24fbacc486a205b5066f7d890a443b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michi=20Flo=C3=9Fmann?= Date: Sat, 13 Jul 2024 13:38:56 +0200 Subject: [PATCH 06/10] add otter plugin --- plugins/otter.nix | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 plugins/otter.nix diff --git a/plugins/otter.nix b/plugins/otter.nix new file mode 100644 index 0000000..4701491 --- /dev/null +++ b/plugins/otter.nix @@ -0,0 +1,3 @@ +_:{ + opts.enable = true; +} From fcf93367045238ff598da59cce0d095b6aefaec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michi=20Flo=C3=9Fmann?= Date: Sat, 13 Jul 2024 13:44:15 +0200 Subject: [PATCH 07/10] add a todo --- plugins/luasnip.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/luasnip.nix b/plugins/luasnip.nix index a19b3a6..7852fc7 100644 --- a/plugins/luasnip.nix +++ b/plugins/luasnip.nix @@ -1,6 +1,7 @@ _:{ opts.enable = true; + # TODO: There's a better way to do this rootOpts = { extraConfigLuaPre = '' require("luasnip.loaders.from_lua").load({paths = "~/.config/snippets/"}) From 5844802ff07d289cad3c56c80c559aab4ba0babb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michi=20Flo=C3=9Fmann?= Date: Sat, 13 Jul 2024 13:55:37 +0200 Subject: [PATCH 08/10] use the nixvim way of loading snippets --- plugins/luasnip.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugins/luasnip.nix b/plugins/luasnip.nix index 7852fc7..613d852 100644 --- a/plugins/luasnip.nix +++ b/plugins/luasnip.nix @@ -1,10 +1,9 @@ _:{ - opts.enable = true; + opts = { + enable = true; - # TODO: There's a better way to do this - rootOpts = { - extraConfigLuaPre = '' - require("luasnip.loaders.from_lua").load({paths = "~/.config/snippets/"}) - ''; + fromLua = [ + { paths = "~/.config/snippets/"; } + ]; }; } From 8a72107a1d918319dc9a1441947a4cf31e9be4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michi=20Flo=C3=9Fmann?= Date: Sat, 13 Jul 2024 14:25:39 +0200 Subject: [PATCH 09/10] update nixvim --- flake.lock | 135 +++++++++++++++------------------------ plugins/guess-indent.nix | 2 +- plugins/treesitter.nix | 4 +- 3 files changed, 56 insertions(+), 85 deletions(-) diff --git a/flake.lock b/flake.lock index e332e43..4b9d2b9 100644 --- a/flake.lock +++ b/flake.lock @@ -9,11 +9,11 @@ ] }, "locked": { - "lastModified": 1713532798, - "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "lastModified": 1717408969, + "narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", "owner": "numtide", "repo": "devshell", - "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "rev": "1ebbe68d57457c8cae98145410b164b5477761f4", "type": "github" }, "original": { @@ -36,22 +36,6 @@ "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" } }, - "flake-compat_2": { - "flake": false, - "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", - "owner": "edolstra", - "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", - "type": "github" - }, - "original": { - "owner": "edolstra", - "repo": "flake-compat", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -60,11 +44,11 @@ ] }, "locked": { - "lastModified": 1715865404, - "narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=", + "lastModified": 1719877454, + "narHash": "sha256-g5N1yyOSsPNiOlFfkuI/wcUjmtah+nxdImJqrSATjOU=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9", + "rev": "4e3583423212f9303aa1a6337f8dffb415920e4f", "type": "github" }, "original": { @@ -73,21 +57,6 @@ "type": "github" } }, - "flake-root": { - "locked": { - "lastModified": 1713493429, - "narHash": "sha256-ztz8JQkI08tjKnsTpfLqzWoKFQF4JGu2LRz8bkdnYUk=", - "owner": "srid", - "repo": "flake-root", - "rev": "bc748b93b86ee76e2032eecda33440ceb2532fcd", - "type": "github" - }, - "original": { - "owner": "srid", - "repo": "flake-root", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -106,11 +75,41 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "nixvim", + "flake-compat" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719259945, + "narHash": "sha256-F1h+XIsGKT9TkGO3omxDLEb/9jOOsI6NnzsXFsZhry4=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ "nixvim", - "pre-commit-hooks", + "git-hooks", "nixpkgs" ] }, @@ -136,11 +135,11 @@ ] }, "locked": { - "lastModified": 1716457508, - "narHash": "sha256-ZxzffLuWRyuMrkVVq7wastNUqeO0HJL9xqfY1QsYaqo=", + "lastModified": 1719827439, + "narHash": "sha256-tneHOIv1lEavZ0vQ+rgz67LPNCgOZVByYki3OkSshFU=", "owner": "nix-community", "repo": "home-manager", - "rev": "850cb322046ef1a268449cf1ceda5fd24d930b05", + "rev": "59ce796b2563e19821361abbe2067c3bb4143a7d", "type": "github" }, "original": { @@ -157,11 +156,11 @@ ] }, "locked": { - "lastModified": 1716511055, - "narHash": "sha256-5Fe/DGgvMhPEMl9VdVxv3zvwRcwNDmW5eRJ0gk72w7U=", + "lastModified": 1719845423, + "narHash": "sha256-ZLHDmWAsHQQKnmfyhYSHJDlt8Wfjv6SQhl2qek42O7A=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "0bea8222f6e83247dd13b055d83e64bce02ee532", + "rev": "ec12b88104d6c117871fad55e931addac4626756", "type": "github" }, "original": { @@ -194,11 +193,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1716509168, - "narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=", + "lastModified": 1720542800, + "narHash": "sha256-ZgnNHuKV6h2+fQ5LuqnUaqZey1Lqqt5dTUAiAnqH0QQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "bfb7a882678e518398ce9a31a881538679f6f092", + "rev": "feb2849fdeb70028c70d73b848214b00d324a497", "type": "github" }, "original": { @@ -213,21 +212,20 @@ "devshell": "devshell", "flake-compat": "flake-compat", "flake-parts": "flake-parts", - "flake-root": "flake-root", + "git-hooks": "git-hooks", "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nixpkgs": [ "nixpkgs" ], - "pre-commit-hooks": "pre-commit-hooks", "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1716759197, - "narHash": "sha256-I4r9krPVUl1b70VbC8j8xDQ2mDBoGCx8tH9CExiJMd8=", + "lastModified": 1720864742, + "narHash": "sha256-NVkF91eZPav7zbcMR+7mUzOdMKgIEBJSwtFU2rv1OpY=", "owner": "nix-community", "repo": "nixvim", - "rev": "ba293d36403c39c22dbb9a928f9af4d0df54b79f", + "rev": "195978e6272702ea5d6e9b837d083c411dc5d688", "type": "github" }, "original": { @@ -268,33 +266,6 @@ "type": "gitlab" } }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": "flake-compat_2", - "gitignore": "gitignore", - "nixpkgs": [ - "nixvim", - "nixpkgs" - ], - "nixpkgs-stable": [ - "nixvim", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1716213921, - "narHash": "sha256-xrsYFST8ij4QWaV6HEokCUNIZLjjLP1bYC60K8XiBVA=", - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "rev": "0e8fcc54b842ad8428c9e705cb5994eaf05c26a0", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "pre-commit-hooks.nix", - "type": "github" - } - }, "root": { "inputs": { "nix-formatter-pack": "nix-formatter-pack", @@ -325,11 +296,11 @@ ] }, "locked": { - "lastModified": 1715940852, - "narHash": "sha256-wJqHMg/K6X3JGAE9YLM0LsuKrKb4XiBeVaoeMNlReZg=", + "lastModified": 1719887753, + "narHash": "sha256-p0B2r98UtZzRDM5miGRafL4h7TwGRC4DII+XXHDHqek=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "2fba33a182602b9d49f0b2440513e5ee091d838b", + "rev": "bdb6355009562d8f9313d9460c0d3860f525bc6c", "type": "github" }, "original": { diff --git a/plugins/guess-indent.nix b/plugins/guess-indent.nix index 63b70dc..d1e19bf 100644 --- a/plugins/guess-indent.nix +++ b/plugins/guess-indent.nix @@ -8,7 +8,7 @@ # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/configs/guess-indent.lua config = '' require("guess-indent").setup({}) - vim.cmd.lua { args = { "require('guess-indent').set_from_buffer('auto_cmd')" }, mods = { silent = true } } + vim.cmd.lua { args = { "require('guess-indent').set_from_buffer()" }, mods = { silent = true } } ''; }; } diff --git a/plugins/treesitter.nix b/plugins/treesitter.nix index ddb4fc5..d88603b 100644 --- a/plugins/treesitter.nix +++ b/plugins/treesitter.nix @@ -8,12 +8,12 @@ enable = true; # Enable treesitter based indentation (use '=' to auto-indent) - indent = true; + settings.indent.enable = true; # Workaround to enable incremental selection without setting default keymaps (keymaps are set globally) # This is needed in order to set custom descriptions and avoid to have multiple keymaps # See https://github.com/nix-community/nixvim/issues/1506 - moduleConfig.incremental_selection = { + settings.incremental_selection = { enable = true; keymaps = lib.mkForce { }; }; From e4255f08179a6ea39b26488142246a5d3cfd8d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michi=20Flo=C3=9Fmann?= Date: Thu, 1 Aug 2024 16:15:05 +0200 Subject: [PATCH 10/10] add arrow plugin --- plugins/arrow.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 plugins/arrow.nix diff --git a/plugins/arrow.nix b/plugins/arrow.nix new file mode 100644 index 0000000..6e7401c --- /dev/null +++ b/plugins/arrow.nix @@ -0,0 +1,16 @@ +{ icons, pkgs, ... }: +{ + opts.enable = true; + + extra = { + packages = [ pkgs.vimPlugins.arrow-nvim ]; + + config = '' + require('arrow').setup({ + show_icons = true, + leader_key = ';', -- Recommended to be a single key + buffer_leader_key = 'm', -- Per Buffer Mappings + }) + ''; + }; +}