From 2a80c2bac183e8a471c6e20daa6ae22c1171e1bd Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 6 Jul 2024 17:14:45 +0200 Subject: [PATCH] working nvf! --- hosts/vali/hermit/configuration.nix | 2 +- modules/editors/nvf/default.nix | 9 +- modules/editors/nvf/lua/misc/handlers.lua | 38 +++---- modules/editors/nvf/plugins/extra.nix | 93 +++++++++++++++--- .../nvf/plugins/settings/assistant.nix | 2 +- .../nvf/plugins/settings/autocomplete.nix | 2 +- .../nvf/plugins/settings/autopairs.nix | 2 +- .../editors/nvf/plugins/settings/binds.nix | 2 +- .../editors/nvf/plugins/settings/comments.nix | 2 +- .../nvf/plugins/settings/dashboard.nix | 2 +- .../editors/nvf/plugins/settings/debugger.nix | 2 +- .../editors/nvf/plugins/settings/filetree.nix | 1 - .../editors/nvf/plugins/settings/gestures.nix | 1 - modules/editors/nvf/plugins/settings/git.nix | 1 - .../nvf/plugins/settings/languages.nix | 13 +-- modules/editors/nvf/plugins/settings/lsp.nix | 1 - .../editors/nvf/plugins/settings/minimap.nix | 1 - .../editors/nvf/plugins/settings/notes.nix | 1 - .../editors/nvf/plugins/settings/notify.nix | 1 - .../editors/nvf/plugins/settings/presence.nix | 1 - .../editors/nvf/plugins/settings/projects.nix | 1 - .../editors/nvf/plugins/settings/session.nix | 1 - .../nvf/plugins/settings/statusline.nix | 1 - .../editors/nvf/plugins/settings/tabline.nix | 1 - .../nvf/plugins/settings/telescope.nix | 1 - .../editors/nvf/plugins/settings/template.nix | 1 - .../editors/nvf/plugins/settings/terminal.nix | 1 - .../editors/nvf/plugins/settings/theme.nix | 1 - .../nvf/plugins/settings/treesitter.nix | 1 - modules/editors/nvf/plugins/settings/ui.nix | 1 - .../editors/nvf/plugins/settings/utility.nix | 1 - .../editors/nvf/plugins/settings/visuals.nix | 1 - .../editors/nvf/plugins/sources/default.nix | 85 ---------------- .../nvf/runtime/after/ftdetect/gitconfig.lua | 8 ++ .../nvf/runtime/after/ftdetect/graphql.lua | 8 ++ .../nvf/runtime/after/ftplugin/envrc.lua | 4 + .../nvf/runtime/after/ftplugin/gitcommit.lua | 2 + .../editors/nvf/runtime/after/ftplugin/go.lua | 5 + .../nvf/runtime/after/ftplugin/json.lua | 14 +++ .../nvf/runtime/after/ftplugin/man.lua | 13 +++ .../nvf/runtime/after/ftplugin/markdown.lua | 30 ++++++ .../editors/nvf/runtime/after/ftplugin/qf.lua | 2 + .../nvf/runtime/after/ftplugin/xml.lua | 2 + .../runtime/after/queries/go/injections.scm | 30 ++++++ .../runtime/after/queries/jsx/injections.scm | 2 + .../after/queries/markdown/textobjects.scm | 5 + .../queries/markdown_inline/highlights.scm | 12 +++ .../runtime/after/queries/mdx/injections.scm | 9 ++ .../runtime/after/queries/rust/injections.scm | 14 +++ .../after/queries/typst/highlights.scm | 5 + .../editors/nvf/runtime/spell/en.utf-8.add | 42 ++++++++ .../nvf/runtime/spell/en.utf-8.add.spl | Bin 0 -> 478 bytes modules/editors/nvf/settings.nix | 21 ++-- 53 files changed, 330 insertions(+), 172 deletions(-) delete mode 100644 modules/editors/nvf/plugins/sources/default.nix create mode 100644 modules/editors/nvf/runtime/after/ftdetect/gitconfig.lua create mode 100644 modules/editors/nvf/runtime/after/ftdetect/graphql.lua create mode 100644 modules/editors/nvf/runtime/after/ftplugin/envrc.lua create mode 100644 modules/editors/nvf/runtime/after/ftplugin/gitcommit.lua create mode 100644 modules/editors/nvf/runtime/after/ftplugin/go.lua create mode 100644 modules/editors/nvf/runtime/after/ftplugin/json.lua create mode 100644 modules/editors/nvf/runtime/after/ftplugin/man.lua create mode 100644 modules/editors/nvf/runtime/after/ftplugin/markdown.lua create mode 100644 modules/editors/nvf/runtime/after/ftplugin/qf.lua create mode 100644 modules/editors/nvf/runtime/after/ftplugin/xml.lua create mode 100644 modules/editors/nvf/runtime/after/queries/go/injections.scm create mode 100644 modules/editors/nvf/runtime/after/queries/jsx/injections.scm create mode 100644 modules/editors/nvf/runtime/after/queries/markdown/textobjects.scm create mode 100644 modules/editors/nvf/runtime/after/queries/markdown_inline/highlights.scm create mode 100644 modules/editors/nvf/runtime/after/queries/mdx/injections.scm create mode 100644 modules/editors/nvf/runtime/after/queries/rust/injections.scm create mode 100644 modules/editors/nvf/runtime/after/queries/typst/highlights.scm create mode 100644 modules/editors/nvf/runtime/spell/en.utf-8.add create mode 100644 modules/editors/nvf/runtime/spell/en.utf-8.add.spl diff --git a/hosts/vali/hermit/configuration.nix b/hosts/vali/hermit/configuration.nix index 7def965..991ff21 100644 --- a/hosts/vali/hermit/configuration.nix +++ b/hosts/vali/hermit/configuration.nix @@ -81,7 +81,7 @@ helix.enable = true; kakoune.enable = true; nixvim.enable = false; # broken at the moment - # neovim.enable = true; + neovim.enable = true; }; services = { pipewire.enable = true; diff --git a/modules/editors/nvf/default.nix b/modules/editors/nvf/default.nix index db35a18..9cbeccc 100644 --- a/modules/editors/nvf/default.nix +++ b/modules/editors/nvf/default.nix @@ -1,6 +1,7 @@ { - inputs, + config, lib, + inputs, ... }: let inherit (builtins) filter map toString elem; @@ -10,7 +11,7 @@ mkNeovimModule = { path, - ingoredPaths ? [./nvf.nix], + ingoredPaths ? [./nvf.nix ./plugins/sources/default.nix], }: filter (hasSuffix ".nix") ( map toString ( @@ -20,9 +21,9 @@ nvf = inputs.neovim-flake; in { - imports = concatLists [ +imports = concatLists [ # neovim-flake home-manager module - [nvf.homeManagerModules.default] + [nvf.nixosModules.default] # construct this entore directory as a module # which means all default.nix files will be imported automtically diff --git a/modules/editors/nvf/lua/misc/handlers.lua b/modules/editors/nvf/lua/misc/handlers.lua index e068569..fead459 100644 --- a/modules/editors/nvf/lua/misc/handlers.lua +++ b/modules/editors/nvf/lua/misc/handlers.lua @@ -1,16 +1,16 @@ -- luacheck: ignore local float_options = { - border = 'single', - max_width = math.ceil(vim.api.nvim_win_get_width(0) * 0.6), - max_height = math.ceil(vim.api.nvim_win_get_height(0) * 0.8), + border = 'single', + max_width = math.ceil(vim.api.nvim_win_get_width(0) * 0.6), + max_height = math.ceil(vim.api.nvim_win_get_height(0) * 0.8), } vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = true, - signs = false, - underline = true, - update_in_insert = false, - severity_sort = true, + virtual_text = true, + signs = false, + underline = true, + update_in_insert = false, + severity_sort = true, }) vim.lsp.handlers['textDocument/show_line_diagnostics'] = vim.lsp.with(vim.lsp.handlers.hover, float_options) @@ -18,17 +18,17 @@ vim.lsp.handlers['textDocument/show_line_diagnostics'] = vim.lsp.with(vim.lsp.ha -- Prevent show notification -- vim.lsp.handlers['textDocument/hover'] = function(_, result, ctx, config) - config = config or float_options - config.focus_id = ctx.method - if not result then - return - end - local markdown_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents) - markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines) - if vim.tbl_isempty(markdown_lines) then - return - end - return vim.lsp.util.open_floating_preview(markdown_lines, 'markdown', config) + config = config or float_options + config.focus_id = ctx.method + if not result then + return + end + local markdown_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents) + markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines) + if vim.tbl_isempty(markdown_lines) then + return + end + return vim.lsp.util.open_floating_preview(markdown_lines, 'markdown', config) end vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, float_options) diff --git a/modules/editors/nvf/plugins/extra.nix b/modules/editors/nvf/plugins/extra.nix index 7ec0089..c504fe0 100644 --- a/modules/editors/nvf/plugins/extra.nix +++ b/modules/editors/nvf/plugins/extra.nix @@ -1,14 +1,88 @@ { config, - self, pkgs, ... }: let inherit (config.modules.other.system) username; inherit (pkgs.vimPlugins) friendly-snippets aerial-nvim nvim-surround undotree mkdir-nvim ssr-nvim direnv-vim legendary-nvim; - pluginSources = import ./sources {inherit self pkgs;}; + inherit (pkgs) fetchFromGitHub; + inherit (pkgs.vimUtils) buildVimPlugin; + + pluginSources = { + + smart-splits = buildVimPlugin { + name = "smart-splits"; + src = fetchFromGitHub { + owner = "mrjones2014"; + repo = "smart-splits.nvim"; + rev = "95833675cd92538bf9cded1d2d58d1fc271c5428"; + hash = "sha256-TsEzHalLTLp9USV0aGRadAObViC/OpIJeuEJ95lJUL8="; + }; + }; + + regexplainer = buildVimPlugin { + name = "nvim-regexplainer"; + src = fetchFromGitHub { + owner = "bennypowers"; + repo = "nvim-regexplainer"; + rev = "4250c8f3c1307876384e70eeedde5149249e154f"; + hash = "sha256-15DLbKtOgUPq4DcF71jFYu31faDn52k3P1x47GL3+b0="; + }; + }; + + specs-nvim = buildVimPlugin { + name = "specs.nvim"; + src = fetchFromGitHub { + owner = "notashelf"; + repo = "specs.nvim"; + rev = "0792aaebf8cbac0c8545c43ad648b98deb83af42"; + hash = "sha256-doHE/3bRuC8lyYxMk927JmwLfiy7aR22+i+BNefEGJ4="; + }; + }; + + deferred-clipboard = buildVimPlugin { + name = "deferred-clipboard"; + src = fetchFromGitHub { + owner = "EtiamNullam"; + repo = "deferred-clipboard.nvim"; + rev = "810a29d166eaa41afc220cc7cd85eeaa3c43b37f"; + hash = "sha256-nanNQEtpjv0YKEkkrPmq/5FPxq+Yj/19cs0Gf7YgKjU="; + }; + }; + /* + data-viewer-nvim = buildVimPlugin { + name = "data-viewer.nvim"; + src = fetchFromGitHub { + owner = "VidocqH"; + repo = "data-viewer.nvim"; + rev = "40ddf37bb7ab6c04ff9e820812d1539afe691668"; + hash = "sha256-D5hvLhsYski11H9qiDDL2zlZMtYmbpHgpewiWR6C7rE="; + }; + }; +*/ + vim-nftables = buildVimPlugin { + name = "vim-nftables"; + src = fetchFromGitHub { + owner = "awisse"; + repo = "vim-nftables"; + rev = "bc29309080b4c7e1888ffb1a830846be16e5b8e7"; + hash = "sha256-L1x3Hv95t/DBBrLtPBKrqaTbIPor/NhVuEHVIYo/OaA="; + }; + }; + + neotab-nvim = buildVimPlugin { + name = "neotab.nvim"; + src = fetchFromGitHub { + owner = "kawre"; + repo = "neotab.nvim"; + rev = "6c6107dddaa051504e433608f59eca606138269b"; + hash = "sha256-bSFKbjj8fJHdfBzYoQ9l3NU0GAYfdfCbESKbwdbLNSw="; + }; + }; + }; + in { - home-manager.users.${username}.programs.neovim-flake.settings.vim.extraPlugins = { + programs.neovim-flake.settings.vim.extraPlugins = { # plugins that are pulled from nixpkgs direnv = {package = direnv-vim;}; friendly-snippets = {package = friendly-snippets;}; @@ -46,7 +120,7 @@ in { # plugins that are built from their sources regexplainer = {package = pluginSources.regexplainer;}; vim-nftables = {package = pluginSources.vim-nftables;}; - +/* data-view = { package = pluginSources.data-viewer-nvim; setup = '' @@ -63,16 +137,7 @@ in { vim.api.nvim_set_keymap('n', 'dvc', ':DataViewerClose', {noremap = true}) ''; }; - - slides-nvim = { - package = pluginSources.slides-nvim; - setup = "require('slides').setup {}"; - }; - - hmts = { - package = pluginSources.hmts; - after = ["treesitter"]; - }; +*/ smart-splits = { package = pluginSources.smart-splits; diff --git a/modules/editors/nvf/plugins/settings/assistant.nix b/modules/editors/nvf/plugins/settings/assistant.nix index 91471ba..bfe0a05 100644 --- a/modules/editors/nvf/plugins/settings/assistant.nix +++ b/modules/editors/nvf/plugins/settings/assistant.nix @@ -1,7 +1,7 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}.programs.neovim-flake.settings.vim = { + programs.neovim-flake.settings.vim = { assistant.copilot = { enable = true; cmp.enable = true; diff --git a/modules/editors/nvf/plugins/settings/autocomplete.nix b/modules/editors/nvf/plugins/settings/autocomplete.nix index 400bafb..f6a6fbb 100644 --- a/modules/editors/nvf/plugins/settings/autocomplete.nix +++ b/modules/editors/nvf/plugins/settings/autocomplete.nix @@ -1,7 +1,7 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}.programs.neovim-flake.settings.vim = { + programs.neovim-flake.settings.vim = { autocomplete = { enable = true; type = "nvim-cmp"; diff --git a/modules/editors/nvf/plugins/settings/autopairs.nix b/modules/editors/nvf/plugins/settings/autopairs.nix index 26d331e..6b84dab 100644 --- a/modules/editors/nvf/plugins/settings/autopairs.nix +++ b/modules/editors/nvf/plugins/settings/autopairs.nix @@ -1,7 +1,7 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}.programs.neovim-flake.settings.vim = { + programs.neovim-flake.settings.vim = { autopairs.enable = true; }; } diff --git a/modules/editors/nvf/plugins/settings/binds.nix b/modules/editors/nvf/plugins/settings/binds.nix index e1bed17..e09effb 100644 --- a/modules/editors/nvf/plugins/settings/binds.nix +++ b/modules/editors/nvf/plugins/settings/binds.nix @@ -1,7 +1,7 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}.programs.neovim-flake.settings.vim = { + programs.neovim-flake.settings.vim = { binds = { whichKey.enable = true; cheatsheet.enable = false; diff --git a/modules/editors/nvf/plugins/settings/comments.nix b/modules/editors/nvf/plugins/settings/comments.nix index 3c6693c..a8659fa 100644 --- a/modules/editors/nvf/plugins/settings/comments.nix +++ b/modules/editors/nvf/plugins/settings/comments.nix @@ -1,7 +1,7 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}.programs.neovim-flake.settings.vim = { + programs.neovim-flake.settings.vim = { comments.comment-nvim.enable = true; }; } diff --git a/modules/editors/nvf/plugins/settings/dashboard.nix b/modules/editors/nvf/plugins/settings/dashboard.nix index a5b5788..85d9824 100644 --- a/modules/editors/nvf/plugins/settings/dashboard.nix +++ b/modules/editors/nvf/plugins/settings/dashboard.nix @@ -1,7 +1,7 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}.programs.neovim-flake.settings.vim = { + programs.neovim-flake.settings.vim = { dashboard = { alpha.enable = true; }; diff --git a/modules/editors/nvf/plugins/settings/debugger.nix b/modules/editors/nvf/plugins/settings/debugger.nix index d116ced..07d5f48 100644 --- a/modules/editors/nvf/plugins/settings/debugger.nix +++ b/modules/editors/nvf/plugins/settings/debugger.nix @@ -1,7 +1,7 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}.programs.neovim-flake.settings.vim = { + programs.neovim-flake.settings.vim = { debugger.nvim-dap = { enable = true; ui.enable = true; diff --git a/modules/editors/nvf/plugins/settings/filetree.nix b/modules/editors/nvf/plugins/settings/filetree.nix index 6ca1a3c..a98dced 100644 --- a/modules/editors/nvf/plugins/settings/filetree.nix +++ b/modules/editors/nvf/plugins/settings/filetree.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { filetree = { nvimTree = { diff --git a/modules/editors/nvf/plugins/settings/gestures.nix b/modules/editors/nvf/plugins/settings/gestures.nix index d3e7370..eb18667 100644 --- a/modules/editors/nvf/plugins/settings/gestures.nix +++ b/modules/editors/nvf/plugins/settings/gestures.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { gestures.gesture-nvim.enable = false; }; diff --git a/modules/editors/nvf/plugins/settings/git.nix b/modules/editors/nvf/plugins/settings/git.nix index 5f2f1d1..361b92f 100644 --- a/modules/editors/nvf/plugins/settings/git.nix +++ b/modules/editors/nvf/plugins/settings/git.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { git = { enable = true; diff --git a/modules/editors/nvf/plugins/settings/languages.nix b/modules/editors/nvf/plugins/settings/languages.nix index bebd7ac..5358045 100644 --- a/modules/editors/nvf/plugins/settings/languages.nix +++ b/modules/editors/nvf/plugins/settings/languages.nix @@ -6,7 +6,7 @@ }: let inherit (config.modules.other.system) username; in { - home-manager.users.${username}.programs.neovim-flake.settings.vim = { + programs.neovim-flake.settings.vim = { languages = { enableLSP = true; enableFormat = true; @@ -28,17 +28,6 @@ in { elixir.enable = false; svelte.enable = false; sql.enable = false; - java = let - jdtlsCache = "${config.xdg.cacheHome}/jdtls"; - in { - enable = true; - lsp.package = [ - "${lib.getExe pkgs.jdt-language-server}" - "-configuration ${jdtlsCache}/config" - "-data ${jdtlsCache}/workspace" - ]; - }; - lua = { enable = true; lsp.neodev.enable = true; diff --git a/modules/editors/nvf/plugins/settings/lsp.nix b/modules/editors/nvf/plugins/settings/lsp.nix index b76eab2..b600161 100644 --- a/modules/editors/nvf/plugins/settings/lsp.nix +++ b/modules/editors/nvf/plugins/settings/lsp.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { lsp = { formatOnSave = true; diff --git a/modules/editors/nvf/plugins/settings/minimap.nix b/modules/editors/nvf/plugins/settings/minimap.nix index 5b3894e..66639da 100644 --- a/modules/editors/nvf/plugins/settings/minimap.nix +++ b/modules/editors/nvf/plugins/settings/minimap.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { minimap = { # cool for vanity but practically useless on small screens diff --git a/modules/editors/nvf/plugins/settings/notes.nix b/modules/editors/nvf/plugins/settings/notes.nix index 4d9f976..eab60f5 100644 --- a/modules/editors/nvf/plugins/settings/notes.nix +++ b/modules/editors/nvf/plugins/settings/notes.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { notes = { todo-comments.enable = true; diff --git a/modules/editors/nvf/plugins/settings/notify.nix b/modules/editors/nvf/plugins/settings/notify.nix index e9e0dc2..eb19037 100644 --- a/modules/editors/nvf/plugins/settings/notify.nix +++ b/modules/editors/nvf/plugins/settings/notify.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { notify = { nvim-notify.enable = true; diff --git a/modules/editors/nvf/plugins/settings/presence.nix b/modules/editors/nvf/plugins/settings/presence.nix index 5855335..267d22a 100644 --- a/modules/editors/nvf/plugins/settings/presence.nix +++ b/modules/editors/nvf/plugins/settings/presence.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { presence.neocord.enable = false; }; diff --git a/modules/editors/nvf/plugins/settings/projects.nix b/modules/editors/nvf/plugins/settings/projects.nix index edf63ce..6992a04 100644 --- a/modules/editors/nvf/plugins/settings/projects.nix +++ b/modules/editors/nvf/plugins/settings/projects.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { projects = { project-nvim = { diff --git a/modules/editors/nvf/plugins/settings/session.nix b/modules/editors/nvf/plugins/settings/session.nix index b882aaf..f9bc5f2 100644 --- a/modules/editors/nvf/plugins/settings/session.nix +++ b/modules/editors/nvf/plugins/settings/session.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { session.nvim-session-manager = { enable = false; diff --git a/modules/editors/nvf/plugins/settings/statusline.nix b/modules/editors/nvf/plugins/settings/statusline.nix index d2f90fe..20c9ff9 100644 --- a/modules/editors/nvf/plugins/settings/statusline.nix +++ b/modules/editors/nvf/plugins/settings/statusline.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { statusline = { lualine = { diff --git a/modules/editors/nvf/plugins/settings/tabline.nix b/modules/editors/nvf/plugins/settings/tabline.nix index 67fe3a6..43d1aba 100644 --- a/modules/editors/nvf/plugins/settings/tabline.nix +++ b/modules/editors/nvf/plugins/settings/tabline.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { tabline = { nvimBufferline.enable = true; diff --git a/modules/editors/nvf/plugins/settings/telescope.nix b/modules/editors/nvf/plugins/settings/telescope.nix index 8dcebb9..ac0321f 100644 --- a/modules/editors/nvf/plugins/settings/telescope.nix +++ b/modules/editors/nvf/plugins/settings/telescope.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { telescope.enable = true; }; diff --git a/modules/editors/nvf/plugins/settings/template.nix b/modules/editors/nvf/plugins/settings/template.nix index c992af0..438b7e8 100644 --- a/modules/editors/nvf/plugins/settings/template.nix +++ b/modules/editors/nvf/plugins/settings/template.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { }; } diff --git a/modules/editors/nvf/plugins/settings/terminal.nix b/modules/editors/nvf/plugins/settings/terminal.nix index d17d424..ae15699 100644 --- a/modules/editors/nvf/plugins/settings/terminal.nix +++ b/modules/editors/nvf/plugins/settings/terminal.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { terminal = { toggleterm = { diff --git a/modules/editors/nvf/plugins/settings/theme.nix b/modules/editors/nvf/plugins/settings/theme.nix index 7470f7b..79c360c 100644 --- a/modules/editors/nvf/plugins/settings/theme.nix +++ b/modules/editors/nvf/plugins/settings/theme.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { theme = { enable = true; diff --git a/modules/editors/nvf/plugins/settings/treesitter.nix b/modules/editors/nvf/plugins/settings/treesitter.nix index 85a8c83..a3f9a52 100644 --- a/modules/editors/nvf/plugins/settings/treesitter.nix +++ b/modules/editors/nvf/plugins/settings/treesitter.nix @@ -5,7 +5,6 @@ }: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { treesitter = { fold = true; diff --git a/modules/editors/nvf/plugins/settings/ui.nix b/modules/editors/nvf/plugins/settings/ui.nix index 41e118b..af157c1 100644 --- a/modules/editors/nvf/plugins/settings/ui.nix +++ b/modules/editors/nvf/plugins/settings/ui.nix @@ -5,7 +5,6 @@ }: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { ui = { noice.enable = true; diff --git a/modules/editors/nvf/plugins/settings/utility.nix b/modules/editors/nvf/plugins/settings/utility.nix index a130056..f84616e 100644 --- a/modules/editors/nvf/plugins/settings/utility.nix +++ b/modules/editors/nvf/plugins/settings/utility.nix @@ -5,7 +5,6 @@ }: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { utility = { ccc.enable = true; diff --git a/modules/editors/nvf/plugins/settings/visuals.nix b/modules/editors/nvf/plugins/settings/visuals.nix index 18edd68..ca853c9 100644 --- a/modules/editors/nvf/plugins/settings/visuals.nix +++ b/modules/editors/nvf/plugins/settings/visuals.nix @@ -1,7 +1,6 @@ {config, ...}: let inherit (config.modules.other.system) username; in { - home-manager.${username}. programs.neovim-flake.settings.vim = { visuals = { enable = true; diff --git a/modules/editors/nvf/plugins/sources/default.nix b/modules/editors/nvf/plugins/sources/default.nix deleted file mode 100644 index 27b2da8..0000000 --- a/modules/editors/nvf/plugins/sources/default.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ - self, - pkgs, - ... -}: let - inherit (self) pins; - inherit (pkgs) fetchFromGitHub; - inherit (pkgs.vimUtils) buildVimPlugin; - - sources = { - hmts = buildVimPlugin { - name = "hmts.nvim"; - src = pins."hmts.nvim"; - }; - - smart-splits = buildVimPlugin { - name = "smart-splits"; - src = fetchFromGitHub { - owner = "mrjones2014"; - repo = "smart-splits.nvim"; - rev = "95833675cd92538bf9cded1d2d58d1fc271c5428"; - hash = ""; - }; - - regexplainer = buildVimPlugin { - name = "nvim-regexplainer"; - src = fetchFromGitHub { - owner = "bennypowers"; - repo = "nvim-regexplainer"; - rev = "4250c8f3c1307876384e70eeedde5149249e154f"; - hash = "sha256-15DLbKtOgUPq4DcF71jFYu31faDn52k3P1x47GL3+b0="; - }; - }; - - specs-nvim = buildVimPlugin { - name = "specs.nvim"; - src = fetchFromGitHub { - owner = "notashelf"; - repo = "specs.nvim"; - rev = "0792aaebf8cbac0c8545c43ad648b98deb83af42"; - hash = "sha256-doHE/3bRuC8lyYxMk927JmwLfiy7aR22+i+BNefEGJ4="; - }; - }; - - deferred-clipboard = buildVimPlugin { - name = "deferred-clipboard"; - src = fetchFromGitHub { - owner = "EtiamNullam"; - repo = "deferred-clipboard.nvim"; - rev = "810a29d166eaa41afc220cc7cd85eeaa3c43b37f"; - hash = "sha256-nanNQEtpjv0YKEkkrPmq/5FPxq+Yj/19cs0Gf7YgKjU="; - }; - }; - data-viewer-nvim = buildVimPlugin { - name = "data-viewer.nvim"; - src = fetchFromGitHub { - owner = "VidocqH"; - repo = "data-viewer.nvim"; - rev = "40ddf37bb7ab6c04ff9e820812d1539afe691668"; - hash = "sha256-D5hvLhsYski11H9qiDDL2zlZMtYmbpHgpewiWR6C7rE="; - }; - }; - vim-nftables = buildVimPlugin { - name = "vim-nftables"; - src = fetchFromGitHub { - owner = "awisse"; - repo = "vim-nftables"; - rev = "bc29309080b4c7e1888ffb1a830846be16e5b8e7"; - hash = "sha256-L1x3Hv95t/DBBrLtPBKrqaTbIPor/NhVuEHVIYo/OaA="; - }; - }; - - neotab-nvim = buildVimPlugin { - name = "neotab.nvim"; - src = fetchFromGitHub { - owner = "kawre"; - repo = "neotab.nvim"; - rev = "6c6107dddaa051504e433608f59eca606138269b"; - hash = "sha256-bSFKbjj8fJHdfBzYoQ9l3NU0GAYfdfCbESKbwdbLNSw="; - }; - }; - }; - }; -in - sources diff --git a/modules/editors/nvf/runtime/after/ftdetect/gitconfig.lua b/modules/editors/nvf/runtime/after/ftdetect/gitconfig.lua new file mode 100644 index 0000000..3a7dd8b --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftdetect/gitconfig.lua @@ -0,0 +1,8 @@ +-- luacheck: ignore +vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, { + pattern = 'gitconfig*,.gitconfig*', + callback = function() + vim.bo.filetype = 'gitconfig' + end, + once = false, +}) diff --git a/modules/editors/nvf/runtime/after/ftdetect/graphql.lua b/modules/editors/nvf/runtime/after/ftdetect/graphql.lua new file mode 100644 index 0000000..f2be6cc --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftdetect/graphql.lua @@ -0,0 +1,8 @@ +-- luacheck: ignore +vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, { + pattern = '*.graphql,*.graphqls,*.gql', + callback = function() + vim.bo.filetype = 'graphql' + end, + once = false, +}) diff --git a/modules/editors/nvf/runtime/after/ftplugin/envrc.lua b/modules/editors/nvf/runtime/after/ftplugin/envrc.lua new file mode 100644 index 0000000..29877ca --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftplugin/envrc.lua @@ -0,0 +1,4 @@ +-- luacheck: ignore +vim.filetype.add({ + filename = { ['.envrc'] = 'bash' }, +}) diff --git a/modules/editors/nvf/runtime/after/ftplugin/gitcommit.lua b/modules/editors/nvf/runtime/after/ftplugin/gitcommit.lua new file mode 100644 index 0000000..bf66a00 --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftplugin/gitcommit.lua @@ -0,0 +1,2 @@ +-- luacheck: ignore +vim.opt_local.textwidth = 80 diff --git a/modules/editors/nvf/runtime/after/ftplugin/go.lua b/modules/editors/nvf/runtime/after/ftplugin/go.lua new file mode 100644 index 0000000..907a87d --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftplugin/go.lua @@ -0,0 +1,5 @@ +-- luacheck: ignore +vim.opt_local.tabstop = 4 +vim.opt_local.shiftwidth = 0 +vim.opt_local.expandtab = false +vim.opt_local.list = false diff --git a/modules/editors/nvf/runtime/after/ftplugin/json.lua b/modules/editors/nvf/runtime/after/ftplugin/json.lua new file mode 100644 index 0000000..54202da --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftplugin/json.lua @@ -0,0 +1,14 @@ +vim.keymap.set('n', 'jf', '%!jq', { noremap = true, silent = true, desc = 'Format with jq' }) +vim.keymap.set('n', 'jm', '%!jq -c', { noremap = true, silent = true, desc = 'Minify with jq' }) + +-- add comma to the end of the line on new line +vim.keymap.set('n', 'o', function() + local line = vim.api.nvim_get_current_line() + + local should_add_comma = string.find(line, '[^,{[]$') + if should_add_comma then + return 'A,' + else + return 'o' + end +end, { buffer = true, expr = true }) diff --git a/modules/editors/nvf/runtime/after/ftplugin/man.lua b/modules/editors/nvf/runtime/after/ftplugin/man.lua new file mode 100644 index 0000000..5b4fe61 --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftplugin/man.lua @@ -0,0 +1,13 @@ +-- luacheck: ignore +local opts = { noremap = true, silent = true, buffer = 0 } +local wincmd = vim.b.pager and 'q' or 'c' +vim.keymap.set('n', 'q', 'lclose' .. wincmd, opts) +vim.keymap.set('n', 'o', function() + -- TODO: can this be done in a floating window? + require('man').show_toc() +end, opts) + +vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') + .. (vim.b.undo_ftplugin ~= nil and ' | ' or '') + .. 'sil! nunmap o' + .. ' | sil! nunmap q' diff --git a/modules/editors/nvf/runtime/after/ftplugin/markdown.lua b/modules/editors/nvf/runtime/after/ftplugin/markdown.lua new file mode 100644 index 0000000..b23e9ee --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftplugin/markdown.lua @@ -0,0 +1,30 @@ +-- luacheck: ignore +vim.opt_local.textwidth = 80 + +local CR = vim.api.nvim_replace_termcodes('', true, true, true) +local function toggle_checkbox() + local cursor = vim.api.nvim_win_get_cursor(0) + local lineno = cursor[1] + local line = vim.api.nvim_buf_get_lines(0, lineno - 1, lineno, false)[1] or '' + if string.find(line, '%[ %]') then + line = line:gsub('%[ %]', '%[x%]') + else + line = line:gsub('%[x%]', '%[ %]') + end + vim.api.nvim_buf_set_lines(0, lineno - 1, lineno, false, { line }) + vim.api.nvim_win_set_cursor(0, cursor) + pcall(vim.fn['repeat#set'], ':ToggleCheckbox' .. CR) +end + +vim.api.nvim_create_user_command( + 'ToggleCheckbox', + toggle_checkbox, + vim.tbl_extend('force', { desc = 'toggle checkboxes' }, {}) +) + +vim.keymap.set('n', 'op', toggle_checkbox, { + noremap = true, + silent = true, + desc = 'Toggle checkbox', + buffer = 0, +}) diff --git a/modules/editors/nvf/runtime/after/ftplugin/qf.lua b/modules/editors/nvf/runtime/after/ftplugin/qf.lua new file mode 100644 index 0000000..8f9ca43 --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftplugin/qf.lua @@ -0,0 +1,2 @@ +-- luacheck: ignore +vim.wo.wrap = true diff --git a/modules/editors/nvf/runtime/after/ftplugin/xml.lua b/modules/editors/nvf/runtime/after/ftplugin/xml.lua new file mode 100644 index 0000000..0b4fc12 --- /dev/null +++ b/modules/editors/nvf/runtime/after/ftplugin/xml.lua @@ -0,0 +1,2 @@ +-- luacheck: ignore +vim.opt_local.shiftwidth = 2 diff --git a/modules/editors/nvf/runtime/after/queries/go/injections.scm b/modules/editors/nvf/runtime/after/queries/go/injections.scm new file mode 100644 index 0000000..f4fbe8c --- /dev/null +++ b/modules/editors/nvf/runtime/after/queries/go/injections.scm @@ -0,0 +1,30 @@ +; extends + +; inject sql into any const string with word query in the name +; e.g. const query = `SELECT * FROM users WHERE name = 'John'`; +(const_spec + name: (identifier) @_name (#match? @_name "[Qq]uery") + value: (expression_list + (raw_string_literal) @injection.content) + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "sql")) + +; inject sql in single line strings +(call_expression + (selector_expression + field: (field_identifier) @_field (#any-of? @_field "GetContext" "Get" "ExecContext" "Exec" "SelectContext" "Select" "In" "Rebind")) + (argument_list + (raw_string_literal) @injection.content) + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "sql") + ) + +; inject sql in multi line strings +(call_expression + (selector_expression + field: (field_identifier) @_field (#any-of? @_field "GetContext" "Get" "ExecContext" "Exec" "SelectContext" "Select" "In" "Rebind")) + (argument_list + (interpreted_string_literal) @injection.content) + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "sql") + ) diff --git a/modules/editors/nvf/runtime/after/queries/jsx/injections.scm b/modules/editors/nvf/runtime/after/queries/jsx/injections.scm new file mode 100644 index 0000000..72c902f --- /dev/null +++ b/modules/editors/nvf/runtime/after/queries/jsx/injections.scm @@ -0,0 +1,2 @@ +;; extends +(( jsx_text ) @injection.content (#set! injection.language "markdown") ) diff --git a/modules/editors/nvf/runtime/after/queries/markdown/textobjects.scm b/modules/editors/nvf/runtime/after/queries/markdown/textobjects.scm new file mode 100644 index 0000000..ed8a41e --- /dev/null +++ b/modules/editors/nvf/runtime/after/queries/markdown/textobjects.scm @@ -0,0 +1,5 @@ +;extends + +(fenced_code_block (code_fence_content) @class.inner) @class.outer + +(paragraph) @function.outer @function.inner diff --git a/modules/editors/nvf/runtime/after/queries/markdown_inline/highlights.scm b/modules/editors/nvf/runtime/after/queries/markdown_inline/highlights.scm new file mode 100644 index 0000000..61a68fc --- /dev/null +++ b/modules/editors/nvf/runtime/after/queries/markdown_inline/highlights.scm @@ -0,0 +1,12 @@ +;extends + +[ + (shortcut_link) +] @nospell + +(strikethrough +(emphasis_delimiter) +(strikethrough + (emphasis_delimiter) + (emphasis_delimiter)) +(emphasis_delimiter))@markup.doublestrikethrough diff --git a/modules/editors/nvf/runtime/after/queries/mdx/injections.scm b/modules/editors/nvf/runtime/after/queries/mdx/injections.scm new file mode 100644 index 0000000..8ff63a6 --- /dev/null +++ b/modules/editors/nvf/runtime/after/queries/mdx/injections.scm @@ -0,0 +1,9 @@ +((jsx_section) + @injection.content + (#set! injection.language "tsx") + (#set! injection.include-children)) + +((markdown_section) + @injection.content + (#set! injection.language "markdown") + (#set! injection.combined)) diff --git a/modules/editors/nvf/runtime/after/queries/rust/injections.scm b/modules/editors/nvf/runtime/after/queries/rust/injections.scm new file mode 100644 index 0000000..dfa0c01 --- /dev/null +++ b/modules/editors/nvf/runtime/after/queries/rust/injections.scm @@ -0,0 +1,14 @@ +;extends +(macro_invocation +(scoped_identifier +path: (identifier) @path (#eq? @path "sqlx") +name: (identifier) @name (#match? @name "^query.*") +) + +(token_tree +(raw_string_literal) @injection.content +(#set! injection.language "sql") +(#set! injection.include-children) +) +(#offset! @injection.content 0 3 0 -2) +) diff --git a/modules/editors/nvf/runtime/after/queries/typst/highlights.scm b/modules/editors/nvf/runtime/after/queries/typst/highlights.scm new file mode 100644 index 0000000..0b0db2f --- /dev/null +++ b/modules/editors/nvf/runtime/after/queries/typst/highlights.scm @@ -0,0 +1,5 @@ +;; extends +((ident) @constant + (#eq? @constant "lambda") + (#set! conceal "λ") + ) diff --git a/modules/editors/nvf/runtime/spell/en.utf-8.add b/modules/editors/nvf/runtime/spell/en.utf-8.add new file mode 100644 index 0000000..883c9d7 --- /dev/null +++ b/modules/editors/nvf/runtime/spell/en.utf-8.add @@ -0,0 +1,42 @@ +contrib +Contrib +gitignore +dotfiles +nyx +notashelf +utils +neovim +glab +gh +ripgrep +wip +thoughtbot +kubectl +CoC +config +Capybara +mailserver +Mailserver +anyrun +ags +spicetify +Spicetify +firefox +Firefox +Hyprland +Hyprwm +Xorg +X11 +devShell +devshell +nixos +NixOS +nixpkgs +Nixpkgs +filetree +sourcetree +url +uri + + + diff --git a/modules/editors/nvf/runtime/spell/en.utf-8.add.spl b/modules/editors/nvf/runtime/spell/en.utf-8.add.spl new file mode 100644 index 0000000000000000000000000000000000000000..1e4ff27257067a615d73c3187999eb8ff7ff4003 GIT binary patch literal 478 zcmWIZ^erw(&B-zP&%nT_&!3o_l9ry4otsxwTvA$I!IYlISj@=4Sjkw#Sjx!Az#y8( zl$g(0z*xzc#F)rf#F)s)#Ke@G$H>&clvcu+309KMSj3pgn8d`u#Ke@E&sfG-%$UKL z%9z8L!^FVUz*xeV#+b>N15zrS%9zQNQ^c6cSi%S*K^CMkrZT26=7Xf2Dwshc8JRhZ zAhXjM^C04RAbUYFNsN_@1&l>ZIpvIrjCmj}dMRKsm$8&Fi7}NinXv@K7tLWz1lw86 zn95khSjLzN5_KwKNzKf!WCS@8;__U^3a0!5kX%SHV>V+th~-qwSi+bH_XEh-0VBw>VADhkKw3)~i$IcT$&8td$zXqFGJ=&mRWfEU<};QurZZ+RmM|tkd?H%H zR8+zQGBXoI