From 2f10454781687711627b9a3e81e94cde2c738fdf Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 26 Feb 2024 06:03:08 +0300 Subject: [PATCH] editors/neovim: post-refactor cleanup --- .../terminal/editors/neovim/.stylua.toml | 6 ++++ .../terminal/editors/neovim/default.nix | 34 +++++-------------- .../terminal/editors/neovim/lua/misc.lua | 2 ++ .../terminal/editors/neovim/plugins/extra.nix | 32 +++++++++++++++++ .../neovim/plugins/sources/default.nix | 21 +++++++++--- .../terminal/editors/neovim/wrapper.nix | 31 +++++++++++++++++ 6 files changed, 96 insertions(+), 30 deletions(-) create mode 100644 homes/notashelf/programs/terminal/editors/neovim/.stylua.toml create mode 100644 homes/notashelf/programs/terminal/editors/neovim/lua/misc.lua create mode 100644 homes/notashelf/programs/terminal/editors/neovim/wrapper.nix diff --git a/homes/notashelf/programs/terminal/editors/neovim/.stylua.toml b/homes/notashelf/programs/terminal/editors/neovim/.stylua.toml new file mode 100644 index 000000000..5e3c178cf --- /dev/null +++ b/homes/notashelf/programs/terminal/editors/neovim/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 100 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 4 +quote_style = "AutoPreferSingle" +call_parentheses = "Always" diff --git a/homes/notashelf/programs/terminal/editors/neovim/default.nix b/homes/notashelf/programs/terminal/editors/neovim/default.nix index 06fcb7344..6730dc0d6 100644 --- a/homes/notashelf/programs/terminal/editors/neovim/default.nix +++ b/homes/notashelf/programs/terminal/editors/neovim/default.nix @@ -25,9 +25,9 @@ in { # neovim-flake home-manager module [nvf.homeManagerModules.default] - # constructed modules - (mkModule {path = ./plugins;}) - (mkModule {path = ./mappings;}) + # construct this entire directory as a module + # which means all default.nix files will be imported automatically + (mkModule {path = ./.;}) ]; config = { @@ -79,36 +79,20 @@ in { }; luaConfigRC = { + # autocommands + "autocommands" = builtins.readFile ./lua/autocommands.lua; + # additional LSP handler configurations via vim.lsp.handlers "lsp-handler" = builtins.readFile ./lua/handlers.lua; + # configurations that don't belong anywhere else + "misc" = builtins.readFile ./lua/misc.lua; + # additional neovide configuration "neovide" = builtins.readFile ./lua/neovide.lua; }; }; }; }; - - xdg.desktopEntries."neovim" = lib.mkForce { - name = "Neovim"; - type = "Application"; - mimeType = ["text/plain"]; - - icon = builtins.fetchurl { - url = "https://raw.githubusercontent.com/NotAShelf/neovim-flake/main/assets/neovim-flake-logo-work.svg"; - sha256 = "19n7n9xafyak35pkn4cww0s5db2cr97yz78w5ppbcp9jvxw6yyz3"; - }; - - exec = let - wezterm = lib.getExe config.programs.wezterm.package; - direnv = lib.getExe pkgs.direnv; - in "${pkgs.writeShellScript "wezterm-neovim" '' - filename = "$(readlink -f "$1")" # define target filename - dirname = "$(dirname "$filename")" # get the directory target file is in - - # launch a wezterm instance with direnv and nvim - ${wezterm} start --cwd "$dirname" -- ${lib.getExe pkgs.zsh} -c "${direnv} exec . nvim '$filename'" - ''} %f"; - }; }; } diff --git a/homes/notashelf/programs/terminal/editors/neovim/lua/misc.lua b/homes/notashelf/programs/terminal/editors/neovim/lua/misc.lua new file mode 100644 index 000000000..f4ce84c88 --- /dev/null +++ b/homes/notashelf/programs/terminal/editors/neovim/lua/misc.lua @@ -0,0 +1,2 @@ +vim.cmd.aunmenu [[PopUp.How-to\ disable\ mouse]] +vim.cmd.aunmenu [[PopUp.-1-]] diff --git a/homes/notashelf/programs/terminal/editors/neovim/plugins/extra.nix b/homes/notashelf/programs/terminal/editors/neovim/plugins/extra.nix index 9e51af0f3..e19f35361 100644 --- a/homes/notashelf/programs/terminal/editors/neovim/plugins/extra.nix +++ b/homes/notashelf/programs/terminal/editors/neovim/plugins/extra.nix @@ -77,6 +77,38 @@ in { setup = "require('smart-splits').setup {}"; }; + neotab-nvim = { + package = pluginSources.neotab-nvim; + setup = '' + require('neotab').setup { + tabkey = "", + act_as_tab = true, + behavior = "nested", ---@type ntab.behavior + pairs = { ---@type ntab.pair[] + { open = "(", close = ")" }, + { open = "[", close = "]" }, + { open = "{", close = "}" }, + { open = "'", close = "'" }, + { open = '"', close = '"' }, + { open = "`", close = "`" }, + { open = "<", close = ">" }, + }, + exclude = {}, + smart_punctuators = { + enabled = false, + semicolon = { + enabled = false, + ft = { "cs", "c", "cpp", "java" }, + }, + escape = { + enabled = false, + triggers = {}, ---@type table + }, + }, + } + ''; + }; + specs-nvim = { package = pluginSources.specs-nvim; setup = '' diff --git a/homes/notashelf/programs/terminal/editors/neovim/plugins/sources/default.nix b/homes/notashelf/programs/terminal/editors/neovim/plugins/sources/default.nix index 3023ffc2a..026871132 100644 --- a/homes/notashelf/programs/terminal/editors/neovim/plugins/sources/default.nix +++ b/homes/notashelf/programs/terminal/editors/neovim/plugins/sources/default.nix @@ -4,6 +4,7 @@ ... }: let inherit (self) pins; + inherit (pkgs) fetchFromGitHub; inherit (pkgs.vimUtils) buildVimPlugin; sources = { @@ -24,7 +25,7 @@ regexplainer = buildVimPlugin { name = "nvim-regexplainer"; - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "bennypowers"; repo = "nvim-regexplainer"; rev = "4250c8f3c1307876384e70eeedde5149249e154f"; @@ -34,7 +35,7 @@ specs-nvim = buildVimPlugin { name = "specs.nvim"; - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "edluffy"; repo = "specs.nvim"; rev = "2743e412bbe21c9d73954c403d01e8de7377890d"; @@ -44,7 +45,7 @@ deferred-clipboard = buildVimPlugin { name = "deferred-clipboard"; - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "EtiamNullam"; repo = "deferred-clipboard.nvim"; rev = "810a29d166eaa41afc220cc7cd85eeaa3c43b37f"; @@ -54,7 +55,7 @@ data-viewer-nvim = buildVimPlugin { name = "data-viewer.nvim"; - src = pkgs.fetchFromGitHub { + src = fetchFromGitHub { owner = "VidocqH"; repo = "data-viewer.nvim"; rev = "40ddf37bb7ab6c04ff9e820812d1539afe691668"; @@ -64,13 +65,23 @@ vim-nftables = buildVimPlugin { name = "vim-nftables"; - src = pkgs.fetchFromGitHub { + 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/homes/notashelf/programs/terminal/editors/neovim/wrapper.nix b/homes/notashelf/programs/terminal/editors/neovim/wrapper.nix new file mode 100644 index 000000000..3964c96ab --- /dev/null +++ b/homes/notashelf/programs/terminal/editors/neovim/wrapper.nix @@ -0,0 +1,31 @@ +{ + config, + pkgs, + lib, + ... +}: { + xdg.desktopEntries."Neovim" = lib.mkForce { + name = "Neovim"; + type = "Application"; + mimeType = ["text/plain"]; + + icon = builtins.fetchurl { + url = "https://raw.githubusercontent.com/NotAShelf/neovim-flake/main/assets/neovim-flake-logo-work.svg"; + sha256 = "19n7n9xafyak35pkn4cww0s5db2cr97yz78w5ppbcp9jvxw6yyz3"; + }; + + exec = let + wezterm = lib.getExe config.programs.wezterm.package; + direnv = lib.getExe pkgs.direnv; + in "${pkgs.writeShellScript "wezterm-neovim" '' + # define target filename + filename="$(readlink -f "$1")" + + # get the directory target file is in + dirname="$(dirname "$filename")" + + # launch a wezterm instance with direnv and nvim + ${wezterm} -e --cwd "$dirname" -- ${lib.getExe pkgs.zsh} -c "${direnv} exec . nvim '$filename'" + ''} %f"; + }; +}