From 8faa242f21648e52a6bbdfa803fd4ea1b0e347e0 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 18 Dec 2023 01:28:42 -0500 Subject: port to nixvim --- config/default.nix | 32 ++++++++++++++ config/keymaps.nix | 82 ++++++++++++++++++++++++++++++++++ config/plugins/bufferline.nix | 19 ++++++++ config/plugins/cmp.nix | 31 +++++++++++++ config/plugins/default.nix | 12 +++++ config/plugins/efmls.nix | 100 ++++++++++++++++++++++++++++++++++++++++++ config/plugins/fidget.nix | 5 +++ config/plugins/flash.nix | 5 +++ config/plugins/gitsigns.nix | 5 +++ config/plugins/ibl.nix | 22 ++++++++++ config/plugins/lsp-format.nix | 5 +++ config/plugins/lsp.nix | 54 +++++++++++++++++++++++ config/plugins/lualine.nix | 8 ++++ config/plugins/mini.nix | 36 +++++++++++++++ config/plugins/neo-tree.nix | 11 +++++ config/plugins/treesitter.nix | 25 +++++++++++ config/plugins/trouble.nix | 5 +++ config/plugins/which-key.nix | 9 ++++ 18 files changed, 466 insertions(+) create mode 100644 config/default.nix create mode 100644 config/keymaps.nix create mode 100644 config/plugins/bufferline.nix create mode 100644 config/plugins/cmp.nix create mode 100644 config/plugins/default.nix create mode 100644 config/plugins/efmls.nix create mode 100644 config/plugins/fidget.nix create mode 100644 config/plugins/flash.nix create mode 100644 config/plugins/gitsigns.nix create mode 100644 config/plugins/ibl.nix create mode 100644 config/plugins/lsp-format.nix create mode 100644 config/plugins/lsp.nix create mode 100644 config/plugins/lualine.nix create mode 100644 config/plugins/mini.nix create mode 100644 config/plugins/neo-tree.nix create mode 100644 config/plugins/treesitter.nix create mode 100644 config/plugins/trouble.nix create mode 100644 config/plugins/which-key.nix (limited to 'config') diff --git a/config/default.nix b/config/default.nix new file mode 100644 index 0000000..79756d6 --- /dev/null +++ b/config/default.nix @@ -0,0 +1,32 @@ +{pkgs, ...}: { + imports = [ + ./plugins + ./keymaps.nix + ]; + + config = { + clipboard.providers.wl-copy.enable = pkgs.stdenv.isLinux; + + colorschemes.catppuccin = { + enable = true; + flavour = "mocha"; + + disableItalic = true; + }; + + enableMan = false; + + globals = { + mapleader = ","; + }; + + options = { + shiftwidth = 2; + tabstop = 2; + smartindent = true; + wrap = true; + syntax = "on"; + termguicolors = true; + }; + }; +} diff --git a/config/keymaps.nix b/config/keymaps.nix new file mode 100644 index 0000000..231da71 --- /dev/null +++ b/config/keymaps.nix @@ -0,0 +1,82 @@ +{lib, ...}: let + setBind = lib.recursiveUpdate { + mode = "n"; + lua = true; + options = { + noremap = true; + silent = true; + }; + }; +in { + keymaps = map setBind ( + [ + { + key = "t"; + action = '' + function() + require("neo-tree.command").execute({ + toggle = true, + dir = vim.loop.cwd() + }) + end + ''; + } + + { + mode = ["n" "o" "x"]; + key = "s"; + action = '' + function() + require("flash").jump() + end + ''; + } + + { + key = "q"; + action = '' + function() + vim.cmd("BufferLinePickClose") + end + ''; + } + + { + key = "f"; + action = '' + function() + vim.cmd("Telescope") + end + ''; + } + + { + key = "p"; + action = '' + function() + vim.cmd("TroubleToggle") + end + ''; + } + + { + key = "z"; + action = '' + function() + vim.cmd("FormatToggle") + end + ''; + } + ] + ++ ( + map (n: { + key = "${toString n}"; + action = '' + function() + vim.cmd("BufferLineGoToBuffer ${toString n}") + end + ''; + }) (lib.range 1 9) + ) + ); +} diff --git a/config/plugins/bufferline.nix b/config/plugins/bufferline.nix new file mode 100644 index 0000000..fe1cd17 --- /dev/null +++ b/config/plugins/bufferline.nix @@ -0,0 +1,19 @@ +{ + plugins.bufferline = { + enable = true; + + alwaysShowBufferline = false; + diagnostics = "nvim_lsp"; + mode = "buffers"; + numbers = "ordinal"; + separatorStyle = "slant"; + offsets = [ + { + filetype = "neo-tree"; + text = "neo-tree"; + highlight = "Directory"; + text_align = "left"; + } + ]; + }; +} diff --git a/config/plugins/cmp.nix b/config/plugins/cmp.nix new file mode 100644 index 0000000..85c9513 --- /dev/null +++ b/config/plugins/cmp.nix @@ -0,0 +1,31 @@ +{ + plugins = { + nvim-cmp = { + enable = true; + + completion = { + completeopt = "menu,menuone,noinsert"; + }; + + mapping = { + "" = "cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert })"; + "" = "cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert })"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true})"; + }; + + snippet.expand = "luasnip"; + + sources = map (name: {inherit name;}) [ + "nvim_lsp" + "luasnip" + "async_path" + "buffer" + ]; + }; + }; +} diff --git a/config/plugins/default.nix b/config/plugins/default.nix new file mode 100644 index 0000000..229942e --- /dev/null +++ b/config/plugins/default.nix @@ -0,0 +1,12 @@ +{ + # import all files besides those prefixed with `_` + imports = builtins.map (file: ./${file}) ( + builtins.filter ( + name: name != "default.nix" && (builtins.substring 0 1 name) != "_" + ) ( + builtins.attrNames ( + builtins.readDir ./. + ) + ) + ); +} diff --git a/config/plugins/efmls.nix b/config/plugins/efmls.nix new file mode 100644 index 0000000..b4740ac --- /dev/null +++ b/config/plugins/efmls.nix @@ -0,0 +1,100 @@ +{ + plugins = { + lsp.servers.efm.extraOptions = { + init_options.documentFormatting = true; + }; + + efmls-configs = { + enable = true; + + externallyManagedPackages = ["prettier_eslint"]; + + setup = { + all = { + linter = [ + "alex" + "codespell" + ]; + }; + + bash = { + formatter = "beautysh"; + linter = "shellcheck"; + }; + + css = { + formatter = "prettier_d"; + }; + + fish = { + formatter = "fish_indent"; + }; + + html = { + formatter = "prettier_d"; + }; + + javascript = { + formatter = "prettier_eslint"; + linter = "eslint_d"; + }; + + json = { + formatter = "prettier_d"; + }; + + lua = { + formatter = "stylua"; + }; + + nix = { + formatter = "alejandra"; + linter = "statix"; + }; + + python = { + formatter = [ + "ruff" + "isort" + ]; + + linter = [ + "mypy" + "pylint" + ]; + }; + + rust = { + formatter = "rustfmt"; + }; + + sass = { + formatter = "prettier_d"; + }; + + scss = { + formatter = "prettier_d"; + }; + + sh = { + formatter = ["beautysh" "shellharden"]; + linter = "shellcheck"; + }; + + typescript = { + formatter = "prettier_eslint"; + linter = "eslint_d"; + }; + + yaml = { + formatter = "prettier"; + linter = "actionlint"; + }; + + zsh = { + formatter = "beautysh"; + }; + }; + }; + }; +} diff --git a/config/plugins/fidget.nix b/config/plugins/fidget.nix new file mode 100644 index 0000000..5d0a033 --- /dev/null +++ b/config/plugins/fidget.nix @@ -0,0 +1,5 @@ +{ + plugins.fidget = { + enable = true; + }; +} diff --git a/config/plugins/flash.nix b/config/plugins/flash.nix new file mode 100644 index 0000000..87446e9 --- /dev/null +++ b/config/plugins/flash.nix @@ -0,0 +1,5 @@ +{ + plugins.flash = { + enable = true; + }; +} diff --git a/config/plugins/gitsigns.nix b/config/plugins/gitsigns.nix new file mode 100644 index 0000000..8ba3e72 --- /dev/null +++ b/config/plugins/gitsigns.nix @@ -0,0 +1,5 @@ +{ + plugins.gitsigns = { + enable = true; + }; +} diff --git a/config/plugins/ibl.nix b/config/plugins/ibl.nix new file mode 100644 index 0000000..d794a6a --- /dev/null +++ b/config/plugins/ibl.nix @@ -0,0 +1,22 @@ +{ + plugins.indent-blankline = { + enable = true; + + exclude.filetypes = [ + "help" + "neo-tree" + "Trouble" + "lazy" + "mason" + "notify" + "toggleterm" + ]; + + indent = { + char = "│"; + tabChar = "│"; + }; + + scope.enabled = false; + }; +} diff --git a/config/plugins/lsp-format.nix b/config/plugins/lsp-format.nix new file mode 100644 index 0000000..af2ab05 --- /dev/null +++ b/config/plugins/lsp-format.nix @@ -0,0 +1,5 @@ +{ + plugins.lsp-format = { + enable = true; + }; +} diff --git a/config/plugins/lsp.nix b/config/plugins/lsp.nix new file mode 100644 index 0000000..c2648db --- /dev/null +++ b/config/plugins/lsp.nix @@ -0,0 +1,54 @@ +{lib, ...}: { + plugins.lsp = { + enable = true; + + capabilities = '' + capabilities = vim.tbl_deep_extend( + "force", + require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), + { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } } + ) + ''; + + keymaps = { + diagnostic = { + "e" = "open_float"; + "[d" = "goto_prev"; + "]d" = "goto_next"; + "u" = "setloclist"; + }; + }; + + servers = let + withDefaultOpts = lib.genAttrs [ + "bashls" + "lua-ls" + "nil_ls" + ] (_: {enable = true;}); + + optionalOpts = { + enable = true; + installLanguageServer = false; + autostart = false; + }; + + optional = lib.genAttrs [ + "clangd" + "eslint" + "pyright" + "rust-analyzer" + "tsserver" + ] (_: optionalOpts); + in + withDefaultOpts + // optional + // { + rust-analyzer = + optionalOpts + // { + installRustc = false; + installCargo = false; + }; + }; + }; +} diff --git a/config/plugins/lualine.nix b/config/plugins/lualine.nix new file mode 100644 index 0000000..43e2128 --- /dev/null +++ b/config/plugins/lualine.nix @@ -0,0 +1,8 @@ +{ + plugins.lualine = { + enable = true; + + theme = "catppuccin"; + extensions = ["neo-tree" "trouble"]; + }; +} diff --git a/config/plugins/mini.nix b/config/plugins/mini.nix new file mode 100644 index 0000000..48bb0ed --- /dev/null +++ b/config/plugins/mini.nix @@ -0,0 +1,36 @@ +{ + plugins.mini = { + enable = true; + + modules = { + comment = {}; + pairs = {}; + indentscope = { + options.try_as_border = true; + }; + }; + }; + + autoCmd = [ + { + event = ["FileType"]; + pattern = [ + "help" + "neo-tree" + "Trouble" + "lazy" + "mason" + "notify" + "toggleterm" + ]; + + callback = { + __raw = '' + function() + vim.b.miniindentscope_disable = true + end + ''; + }; + } + ]; +} diff --git a/config/plugins/neo-tree.nix b/config/plugins/neo-tree.nix new file mode 100644 index 0000000..f99df9e --- /dev/null +++ b/config/plugins/neo-tree.nix @@ -0,0 +1,11 @@ +{ + plugins.neo-tree = { + enable = true; + + extraOptions = { + filetype_exclude = ["help" "neo-tree" "Trouble" "lazy" "mason" "notify" "toggleterm"]; + show_current_context = false; + show_trailing_blankline_indent = false; + }; + }; +} diff --git a/config/plugins/treesitter.nix b/config/plugins/treesitter.nix new file mode 100644 index 0000000..047bd17 --- /dev/null +++ b/config/plugins/treesitter.nix @@ -0,0 +1,25 @@ +{ + pkgs, + self, + ... +}: { + extraPlugins = [pkgs.vimPlugins.vim-just]; + + plugins = { + treesitter = { + enable = true; + + grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars ++ [self.tree-sitter-just]; + + indent = true; + nixvimInjections = true; + }; + + ts-context-commentstring = { + enable = true; + disableAutoInitialization = true; + }; + + ts-autotag.enable = true; + }; +} diff --git a/config/plugins/trouble.nix b/config/plugins/trouble.nix new file mode 100644 index 0000000..343c92f --- /dev/null +++ b/config/plugins/trouble.nix @@ -0,0 +1,5 @@ +{ + plugins.trouble = { + enable = true; + }; +} diff --git a/config/plugins/which-key.nix b/config/plugins/which-key.nix new file mode 100644 index 0000000..ef43fc4 --- /dev/null +++ b/config/plugins/which-key.nix @@ -0,0 +1,9 @@ +{ + plugins.which-key = { + enable = true; + + plugins = { + spelling.enabled = true; + }; + }; +} -- cgit v1.2.3