From 2e7e1ce219b43bb74f67875200dd4b68758ffd27 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 16 Jul 2024 19:04:27 -0400 Subject: back to nixvim again --- after/plugin/globals.lua | 4 -- after/plugin/keymaps.lua | 44 ------------- dev/checks.nix | 45 +++++++++++++ dev/default.nix | 12 ++++ dev/devShell.nix | 15 +++++ flake.lock | 53 ++++++++++++++- flake.nix | 128 ++++++++++--------------------------- ftdetect/githubaction.lua | 7 -- ftdetect/just.lua | 5 -- lua/getchoo/init.lua | 14 ---- neovim.nix | 116 --------------------------------- nixvim/default.nix | 50 +++++++++++++++ nixvim/filetypes/default.nix | 6 ++ nixvim/filetypes/github-action.nix | 8 +++ nixvim/filetypes/just.nix | 7 ++ nixvim/plugins/bufferline.nix | 35 ++++++++++ nixvim/plugins/cmp.nix | 47 ++++++++++++++ nixvim/plugins/crates.nix | 5 ++ nixvim/plugins/default.nix | 20 ++++++ nixvim/plugins/fidget.nix | 5 ++ nixvim/plugins/flash.nix | 29 +++++++++ nixvim/plugins/gitsigns.nix | 5 ++ nixvim/plugins/glow.nix | 5 ++ nixvim/plugins/ibl.nix | 23 +++++++ nixvim/plugins/lint.nix | 27 ++++++++ nixvim/plugins/lsp-format.nix | 17 +++++ nixvim/plugins/lsp/default.nix | 20 ++++++ nixvim/plugins/lsp/keymaps.nix | 16 +++++ nixvim/plugins/lsp/servers.nix | 82 ++++++++++++++++++++++++ nixvim/plugins/lualine.nix | 8 +++ nixvim/plugins/mini.nix | 60 +++++++++++++++++ nixvim/plugins/telescope.nix | 17 +++++ nixvim/plugins/treesitter.nix | 10 +++ nixvim/plugins/trouble.nix | 17 +++++ nvim.yaml | 5 -- plugin/bufferline.lua | 16 ----- plugin/catppuccin.lua | 33 ---------- plugin/cmp.lua | 47 -------------- plugin/crates.lua | 6 -- plugin/fidget.lua | 6 -- plugin/flash.lua | 6 -- plugin/gitsigns.lua | 6 -- plugin/glow.lua | 6 -- plugin/ibl.lua | 24 ------- plugin/lint.lua | 20 ------ plugin/lsp-format.lua | 6 -- plugin/lsp.lua | 127 ------------------------------------ plugin/lualine.lua | 11 ---- plugin/mini.lua | 29 --------- plugin/telescope.lua | 6 -- plugin/treesitter.lua | 11 ---- plugin/trouble.lua | 6 -- selene.toml | 1 - 53 files changed, 678 insertions(+), 656 deletions(-) delete mode 100644 after/plugin/globals.lua delete mode 100644 after/plugin/keymaps.lua create mode 100644 dev/checks.nix create mode 100644 dev/default.nix create mode 100644 dev/devShell.nix delete mode 100644 ftdetect/githubaction.lua delete mode 100644 ftdetect/just.lua delete mode 100644 lua/getchoo/init.lua delete mode 100644 neovim.nix create mode 100644 nixvim/default.nix create mode 100644 nixvim/filetypes/default.nix create mode 100644 nixvim/filetypes/github-action.nix create mode 100644 nixvim/filetypes/just.nix create mode 100644 nixvim/plugins/bufferline.nix create mode 100644 nixvim/plugins/cmp.nix create mode 100644 nixvim/plugins/crates.nix create mode 100644 nixvim/plugins/default.nix create mode 100644 nixvim/plugins/fidget.nix create mode 100644 nixvim/plugins/flash.nix create mode 100644 nixvim/plugins/gitsigns.nix create mode 100644 nixvim/plugins/glow.nix create mode 100644 nixvim/plugins/ibl.nix create mode 100644 nixvim/plugins/lint.nix create mode 100644 nixvim/plugins/lsp-format.nix create mode 100644 nixvim/plugins/lsp/default.nix create mode 100644 nixvim/plugins/lsp/keymaps.nix create mode 100644 nixvim/plugins/lsp/servers.nix create mode 100644 nixvim/plugins/lualine.nix create mode 100644 nixvim/plugins/mini.nix create mode 100644 nixvim/plugins/telescope.nix create mode 100644 nixvim/plugins/treesitter.nix create mode 100644 nixvim/plugins/trouble.nix delete mode 100644 nvim.yaml delete mode 100644 plugin/bufferline.lua delete mode 100644 plugin/catppuccin.lua delete mode 100644 plugin/cmp.lua delete mode 100644 plugin/crates.lua delete mode 100644 plugin/fidget.lua delete mode 100644 plugin/flash.lua delete mode 100644 plugin/gitsigns.lua delete mode 100644 plugin/glow.lua delete mode 100644 plugin/ibl.lua delete mode 100644 plugin/lint.lua delete mode 100644 plugin/lsp-format.lua delete mode 100644 plugin/lsp.lua delete mode 100644 plugin/lualine.lua delete mode 100644 plugin/mini.lua delete mode 100644 plugin/telescope.lua delete mode 100644 plugin/treesitter.lua delete mode 100644 plugin/trouble.lua delete mode 100644 selene.toml diff --git a/after/plugin/globals.lua b/after/plugin/globals.lua deleted file mode 100644 index 5da584b..0000000 --- a/after/plugin/globals.lua +++ /dev/null @@ -1,4 +0,0 @@ -vim.g.mapleader = "," -vim.g.do_filetype_lua = { - "ts=typescript", -} diff --git a/after/plugin/keymaps.lua b/after/plugin/keymaps.lua deleted file mode 100644 index 9ff505a..0000000 --- a/after/plugin/keymaps.lua +++ /dev/null @@ -1,44 +0,0 @@ -local opts = { noremap = true, silent = true } -local set = function(mode, key, vimcmd) - vim.keymap.set(mode, key, vimcmd, opts) -end - -set("n", "t", function() - local files = require("mini.files") - if not files.close() then - files.open() - end -end) - -set({ "n", "o", "x" }, "s", function() - require("flash").jump() -end) - -for i = 1, 9 do - set("n", "" .. i, function() - vim.cmd("BufferLineGoToBuffer " .. i) - end) -end - -set("n", "q", function() - vim.cmd("BufferLinePickClose") -end) - -local diagnostic = vim.diagnostic -set("n", "e", diagnostic.open_float) -set("n", "[d", diagnostic.goto_prev) -set("n", "]d", diagnostic.goto_next) -set("n", "u", diagnostic.setloclist) -set("n", "ca", vim.lsp.buf.code_action) - -set("n", "f", function() - vim.cmd("Telescope") -end) - -set("n", "p", function() - vim.cmd("Trouble diagnostics toggle") -end) - -set("n", "z", function() - vim.cmd("FormatToggle") -end) diff --git a/dev/checks.nix b/dev/checks.nix new file mode 100644 index 0000000..533c2a0 --- /dev/null +++ b/dev/checks.nix @@ -0,0 +1,45 @@ +{ + perSystem = + { lib, pkgs, ... }: + let + root = lib.fileset.toSource { + root = ../.; + fileset = lib.fileset.unions [ + ./. + ../.github + ../nixvim + ../flake.nix + ]; + }; + in + { + checks = { + format-and-lint = + pkgs.runCommand "format-and-lint" + { + src = root; + nativeBuildInputs = [ + pkgs.actionlint + pkgs.deadnix + pkgs.nixfmt-rfc-style + pkgs.statix + ]; + } + '' + echo "running actionlint..." + actionlint ./.github/workflows/* + + echo "running deadnix..." + deadnix + + echo "running nixfmt..." + nixfmt --check . + + echo "running statix..." + statix check . + + touch $out + ''; + }; + }; +} diff --git a/dev/default.nix b/dev/default.nix new file mode 100644 index 0000000..eff9cc3 --- /dev/null +++ b/dev/default.nix @@ -0,0 +1,12 @@ +{ + imports = [ + ./checks.nix + ./devShell.nix + ]; + + perSystem = + { pkgs, ... }: + { + formatter = pkgs.nixfmt-rfc-style; + }; +} diff --git a/dev/devShell.nix b/dev/devShell.nix new file mode 100644 index 0000000..7792817 --- /dev/null +++ b/dev/devShell.nix @@ -0,0 +1,15 @@ +{ + perSystem = + { pkgs, self', ... }: + { + devShells.default = pkgs.mkShellNoCC { + packages = [ + pkgs.actionlint + + self'.formatter + pkgs.nil + pkgs.statix + ]; + }; + }; +} diff --git a/flake.lock b/flake.lock index bc9406e..9e4d47f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1720750130, @@ -16,9 +36,40 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "devshell": [], + "flake-compat": [], + "flake-parts": [ + "flake-parts" + ], + "git-hooks": [], + "home-manager": [], + "nix-darwin": [], + "nixpkgs": [ + "nixpkgs" + ], + "treefmt-nix": [] + }, + "locked": { + "lastModified": 1721042250, + "narHash": "sha256-CEOGzI9WFGezwJ3lok0F//1UEq5crzE2kZDLQK2EtfE=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "b9ed90003273f0a75151b32948e16b44891f403c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, "root": { "inputs": { - "nixpkgs": "nixpkgs" + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" } } }, diff --git a/flake.nix b/flake.nix index dbde118..e7c5ee6 100644 --- a/flake.nix +++ b/flake.nix @@ -3,12 +3,32 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + + nixvim = { + url = "github:nix-community/nixvim"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-parts.follows = "flake-parts"; + + devshell.follows = ""; + flake-compat.follows = ""; + git-hooks.follows = ""; + home-manager.follows = ""; + nix-darwin.follows = ""; + treefmt-nix.follows = ""; + }; + }; }; outputs = - { self, nixpkgs }: - let - inherit (nixpkgs) lib; + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ ./dev ]; systems = [ "x86_64-linux" @@ -17,101 +37,23 @@ "aarch64-darwin" ]; - forAllSystems = lib.genAttrs systems; - nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); - in - { - checks = forAllSystems ( - system: - let - pkgs = nixpkgsFor.${system}; - fs = lib.fileset; - - root = fs.toSource { - root = ./.; - fileset = fs.unions [ - # ci workflows - ./.github - - # lua configuration - ./after - ./ftdetect - ./lua - ./plugin - ./selene.toml - ./nvim.yaml - - # nix - ./flake.nix - ./neovim.nix - ]; - }; - in + perSystem = { - check-format-and-lint = - pkgs.runCommand "check-format-and-lint" - { - nativeBuildInputs = [ - pkgs.actionlint - pkgs.nixfmt-rfc-style - pkgs.selene - pkgs.statix - ]; - } - '' - cd ${root} - - echo "running actionlint..." - actionlint ./.github/workflows/* - - echo "running nixfmt..." - nixfmt --check . - - echo "running selene...." - selene **/*.lua - - echo "running statix..." - statix check . - - touch $out - ''; - - } - ); - - devShells = forAllSystems ( - system: - let - pkgs = nixpkgsFor.${system}; - in + pkgs, + inputs', + self', + ... + }: { - default = pkgs.mkShellNoCC { - packages = [ - pkgs.actionlint - - # lua - pkgs.lua-language-server - pkgs.selene - pkgs.stylua + packages = { + getchvim = inputs'.nixvim.legacyPackages.makeNixvimWithModule { + inherit pkgs; + module = import ./nixvim; + }; - # nix - self.formatter.${system} - pkgs.deadnix - pkgs.nil - pkgs.statix - ]; + default = self'.packages.getchvim; }; - } - ); - - formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); - - packages = forAllSystems (system: { - getchvim = nixpkgsFor.${system}.callPackage ./neovim.nix { - version = self.shortRev or self.dirtyShortRev or "unknown"; }; - default = self.packages.${system}.getchvim; - }); }; } diff --git a/ftdetect/githubaction.lua b/ftdetect/githubaction.lua deleted file mode 100644 index a6e11cf..0000000 --- a/ftdetect/githubaction.lua +++ /dev/null @@ -1,7 +0,0 @@ --- this allows `actionlint` to only yaml files that are actions -vim.filetype.add({ - pattern = { - [".*/.github/workflows/.*%.yml"] = "yaml.githubaction", - [".*/.github/workflows/.*%.yaml"] = "yaml.githubaction", - }, -}) diff --git a/ftdetect/just.lua b/ftdetect/just.lua deleted file mode 100644 index 4c7098a..0000000 --- a/ftdetect/just.lua +++ /dev/null @@ -1,5 +0,0 @@ -vim.filetype.add({ - filename = { - ["justfile"] = "just", - }, -}) diff --git a/lua/getchoo/init.lua b/lua/getchoo/init.lua deleted file mode 100644 index ca4fc6b..0000000 --- a/lua/getchoo/init.lua +++ /dev/null @@ -1,14 +0,0 @@ -local g = vim.g -local opt = vim.opt - -g.mapleader = "," - -opt.shiftwidth = 2 - --- line stuff -opt.number = true -opt.wrap = true - --- ui -opt.mouse = "a" -opt.showmode = false -- status line does this diff --git a/neovim.nix b/neovim.nix deleted file mode 100644 index 41e639a..0000000 --- a/neovim.nix +++ /dev/null @@ -1,116 +0,0 @@ -{ - lib, - neovimUtils, - vimUtils, - vimPlugins, - wrapNeovimUnstable, - neovim-unwrapped, - actionlint, - glow, - ripgrep, - nil, - nixfmt-rfc-style, - nodePackages, - shellcheck, - shfmt, - statix, - typos-lsp, - version, -}: -let - fs = lib.fileset; - vimPlugins-getchoo-nvim = vimUtils.buildVimPlugin { - pname = "getchoo-neovim-config"; - inherit version; - - src = fs.toSource { - root = ./.; - fileset = fs.intersection (fs.gitTracked ./.) ( - fs.unions [ - ./after - ./ftdetect - ./lua - ./plugin - ] - ); - }; - }; - - plugins = with vimPlugins; [ - vimPlugins-getchoo-nvim - - # coding - nvim-cmp - luasnip - cmp-async-path - cmp-buffer - cmp_luasnip - cmp-nvim-lsp - cmp-rg - - crates-nvim - gitsigns-nvim - nvim-lint - - # editing - flash-nvim - glow-nvim - mini-nvim - - telescope-nvim # dependent on > - plenary-nvim - - nvim-treesitter.withAllGrammars - - # ui - bufferline-nvim # dependent on > - nvim-web-devicons - - catppuccin-nvim - indent-blankline-nvim - lualine-nvim - - # lsp - fidget-nvim - nvim-lspconfig - lsp-format-nvim - trouble-nvim - ]; - - extraPackages = [ - glow # glow.nvim - - ripgrep # cmp - - # lsp - nodePackages.bash-language-server - shellcheck - shfmt - - nil - nixfmt-rfc-style - - typos-lsp - - ## linters - nodePackages.alex - actionlint - statix - ]; - - baseConfig = neovimUtils.makeNeovimConfig { - withRuby = false; - inherit plugins; - }; - - config = baseConfig // { - luaRcContent = "require('getchoo')"; - wrapperArgs = baseConfig.wrapperArgs ++ [ - "--suffix" - "PATH" - ":" - "${lib.makeBinPath extraPackages}" - ]; - }; -in -wrapNeovimUnstable neovim-unwrapped config diff --git a/nixvim/default.nix b/nixvim/default.nix new file mode 100644 index 0000000..c1c275c --- /dev/null +++ b/nixvim/default.nix @@ -0,0 +1,50 @@ +{ + imports = [ + ./filetypes + ./plugins + ]; + + colorschemes.catppuccin = { + enable = true; + + settings = { + flavour = "mocha"; + + integrations = { + cmp = true; + flash = true; + gitsigns = true; + indent_blankline = { + enabled = true; + }; + lsp_trouble = true; + native_lsp = { + enabled = true; + }; + neotree = true; + treesitter = true; + telescope = true; + which_key = true; + }; + + no_italic = true; + }; + }; + + globals = { + mapleader = " "; + }; + + opts = { + shiftwidth = 2; + tabstop = 2; + + # line stuff + number = true; + wrap = true; + + # ui + mouse = "a"; + showmode = false; # status line does this + }; +} diff --git a/nixvim/filetypes/default.nix b/nixvim/filetypes/default.nix new file mode 100644 index 0000000..8bcb94e --- /dev/null +++ b/nixvim/filetypes/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./github-action.nix + ./just.nix + ]; +} diff --git a/nixvim/filetypes/github-action.nix b/nixvim/filetypes/github-action.nix new file mode 100644 index 0000000..c057de0 --- /dev/null +++ b/nixvim/filetypes/github-action.nix @@ -0,0 +1,8 @@ +{ + # yes this is very silly + # but it makes sure actionlint won't lint *every* yaml file + filetype.pattern = { + ".*/.github/workflows/.*%.yml" = "yaml.githubaction"; + ".*/.github/workflows/.*%.yaml" = "yaml.githubaction"; + }; +} diff --git a/nixvim/filetypes/just.nix b/nixvim/filetypes/just.nix new file mode 100644 index 0000000..3bc4161 --- /dev/null +++ b/nixvim/filetypes/just.nix @@ -0,0 +1,7 @@ +{ + # there's treesitter grammar for this + # but no upstram filetype :( + filetype.filename = { + justfile = "just"; + }; +} diff --git a/nixvim/plugins/bufferline.nix b/nixvim/plugins/bufferline.nix new file mode 100644 index 0000000..85dc127 --- /dev/null +++ b/nixvim/plugins/bufferline.nix @@ -0,0 +1,35 @@ +{ lib, ... }: +let + applyDefaultOpts = map ( + lib.recursiveUpdate { + mode = "n"; + options = { + noremap = true; + silent = true; + }; + } + ); +in +{ + keymaps = + applyDefaultOpts [ + { + action = "BufferLinePickClose"; + key = "q"; + } + ] + ++ map (i: { + action = "BufferLineGoToBuffer ${toString i}"; + key = "${toString i}"; + }) (lib.range 1 9); + + plugins.bufferline = { + enable = true; + + alwaysShowBufferline = false; + diagnostics = "nvim_lsp"; + mode = "buffers"; + numbers = "ordinal"; + separatorStyle = "slant"; + }; +} diff --git a/nixvim/plugins/cmp.nix b/nixvim/plugins/cmp.nix new file mode 100644 index 0000000..6793435 --- /dev/null +++ b/nixvim/plugins/cmp.nix @@ -0,0 +1,47 @@ +{ helpers, ... }: +{ + plugins.cmp = { + enable = true; + + settings = { + completion.completeopt = "menu,menuone,insert"; + + snippet.expand = '' + function(args) + require('luasnip').lsp_expand(args.body) + end + ''; + + 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()"; + "" = helpers.mkRaw '' + cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + else + fallback() + end + end, + + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }) + ''; + }; + + sources = map (name: { inherit name; }) [ + "nvim_lsp" + "luasnip" + "async_path" + "buffer" + "rg" + ]; + }; + }; +} diff --git a/nixvim/plugins/crates.nix b/nixvim/plugins/crates.nix new file mode 100644 index 0000000..fd8cda0 --- /dev/null +++ b/nixvim/plugins/crates.nix @@ -0,0 +1,5 @@ +{ + plugins.crates-nvim = { + enable = true; + }; +} diff --git a/nixvim/plugins/default.nix b/nixvim/plugins/default.nix new file mode 100644 index 0000000..bfbc12c --- /dev/null +++ b/nixvim/plugins/default.nix @@ -0,0 +1,20 @@ +{ + imports = [ + ./bufferline.nix + ./cmp.nix + ./crates.nix + ./fidget.nix + ./flash.nix + ./gitsigns.nix + ./glow.nix + ./ibl.nix + ./lint.nix + ./lsp + ./lsp-format.nix + ./lualine.nix + ./mini.nix + ./telescope.nix + ./treesitter.nix + ./trouble.nix + ]; +} diff --git a/nixvim/plugins/fidget.nix b/nixvim/plugins/fidget.nix new file mode 100644 index 0000000..5d0a033 --- /dev/null +++ b/nixvim/plugins/fidget.nix @@ -0,0 +1,5 @@ +{ + plugins.fidget = { + enable = true; + }; +} diff --git a/nixvim/plugins/flash.nix b/nixvim/plugins/flash.nix new file mode 100644 index 0000000..00f6c05 --- /dev/null +++ b/nixvim/plugins/flash.nix @@ -0,0 +1,29 @@ +{ helpers, ... }: +{ + keymaps = [ + { + action = helpers.mkRaw '' + function() + require("flash").jump() + end + ''; + + key = "s"; + + options = { + noremap = true; + silent = true; + }; + + mode = [ + "n" + "o" + "x" + ]; + } + ]; + + plugins.flash = { + enable = true; + }; +} diff --git a/nixvim/plugins/gitsigns.nix b/nixvim/plugins/gitsigns.nix new file mode 100644 index 0000000..8ba3e72 --- /dev/null +++ b/nixvim/plugins/gitsigns.nix @@ -0,0 +1,5 @@ +{ + plugins.gitsigns = { + enable = true; + }; +} diff --git a/nixvim/plugins/glow.nix b/nixvim/plugins/glow.nix new file mode 100644 index 0000000..de95ddf --- /dev/null +++ b/nixvim/plugins/glow.nix @@ -0,0 +1,5 @@ +{ + plugins.glow = { + enable = true; + }; +} diff --git a/nixvim/plugins/ibl.nix b/nixvim/plugins/ibl.nix new file mode 100644 index 0000000..235b04f --- /dev/null +++ b/nixvim/plugins/ibl.nix @@ -0,0 +1,23 @@ +{ + plugins.indent-blankline = { + enable = true; + + settings = { + exclude = { + filetypes = [ + "help" + "Trouble" + "toggleterm" + ]; + }; + + indent = { + char = "│"; + tab_char = "│"; + }; + + # Let mini.nvim handle this + scope.enabled = false; + }; + }; +} diff --git a/nixvim/plugins/lint.nix b/nixvim/plugins/lint.nix new file mode 100644 index 0000000..ca751fb --- /dev/null +++ b/nixvim/plugins/lint.nix @@ -0,0 +1,27 @@ +{ pkgs, helpers, ... }: +{ + extraPackages = [ + pkgs.actionlint + pkgs.nodePackages.alex + pkgs.statix + ]; + + plugins.lint = { + enable = true; + + # Run linters declared in lintersByFt + # then alex on all files + autoCmd.callback = helpers.mkRaw '' + function() + require("lint").try_lint() + require("lint").try_lint("alex") + end + ''; + + lintersByFt = { + githubaction = [ "actionlint" ]; + lua = [ "selene" ]; + nix = [ "statix" ]; + }; + }; +} diff --git a/nixvim/plugins/lsp-format.nix b/nixvim/plugins/lsp-format.nix new file mode 100644 index 0000000..ac64463 --- /dev/null +++ b/nixvim/plugins/lsp-format.nix @@ -0,0 +1,17 @@ +{ + keymaps = [ + { + action = "FormatToggle"; + key = "z"; + mode = "n"; + options = { + noremap = true; + silent = true; + }; + } + ]; + + plugins.lsp-format = { + enable = true; + }; +} diff --git a/nixvim/plugins/lsp/default.nix b/nixvim/plugins/lsp/default.nix new file mode 100644 index 0000000..3d5de1b --- /dev/null +++ b/nixvim/plugins/lsp/default.nix @@ -0,0 +1,20 @@ +{ + imports = [ + ./keymaps.nix + ./servers.nix + ]; + + plugins.lsp = { + enable = true; + + capabilities = '' + capabilities = vim.tbl_deep_extend( + "force", + vim.lsp.protocol.make_client_capabilities(), + require("cmp_nvim_lsp").default_capabilities(), + -- for nil_ls + { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } } + ) + ''; + }; +} diff --git a/nixvim/plugins/lsp/keymaps.nix b/nixvim/plugins/lsp/keymaps.nix new file mode 100644 index 0000000..ee67ab8 --- /dev/null +++ b/nixvim/plugins/lsp/keymaps.nix @@ -0,0 +1,16 @@ +{ + plugins.lsp.keymaps = { + silent = true; + + diagnostic = { + "e" = "open_float"; + "[d" = "goto_prev"; + "]d" = "goto_next"; + "u" = "setloclist"; + }; + + lspBuf = { + "ca" = "code_action"; + }; + }; +} diff --git a/nixvim/plugins/lsp/servers.nix b/nixvim/plugins/lsp/servers.nix new file mode 100644 index 0000000..6334939 --- /dev/null +++ b/nixvim/plugins/lsp/servers.nix @@ -0,0 +1,82 @@ +{ pkgs, helpers, ... }: +{ + extraPackages = [ + # bashls + pkgs.shellcheck + pkgs.shfmt + + # nil-ls + pkgs.nixfmt-rfc-style + ]; + + globals = { + # Required for Deno's LSP + markdown_fenced_languages = [ "ts=typescript" ]; + }; + + plugins.lsp.servers = { + astro.enable = true; + bashls.enable = true; + biome.enable = true; + clangd.enable = true; + denols.enable = true; + eslint.enable = true; + + lua-ls = { + enable = true; + settings = { + diagnostics.globals = [ "vim" ]; + runtime.version = "LuaJIT"; + workspace = { + checkThirdParty = false; + library = [ (helpers.mkRaw "vim.env.VIMRUNTIME") ]; + }; + }; + }; + + nil-ls = { + enable = true; + + settings = { + formatting.command = [ "nixfmt" ]; + }; + }; + + nimls.enable = true; + pyright = { + enable = true; + + settings = { + # Use ruff for imports + pyright = { + disableOrganizeImports = true; + }; + python.ignore = [ "*" ]; + }; + }; + + ruff-lsp = { + enable = true; + + # pyright should handle this + onAttach.function = '' + client.server_capabilities.hoverProvider = false + ''; + }; + + rust-analyzer = { + enable = true; + + installCargo = false; + installRustc = false; + + settings = { + check.command = "clippy"; + }; + }; + + tsserver.enable = true; + typos-lsp.enable = true; + typst-lsp.enable = true; + }; +} diff --git a/nixvim/plugins/lualine.nix b/nixvim/plugins/lualine.nix new file mode 100644 index 0000000..990e495 --- /dev/null +++ b/nixvim/plugins/lualine.nix @@ -0,0 +1,8 @@ +{ + plugins.lualine = { + enable = true; + + theme = "catppuccin"; + extensions = [ "trouble" ]; + }; +} diff --git a/nixvim/plugins/mini.nix b/nixvim/plugins/mini.nix new file mode 100644 index 0000000..0a83bcf --- /dev/null +++ b/nixvim/plugins/mini.nix @@ -0,0 +1,60 @@ +{ helpers, ... }: +{ + autoCmd = [ + # don't use mini.indentscope on some files + { + callback = helpers.mkRaw '' + function() + vim.b.miniindentscope_disable = true + end + ''; + event = "FileType"; + pattern = [ + "help" + "Trouble" + "toggleterm" + ]; + } + ]; + + keymaps = [ + # open mini.files + { + action = helpers.mkRaw '' + function() + local files = require("mini.files") + if not files.close() then + files.open() + end + end + ''; + + key = "t"; + mode = "n"; + options = { + noremap = true; + silent = true; + }; + } + ]; + + plugins.mini = { + enable = true; + + modules = { + files = { }; + + hipatterns = { + highlighters = { + hex_color = helpers.mkRaw "require('mini.hipatterns').gen_highlighter.hex_color()"; + }; + }; + + indentscope = { + options.try_as_border = false; + }; + + pairs = { }; + }; + }; +} diff --git a/nixvim/plugins/telescope.nix b/nixvim/plugins/telescope.nix new file mode 100644 index 0000000..32528af --- /dev/null +++ b/nixvim/plugins/telescope.nix @@ -0,0 +1,17 @@ +{ + keymaps = [ + { + action = "Telescope"; + key = "f"; + mode = "n"; + options = { + noremap = true; + silent = true; + }; + } + ]; + + plugins.telescope = { + enable = true; + }; +} diff --git a/nixvim/plugins/treesitter.nix b/nixvim/plugins/treesitter.nix new file mode 100644 index 0000000..ec2316a --- /dev/null +++ b/nixvim/plugins/treesitter.nix @@ -0,0 +1,10 @@ +{ + plugins.treesitter = { + enable = true; + + settings = { + highlight.enable = true; + indent.enable = true; + }; + }; +} diff --git a/nixvim/plugins/trouble.nix b/nixvim/plugins/trouble.nix new file mode 100644 index 0000000..a971991 --- /dev/null +++ b/nixvim/plugins/trouble.nix @@ -0,0 +1,17 @@ +{ + keymaps = [ + { + action = "Trouble diagnostics toggle"; + key = "p"; + mode = "n"; + options = { + noremap = true; + silent = true; + }; + } + ]; + + plugins.trouble = { + enable = true; + }; +} diff --git a/nvim.yaml b/nvim.yaml deleted file mode 100644 index 7465c62..0000000 --- a/nvim.yaml +++ /dev/null @@ -1,5 +0,0 @@ -base: lua52 - -globals: - vim: - any: true diff --git a/plugin/bufferline.lua b/plugin/bufferline.lua deleted file mode 100644 index b03ddff..0000000 --- a/plugin/bufferline.lua +++ /dev/null @@ -1,16 +0,0 @@ -if vim.g.did_load_bufferline_plugin then - return -end -vim.g.did_load_bufferline_plugin = true - -require("bufferline").setup({ - options = { - always_show_bufferline = false, - - diagnostics = "nvim_lsp", - - mode = "buffers", - numbers = "ordinal", - separator_style = "slant", - }, -}) diff --git a/plugin/catppuccin.lua b/plugin/catppuccin.lua deleted file mode 100644 index 79b84ec..0000000 --- a/plugin/catppuccin.lua +++ /dev/null @@ -1,33 +0,0 @@ -if vim.g.did_load_catppuccin_plugin then - return -end -vim.g.did_load_catppuccin_plugin = true - -local compile_path = vim.fn.stdpath("cache") .. "/catppuccin-nvim" -vim.fn.mkdir(compile_path, "p") -vim.opt.runtimepath:append(compile_path) - -require("catppuccin").setup({ - compile_path = compile_path, - flavour = "mocha", - integrations = { - cmp = true, - flash = true, - gitsigns = true, - indent_blankline = { - enabled = true, - }, - lsp_trouble = true, - native_lsp = { - enabled = true, - }, - neotree = true, - treesitter = true, - telescope = true, - which_key = true, - }, - - no_italic = true, -}) - -vim.cmd.colorscheme("catppuccin") diff --git a/plugin/cmp.lua b/plugin/cmp.lua deleted file mode 100644 index 10c750f..0000000 --- a/plugin/cmp.lua +++ /dev/null @@ -1,47 +0,0 @@ -if vim.g.did_load_cmp_plugin then - return -end -vim.g.did_load_cmp_plugin = true - -local cmp = require("cmp") - -cmp.setup({ - completion = { - compleopt = "menu,menuone,insert", - }, - - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - - 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({ - i = function(fallback) - if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) - else - fallback() - end - end, - - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), - }), - }, - - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "async_path" }, - { name = "buffer" }, - { name = "rg" }, - }), -}) diff --git a/plugin/crates.lua b/plugin/crates.lua deleted file mode 100644 index a954320..0000000 --- a/plugin/crates.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_crates_plugin then - return -end -vim.g.did_load_crates_plugin = true - -require("crates").setup() diff --git a/plugin/fidget.lua b/plugin/fidget.lua deleted file mode 100644 index 59fbb0c..0000000 --- a/plugin/fidget.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_fidget_plugin then - return -end -vim.g.did_load_fidget_plugin = true - -require("fidget").setup() diff --git a/plugin/flash.lua b/plugin/flash.lua deleted file mode 100644 index f3e1c15..0000000 --- a/plugin/flash.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_flash_plugin then - return -end -vim.g.did_load_flash_plugin = true - -require("flash").setup() diff --git a/plugin/gitsigns.lua b/plugin/gitsigns.lua deleted file mode 100644 index 7f6f457..0000000 --- a/plugin/gitsigns.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_gitsigns_plugin then - return -end -vim.g.did_load_gitsigns_plugin = true - -require("gitsigns").setup() diff --git a/plugin/glow.lua b/plugin/glow.lua deleted file mode 100644 index 4e7f2d9..0000000 --- a/plugin/glow.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_glow_plugin then - return -end -vim.g.did_load_glow_plugin = true - -require("glow").setup() diff --git a/plugin/ibl.lua b/plugin/ibl.lua deleted file mode 100644 index 0d42c04..0000000 --- a/plugin/ibl.lua +++ /dev/null @@ -1,24 +0,0 @@ -if vim.g.did_load_ibl_plugin then - return -end -vim.g.did_load_ibl_plugin = true - -require("ibl").setup({ - exclude = { - filetypes = { - "help", - "Trouble", - "toggleterm", - }, - }, - - indent = { - char = "│", - tab_char = "│", - }, - - scope = { - -- Let mini.nvim handle this - enabled = false, - }, -}) diff --git a/plugin/lint.lua b/plugin/lint.lua deleted file mode 100644 index b7dba21..0000000 --- a/plugin/lint.lua +++ /dev/null @@ -1,20 +0,0 @@ -if vim.g.did_load_lint_plugin then - return -end -vim.g.did_load_lint_plugin = true - -require("lint").linters_by_ft = { - githubaction = { "actionlint" }, - lua = { "selene" }, - nix = { "statix" }, -} - -vim.api.nvim_create_autocmd({ "BufWritePost" }, { - callback = function() - -- Run linters declared in linters_by_ft - require("lint").try_lint() - - -- Run these linters regardless of filetype - require("lint").try_lint("alex") - end, -}) diff --git a/plugin/lsp-format.lua b/plugin/lsp-format.lua deleted file mode 100644 index e21bdfd..0000000 --- a/plugin/lsp-format.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_lsp_format_plugin then - return -end -vim.g.did_load_lsp_format_plugin = true - -require("lsp-format").setup() diff --git a/plugin/lsp.lua b/plugin/lsp.lua deleted file mode 100644 index ef1a90b..0000000 --- a/plugin/lsp.lua +++ /dev/null @@ -1,127 +0,0 @@ -if vim.g.did_load_lsp_plugin then - return -end -vim.g.did_load_lsp_plugin = true - -local lsp_servers = { - astro = { - binary = "astro-ls", - }, - - bashls = { - binary = "bash-language-server", - }, - - biome = {}, - - clangd = {}, - - denols = { - binary = "deno", - }, - - dprint = {}, - - eslint = { - binary = "vscode-eslint-language-server", - }, - - -- TODO: I WANT STYLUA BACK!! - lua_ls = { - binary = "lua-language-server", - extraOptions = { - settings = { - Lua = { - runtime = { version = "LuaJIT" }, - diagnostics = { globals = "vim" }, - workspace = { checkThirdPaty = false, library = { vim.env.VIMRUNTIME } }, - }, - }, - }, - }, - - nil_ls = { - binary = "nil", - extraOptions = { - settings = { - ["nil"] = { - formatting = { command = { "nixfmt" } }, - }, - }, - }, - }, - - nim_langserver = { - binary = "nimlangserver", - }, - - pyright = { - extraOptions = { - settings = { - -- ruff is used instead - pyright = { disableOrganizeImports = true }, - python = { ignore = { "*" } }, - }, - }, - }, - - ruff_lsp = { - binary = "ruff-lsp", - extraOptions = { - on_attach = function(client, _) - require("lsp-format").on_attach(client) - -- pyright should handle this - client.server_capabilities.hoverProvider = false - end, - }, - }, - - rust_analyzer = { - binary = "rust-analyzer", - extraOptions = { - settings = { - ["rust-analyzer"] = { - check = { command = "clippy" }, - }, - }, - }, - }, - - tsserver = { - binary = "typescript-language-server", - }, - - typos_lsp = { - binary = "typos-lsp", - }, - - typst_lsp = { - binary = "typst-lsp", - }, -} - -local caps = vim.tbl_deep_extend( - "force", - vim.lsp.protocol.make_client_capabilities(), - require("cmp_nvim_lsp").default_capabilities(), - -- for nil_ls - { workspace = { didChangeWatchedFiles = { dynamicRegistration = true } } } -) - -local setup = { - on_attach = function(client, _) - require("lsp-format").on_attach(client) - end, - - capabilities = caps, -} - -for server, config in pairs(lsp_servers) do - local binary = config.binary or server - - local options = (config.extraOptions == nil) and setup or vim.tbl_extend("keep", config.extraOptions, setup) - - if vim.fn.executable(binary) == 1 then - require("lspconfig")[server].setup(options) - end -end diff --git a/plugin/lualine.lua b/plugin/lualine.lua deleted file mode 100644 index 603693d..0000000 --- a/plugin/lualine.lua +++ /dev/null @@ -1,11 +0,0 @@ -if vim.g.did_load_lualine_plugin then - return -end -vim.g.did_load_lualine_plugin = true - -require("lualine").setup({ - options = { - theme = "catppuccin", - }, - extensions = { "trouble" }, -}) diff --git a/plugin/mini.lua b/plugin/mini.lua deleted file mode 100644 index ebcbf78..0000000 --- a/plugin/mini.lua +++ /dev/null @@ -1,29 +0,0 @@ -if vim.g.did_load_mini_plugin then - return -end -vim.g.did_load_mini_plugin = true - -local hipatterns = require("mini.hipatterns") - -require("mini.files").setup() -hipatterns.setup({ - highlighters = { - hex_color = hipatterns.gen_highlighter.hex_color(), - }, -}) -require("mini.indentscope").setup({ - options = { try_as_border = true }, -}) -require("mini.pairs").setup() - -vim.api.nvim_create_autocmd("FileType", { - pattern = { - "help", - "Trouble", - "toggleterm", - }, - - callback = function() - vim.b.miniindentscope_disable = true - end, -}) diff --git a/plugin/telescope.lua b/plugin/telescope.lua deleted file mode 100644 index d50d742..0000000 --- a/plugin/telescope.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_telescope_plugin then - return -end -vim.g.did_load_telescope_plugin = true - -require("telescope").setup() diff --git a/plugin/treesitter.lua b/plugin/treesitter.lua deleted file mode 100644 index 4668fe8..0000000 --- a/plugin/treesitter.lua +++ /dev/null @@ -1,11 +0,0 @@ -if vim.g.did_load_treesitter_plugin then - return -end -vim.g.did_load_treesitter_plugin = true - -require("nvim-treesitter.configs").setup({ - auto_install = false, - - highlight = { enable = true }, - indent = { enable = true }, -}) diff --git a/plugin/trouble.lua b/plugin/trouble.lua deleted file mode 100644 index e1e7768..0000000 --- a/plugin/trouble.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_trouble_plugin then - return -end -vim.g.did_load_trouble_plugin = true - -require("trouble").setup() diff --git a/selene.toml b/selene.toml deleted file mode 100644 index 98b6ac7..0000000 --- a/selene.toml +++ /dev/null @@ -1 +0,0 @@ -std = "nvim" -- cgit v1.2.3