From 5ec30e9a2b9047713c060c90a5e7930fafc2a3d6 Mon Sep 17 00:00:00 2001 From: seth Date: Sat, 13 Jul 2024 20:12:35 -0400 Subject: flatten plugin structure --- .editorconfig | 12 ---- .gitignore | 10 +--- after/plugin/globals.lua | 4 ++ after/plugin/keymaps.lua | 44 ++++++++++++++ config/after/plugin/globals.lua | 4 -- config/after/plugin/keymaps.lua | 44 -------------- config/default.nix | 19 ------ config/ftdetect/just.lua | 5 -- config/lua/getchoo/efmls.lua | 58 ------------------ config/lua/getchoo/init.lua | 25 -------- config/plugin/bufferline.lua | 25 -------- config/plugin/catppuccin.lua | 33 ---------- config/plugin/cmp.lua | 47 --------------- config/plugin/dressing.lua | 6 -- config/plugin/fidget.lua | 6 -- config/plugin/flash.lua | 6 -- config/plugin/gitsigns.lua | 6 -- config/plugin/ibl.lua | 27 --------- config/plugin/lsp-format.lua | 6 -- config/plugin/lsp.lua | 129 ---------------------------------------- config/plugin/lualine.lua | 11 ---- config/plugin/mini.lua | 26 -------- config/plugin/telescope.lua | 6 -- config/plugin/treesitter.lua | 11 ---- config/plugin/trouble.lua | 6 -- config/plugin/which-key.lua | 10 ---- flake.nix | 82 +++++++++++++------------ ftdetect/just.lua | 5 ++ lua/getchoo/efmls.lua | 58 ++++++++++++++++++ lua/getchoo/init.lua | 25 ++++++++ neovim.nix | 43 ++++++++++---- plugin/bufferline.lua | 25 ++++++++ plugin/catppuccin.lua | 33 ++++++++++ plugin/cmp.lua | 47 +++++++++++++++ plugin/dressing.lua | 6 ++ plugin/fidget.lua | 6 ++ plugin/flash.lua | 6 ++ plugin/gitsigns.lua | 6 ++ plugin/ibl.lua | 27 +++++++++ plugin/lsp-format.lua | 6 ++ plugin/lsp.lua | 129 ++++++++++++++++++++++++++++++++++++++++ plugin/lualine.lua | 11 ++++ plugin/mini.lua | 26 ++++++++ plugin/telescope.lua | 6 ++ plugin/treesitter.lua | 11 ++++ plugin/trouble.lua | 6 ++ plugin/which-key.lua | 10 ++++ 47 files changed, 572 insertions(+), 588 deletions(-) delete mode 100644 .editorconfig create mode 100644 after/plugin/globals.lua create mode 100644 after/plugin/keymaps.lua delete mode 100644 config/after/plugin/globals.lua delete mode 100644 config/after/plugin/keymaps.lua delete mode 100644 config/default.nix delete mode 100644 config/ftdetect/just.lua delete mode 100644 config/lua/getchoo/efmls.lua delete mode 100644 config/lua/getchoo/init.lua delete mode 100644 config/plugin/bufferline.lua delete mode 100644 config/plugin/catppuccin.lua delete mode 100644 config/plugin/cmp.lua delete mode 100644 config/plugin/dressing.lua delete mode 100644 config/plugin/fidget.lua delete mode 100644 config/plugin/flash.lua delete mode 100644 config/plugin/gitsigns.lua delete mode 100644 config/plugin/ibl.lua delete mode 100644 config/plugin/lsp-format.lua delete mode 100644 config/plugin/lsp.lua delete mode 100644 config/plugin/lualine.lua delete mode 100644 config/plugin/mini.lua delete mode 100644 config/plugin/telescope.lua delete mode 100644 config/plugin/treesitter.lua delete mode 100644 config/plugin/trouble.lua delete mode 100644 config/plugin/which-key.lua create mode 100644 ftdetect/just.lua create mode 100644 lua/getchoo/efmls.lua create mode 100644 lua/getchoo/init.lua create mode 100644 plugin/bufferline.lua create mode 100644 plugin/catppuccin.lua create mode 100644 plugin/cmp.lua create mode 100644 plugin/dressing.lua create mode 100644 plugin/fidget.lua create mode 100644 plugin/flash.lua create mode 100644 plugin/gitsigns.lua create mode 100644 plugin/ibl.lua create mode 100644 plugin/lsp-format.lua create mode 100644 plugin/lsp.lua create mode 100644 plugin/lualine.lua create mode 100644 plugin/mini.lua create mode 100644 plugin/telescope.lua create mode 100644 plugin/treesitter.lua create mode 100644 plugin/trouble.lua create mode 100644 plugin/which-key.lua diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 54ba4d1..0000000 --- a/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_style = tab -insert_final_newline = true -trim_trailing_whitespace = true - -[*.{lock,nix}] -indent_size = 2 -indent_style = space diff --git a/.gitignore b/.gitignore index a3149df..e3b6f2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,4 @@ # nix build results -result* +result +result-* repl-result-out* - -# dev shell artifacts -.direnv -.pre-commit-config.yaml - -# vimnix artifacts -generated.lua diff --git a/after/plugin/globals.lua b/after/plugin/globals.lua new file mode 100644 index 0000000..f2d5650 --- /dev/null +++ b/after/plugin/globals.lua @@ -0,0 +1,4 @@ +-- for deno's lsp +vim.g.markdown_fenced_languages = { + "ts=typescript", +} diff --git a/after/plugin/keymaps.lua b/after/plugin/keymaps.lua new file mode 100644 index 0000000..9ff505a --- /dev/null +++ b/after/plugin/keymaps.lua @@ -0,0 +1,44 @@ +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/config/after/plugin/globals.lua b/config/after/plugin/globals.lua deleted file mode 100644 index f2d5650..0000000 --- a/config/after/plugin/globals.lua +++ /dev/null @@ -1,4 +0,0 @@ --- for deno's lsp -vim.g.markdown_fenced_languages = { - "ts=typescript", -} diff --git a/config/after/plugin/keymaps.lua b/config/after/plugin/keymaps.lua deleted file mode 100644 index 9ff505a..0000000 --- a/config/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/config/default.nix b/config/default.nix deleted file mode 100644 index ece45ef..0000000 --- a/config/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ - lib, - vimUtils, - version, -}: -vimUtils.buildVimPlugin { - pname = "neovim-config"; - inherit version; - - src = lib.fileset.toSource { - root = ./.; - fileset = lib.fileset.unions [ - ./after - ./ftdetect - ./lua - ./plugin - ]; - }; -} diff --git a/config/ftdetect/just.lua b/config/ftdetect/just.lua deleted file mode 100644 index 4c7098a..0000000 --- a/config/ftdetect/just.lua +++ /dev/null @@ -1,5 +0,0 @@ -vim.filetype.add({ - filename = { - ["justfile"] = "just", - }, -}) diff --git a/config/lua/getchoo/efmls.lua b/config/lua/getchoo/efmls.lua deleted file mode 100644 index 92d61e9..0000000 --- a/config/lua/getchoo/efmls.lua +++ /dev/null @@ -1,58 +0,0 @@ -local alex = require("efmls-configs.linters.alex") -alex.rootMarkers = nil -local actionlint = require("efmls-configs.linters.actionlint") -local beautysh = require("efmls-configs.formatters.beautysh") -local fish_indent = require("efmls-configs.formatters.fish_indent") -local prettier = require("efmls-configs.formatters.prettier") -local prettier_eslint = require("efmls-configs.formatters.prettier_eslint") -local selene = require("efmls-configs.linters.selene") -local statix = require("efmls-configs.linters.statix") -local stylua = require("efmls-configs.formatters.stylua") - -local languages = { - all = { alex }, - - bash = { - beautysh, - }, - - css = { prettier }, - - fish = { fish_indent }, - - html = { prettier }, - - javascript = { prettier_eslint }, - - json = { prettier }, - - lua = { selene, stylua }, - - nix = { statix }, - - sass = { prettier }, - - scss = { prettier }, - - sh = { beautysh }, - - typescript = { prettier_eslint }, - - yaml = { prettier, actionlint }, - - zsh = { beautysh }, -} - -return { - filetypes = vim.tbl_keys(languages), - - settings = { - rootMarkers = { ".git/" }, - languages = languages, - }, - - init_options = { - documentFormatting = true, - documentRangeFormatting = true, - }, -} diff --git a/config/lua/getchoo/init.lua b/config/lua/getchoo/init.lua deleted file mode 100644 index a919bc8..0000000 --- a/config/lua/getchoo/init.lua +++ /dev/null @@ -1,25 +0,0 @@ -local opt = vim.opt - -opt.shiftwidth = 2 -opt.tabstop = 2 --- https://www.reddit.com/r/neovim/comments/14n6iiy/if_you_have_treesitter_make_sure_to_disable --- TLDR: this breaks things with treesitter indent -opt.smartindent = false -opt.number = true -opt.wrap = true -opt.syntax = "on" -opt.termguicolors = true -opt.mouse = "a" - -local backupDir = vim.fn.stdpath("state") .. "/backup" -local b = io.open(backupDir, "r") -if b then - b:close() -else - os.execute("mkdir -p " .. backupDir) -end - -opt.backupdir = backupDir - -vim.g.mapleader = "," -vim.g.do_filetype_lua = 1 diff --git a/config/plugin/bufferline.lua b/config/plugin/bufferline.lua deleted file mode 100644 index f6e68ef..0000000 --- a/config/plugin/bufferline.lua +++ /dev/null @@ -1,25 +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", - - offsets = { - { - filetype = "neo-tree", - text = "neo-tree", - highlight = "Directory", - text_align = "left", - }, - }, - }, -}) diff --git a/config/plugin/catppuccin.lua b/config/plugin/catppuccin.lua deleted file mode 100644 index 79b84ec..0000000 --- a/config/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/config/plugin/cmp.lua b/config/plugin/cmp.lua deleted file mode 100644 index 10c750f..0000000 --- a/config/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/config/plugin/dressing.lua b/config/plugin/dressing.lua deleted file mode 100644 index dc926fe..0000000 --- a/config/plugin/dressing.lua +++ /dev/null @@ -1,6 +0,0 @@ -if vim.g.did_load_dressing_plugin then - return -end -vim.g.did_load_dressing_plugin = true - -require("dressing") diff --git a/config/plugin/fidget.lua b/config/plugin/fidget.lua deleted file mode 100644 index 59fbb0c..0000000 --- a/config/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/config/plugin/flash.lua b/config/plugin/flash.lua deleted file mode 100644 index f3e1c15..0000000 --- a/config/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/config/plugin/gitsigns.lua b/config/plugin/gitsigns.lua deleted file mode 100644 index 7f6f457..0000000 --- a/config/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/config/plugin/ibl.lua b/config/plugin/ibl.lua deleted file mode 100644 index d780c74..0000000 --- a/config/plugin/ibl.lua +++ /dev/null @@ -1,27 +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", - "neo-tree", - "Trouble", - "lazy", - "mason", - "notify", - "toggleterm", - }, - }, - - indent = { - char = "│", - tab_char = "│", - }, - - scope = { - enabled = false, - }, -}) diff --git a/config/plugin/lsp-format.lua b/config/plugin/lsp-format.lua deleted file mode 100644 index e21bdfd..0000000 --- a/config/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/config/plugin/lsp.lua b/config/plugin/lsp.lua deleted file mode 100644 index 356add3..0000000 --- a/config/plugin/lsp.lua +++ /dev/null @@ -1,129 +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", - }, - - efm = { - binary = "efm-langserver", - extraOptions = require("getchoo.efmls"), - }, - - lua_ls = { - binary = "lua-language-server", - extraOptions = { - settings = { - Lua = { - runtime = { version = "LuaJIT" }, - diagnostics = { globals = "vim" }, - workspace = { library = vim.api.nvim_get_runtime_file("", true) }, - }, - }, - }, - }, - - 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 = { - checkOnSave = { 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/config/plugin/lualine.lua b/config/plugin/lualine.lua deleted file mode 100644 index 8a8f87a..0000000 --- a/config/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 = { "neo-tree", "trouble" }, -}) diff --git a/config/plugin/mini.lua b/config/plugin/mini.lua deleted file mode 100644 index 1911516..0000000 --- a/config/plugin/mini.lua +++ /dev/null @@ -1,26 +0,0 @@ -if vim.g.did_load_mini_plugin then - return -end -vim.g.did_load_mini_plugin = true - -require("mini.comment").setup() -require("mini.files").setup() -require("mini.pairs").setup() -require("mini.indentscope").setup({ - options = { try_as_border = true }, -}) - -vim.api.nvim_create_autocmd("FileType", { - pattern = { - "help", - "neo-tree", - "Trouble", - "lazy", - "mason", - "notify", - "toggleterm", - }, - callback = function() - vim.b.miniindentscope_disable = true - end, -}) diff --git a/config/plugin/telescope.lua b/config/plugin/telescope.lua deleted file mode 100644 index d50d742..0000000 --- a/config/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/config/plugin/treesitter.lua b/config/plugin/treesitter.lua deleted file mode 100644 index 4668fe8..0000000 --- a/config/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/config/plugin/trouble.lua b/config/plugin/trouble.lua deleted file mode 100644 index e1e7768..0000000 --- a/config/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/config/plugin/which-key.lua b/config/plugin/which-key.lua deleted file mode 100644 index e6d5ecc..0000000 --- a/config/plugin/which-key.lua +++ /dev/null @@ -1,10 +0,0 @@ -if vim.g.did_load_which_key_plugin then - return -end -vim.g.did_load_which_key_plugin = true - -require("which-key").setup({ - plugins = { - spelling = { enable = true }, - }, -}) diff --git a/flake.nix b/flake.nix index 68234c8..dbde118 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,15 @@ { description = "getchoo's neovim config"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; outputs = { self, nixpkgs }: let + inherit (nixpkgs) lib; + systems = [ "x86_64-linux" "aarch64-linux" @@ -13,7 +17,7 @@ "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs systems; + forAllSystems = lib.genAttrs systems; nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); in { @@ -21,19 +25,41 @@ 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 { - check-formatting = - pkgs.runCommand "check-formatting" + check-format-and-lint = + pkgs.runCommand "check-format-and-lint" { nativeBuildInputs = [ pkgs.actionlint pkgs.nixfmt-rfc-style - pkgs.stylua + pkgs.selene + pkgs.statix ]; } '' - cd ${./.} + cd ${root} echo "running actionlint..." actionlint ./.github/workflows/* @@ -41,31 +67,15 @@ echo "running nixfmt..." nixfmt --check . - echo "running stylua..." - stylua --check . - - touch $out - ''; - - check-lint = - pkgs.runCommand "check-lint" - { - nativeBuildInputs = [ - pkgs.selene - pkgs.statix - ]; - } - '' - cd ${./.} - - echo "running selene..." - selene . + echo "running selene...." + selene **/*.lua echo "running statix..." statix check . touch $out ''; + } ); @@ -96,24 +106,12 @@ formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); - packages = forAllSystems ( - system: - let - pkgs = nixpkgsFor.${system}; - - packages' = self.packages.${system}; + packages = forAllSystems (system: { + getchvim = nixpkgsFor.${system}.callPackage ./neovim.nix { version = self.shortRev or self.dirtyShortRev or "unknown"; - in - { - getchvim = pkgs.callPackage ./neovim.nix { - inherit version; - inherit (packages') vimPlugins-getchoo-nvim; - }; + }; - vimPlugins-getchoo-nvim = pkgs.callPackage ./config { inherit version; }; - - default = packages'.getchvim; - } - ); + default = self.packages.${system}.getchvim; + }); }; } diff --git a/ftdetect/just.lua b/ftdetect/just.lua new file mode 100644 index 0000000..4c7098a --- /dev/null +++ b/ftdetect/just.lua @@ -0,0 +1,5 @@ +vim.filetype.add({ + filename = { + ["justfile"] = "just", + }, +}) diff --git a/lua/getchoo/efmls.lua b/lua/getchoo/efmls.lua new file mode 100644 index 0000000..92d61e9 --- /dev/null +++ b/lua/getchoo/efmls.lua @@ -0,0 +1,58 @@ +local alex = require("efmls-configs.linters.alex") +alex.rootMarkers = nil +local actionlint = require("efmls-configs.linters.actionlint") +local beautysh = require("efmls-configs.formatters.beautysh") +local fish_indent = require("efmls-configs.formatters.fish_indent") +local prettier = require("efmls-configs.formatters.prettier") +local prettier_eslint = require("efmls-configs.formatters.prettier_eslint") +local selene = require("efmls-configs.linters.selene") +local statix = require("efmls-configs.linters.statix") +local stylua = require("efmls-configs.formatters.stylua") + +local languages = { + all = { alex }, + + bash = { + beautysh, + }, + + css = { prettier }, + + fish = { fish_indent }, + + html = { prettier }, + + javascript = { prettier_eslint }, + + json = { prettier }, + + lua = { selene, stylua }, + + nix = { statix }, + + sass = { prettier }, + + scss = { prettier }, + + sh = { beautysh }, + + typescript = { prettier_eslint }, + + yaml = { prettier, actionlint }, + + zsh = { beautysh }, +} + +return { + filetypes = vim.tbl_keys(languages), + + settings = { + rootMarkers = { ".git/" }, + languages = languages, + }, + + init_options = { + documentFormatting = true, + documentRangeFormatting = true, + }, +} diff --git a/lua/getchoo/init.lua b/lua/getchoo/init.lua new file mode 100644 index 0000000..a919bc8 --- /dev/null +++ b/lua/getchoo/init.lua @@ -0,0 +1,25 @@ +local opt = vim.opt + +opt.shiftwidth = 2 +opt.tabstop = 2 +-- https://www.reddit.com/r/neovim/comments/14n6iiy/if_you_have_treesitter_make_sure_to_disable +-- TLDR: this breaks things with treesitter indent +opt.smartindent = false +opt.number = true +opt.wrap = true +opt.syntax = "on" +opt.termguicolors = true +opt.mouse = "a" + +local backupDir = vim.fn.stdpath("state") .. "/backup" +local b = io.open(backupDir, "r") +if b then + b:close() +else + os.execute("mkdir -p " .. backupDir) +end + +opt.backupdir = backupDir + +vim.g.mapleader = "," +vim.g.do_filetype_lua = 1 diff --git a/neovim.nix b/neovim.nix index 096c32d..465f805 100644 --- a/neovim.nix +++ b/neovim.nix @@ -1,6 +1,7 @@ { lib, neovimUtils, + vimUtils, vimPlugins, wrapNeovimUnstable, neovim-unwrapped, @@ -14,11 +15,30 @@ shellcheck, statix, typos-lsp, - vimPlugins-getchoo-nvim, - ... + 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 + bufferline-nvim # dependent on > nvim-web-devicons @@ -78,20 +98,23 @@ let typos-lsp ]; - neovimConfig = neovimUtils.makeNeovimConfig { plugins = plugins ++ [ vimPlugins-getchoo-nvim ]; }; -in -wrapNeovimUnstable neovim-unwrapped ( - neovimConfig - // { + baseConfig = neovimUtils.makeNeovimConfig { + withRuby = false; + inherit plugins; + }; + + config = baseConfig // { + # init our configuration luaRcContent = '' require("getchoo") ''; - wrapperArgs = neovimConfig.wrapperArgs ++ [ + wrapperArgs = baseConfig.wrapperArgs ++ [ "--suffix" "PATH" ":" "${lib.makeBinPath extraPackages}" ]; - } -) + }; +in +wrapNeovimUnstable neovim-unwrapped config diff --git a/plugin/bufferline.lua b/plugin/bufferline.lua new file mode 100644 index 0000000..f6e68ef --- /dev/null +++ b/plugin/bufferline.lua @@ -0,0 +1,25 @@ +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", + + offsets = { + { + filetype = "neo-tree", + text = "neo-tree", + highlight = "Directory", + text_align = "left", + }, + }, + }, +}) diff --git a/plugin/catppuccin.lua b/plugin/catppuccin.lua new file mode 100644 index 0000000..79b84ec --- /dev/null +++ b/plugin/catppuccin.lua @@ -0,0 +1,33 @@ +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 new file mode 100644 index 0000000..10c750f --- /dev/null +++ b/plugin/cmp.lua @@ -0,0 +1,47 @@ +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/dressing.lua b/plugin/dressing.lua new file mode 100644 index 0000000..dc926fe --- /dev/null +++ b/plugin/dressing.lua @@ -0,0 +1,6 @@ +if vim.g.did_load_dressing_plugin then + return +end +vim.g.did_load_dressing_plugin = true + +require("dressing") diff --git a/plugin/fidget.lua b/plugin/fidget.lua new file mode 100644 index 0000000..59fbb0c --- /dev/null +++ b/plugin/fidget.lua @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..f3e1c15 --- /dev/null +++ b/plugin/flash.lua @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..7f6f457 --- /dev/null +++ b/plugin/gitsigns.lua @@ -0,0 +1,6 @@ +if vim.g.did_load_gitsigns_plugin then + return +end +vim.g.did_load_gitsigns_plugin = true + +require("gitsigns").setup() diff --git a/plugin/ibl.lua b/plugin/ibl.lua new file mode 100644 index 0000000..d780c74 --- /dev/null +++ b/plugin/ibl.lua @@ -0,0 +1,27 @@ +if vim.g.did_load_ibl_plugin then + return +end +vim.g.did_load_ibl_plugin = true + +require("ibl").setup({ + exclude = { + filetypes = { + "help", + "neo-tree", + "Trouble", + "lazy", + "mason", + "notify", + "toggleterm", + }, + }, + + indent = { + char = "│", + tab_char = "│", + }, + + scope = { + enabled = false, + }, +}) diff --git a/plugin/lsp-format.lua b/plugin/lsp-format.lua new file mode 100644 index 0000000..e21bdfd --- /dev/null +++ b/plugin/lsp-format.lua @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..356add3 --- /dev/null +++ b/plugin/lsp.lua @@ -0,0 +1,129 @@ +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", + }, + + efm = { + binary = "efm-langserver", + extraOptions = require("getchoo.efmls"), + }, + + lua_ls = { + binary = "lua-language-server", + extraOptions = { + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + diagnostics = { globals = "vim" }, + workspace = { library = vim.api.nvim_get_runtime_file("", true) }, + }, + }, + }, + }, + + 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 = { + checkOnSave = { 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 new file mode 100644 index 0000000..8a8f87a --- /dev/null +++ b/plugin/lualine.lua @@ -0,0 +1,11 @@ +if vim.g.did_load_lualine_plugin then + return +end +vim.g.did_load_lualine_plugin = true + +require("lualine").setup({ + options = { + theme = "catppuccin", + }, + extensions = { "neo-tree", "trouble" }, +}) diff --git a/plugin/mini.lua b/plugin/mini.lua new file mode 100644 index 0000000..1911516 --- /dev/null +++ b/plugin/mini.lua @@ -0,0 +1,26 @@ +if vim.g.did_load_mini_plugin then + return +end +vim.g.did_load_mini_plugin = true + +require("mini.comment").setup() +require("mini.files").setup() +require("mini.pairs").setup() +require("mini.indentscope").setup({ + options = { try_as_border = true }, +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = { + "help", + "neo-tree", + "Trouble", + "lazy", + "mason", + "notify", + "toggleterm", + }, + callback = function() + vim.b.miniindentscope_disable = true + end, +}) diff --git a/plugin/telescope.lua b/plugin/telescope.lua new file mode 100644 index 0000000..d50d742 --- /dev/null +++ b/plugin/telescope.lua @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..4668fe8 --- /dev/null +++ b/plugin/treesitter.lua @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..e1e7768 --- /dev/null +++ b/plugin/trouble.lua @@ -0,0 +1,6 @@ +if vim.g.did_load_trouble_plugin then + return +end +vim.g.did_load_trouble_plugin = true + +require("trouble").setup() diff --git a/plugin/which-key.lua b/plugin/which-key.lua new file mode 100644 index 0000000..e6d5ecc --- /dev/null +++ b/plugin/which-key.lua @@ -0,0 +1,10 @@ +if vim.g.did_load_which_key_plugin then + return +end +vim.g.did_load_which_key_plugin = true + +require("which-key").setup({ + plugins = { + spelling = { enable = true }, + }, +}) -- cgit v1.2.3