diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..653f105 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1 @@ +globals = { "vim" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b9b346..4ef121d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,58 @@ # Changelog +## 24th February 2024 + +### Added + +* Add `neodev`. + +### Removed + +* Remove some unused plugins and packages. + * e.g. floaterm, projectionist, vim-wiki, vim-easy-align, + vim-surround, visual-star-search, vim-rhubarb + +### Changed + +* Tidy neovim configuration + * Replace none-ls with conform.nvim and nvim-lint. + * Replace lualine.nvim with mini-statusline. + * Simplify cmp completion sources. + +## 21st February 2024 + +### Added + +* Re-add `vim-just` and `fidget.nvim`. + +## 13th February 2024 + +### Changed + +* Use `alejandra` to format Nix files. + +## 5th February 2024 + +### Fixed + +* Fix PHPUnit command in `vim-test`. + +## 27th January 2024 + +### Added + +* Add vim-floaterm. + +### Removed + +* Remove Astro plugin and language server. + +## 26th January 2024 + +### Added + +* Add vim-wiki. + ## 25th January 2024 ### Added diff --git a/after/plugin/colorscheme.lua b/after/plugin/colorscheme.lua index a6f0ace..d949f5f 100644 --- a/after/plugin/colorscheme.lua +++ b/after/plugin/colorscheme.lua @@ -8,6 +8,10 @@ catppuccin.setup { integrations = { cmp = true, gitsigns = true, + mini = { + enabled = true, + indentscope_color = "", + }, native_lsp = { enabled = true, }, diff --git a/after/plugin/completion.lua b/after/plugin/completion.lua index 0e60829..5104fda 100644 --- a/after/plugin/completion.lua +++ b/after/plugin/completion.lua @@ -26,13 +26,9 @@ cmp.setup { }, sources = { - { name = "nvim_lsp_signature_help" }, { name = "nvim_lsp" }, { name = "nvim_lua" }, - { name = "cmp_tabnine" }, - { name = "path" }, { name = "luasnip" }, - { name = "buffer", keyword_length = 5, max_item_count = 5 }, }, sorting = { diff --git a/after/plugin/floaterm.lua b/after/plugin/floaterm.lua deleted file mode 100644 index b950b61..0000000 --- a/after/plugin/floaterm.lua +++ /dev/null @@ -1,8 +0,0 @@ --- Based on https://github.com/ALT-F4-LLC/thealtf4stream.nvim/blob/main/lua/TheAltF4Stream/floaterm.lua. - -local nmap = require "opdavies.keymap".nmap - -nmap { "ld", "FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazydocker" } -nmap { "lg", "FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazygit" } -nmap { "nn", "FloatermNew --autoclose=2 --height=0.75 --width=0.75 nnn -Hde" } -nmap { "tt", "FloatermNew --autoclose=2 --height=0.9 --width=0.9 zsh" } diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua deleted file mode 100644 index 7c0d419..0000000 --- a/after/plugin/lualine.lua +++ /dev/null @@ -1,9 +0,0 @@ -require("lualine").setup { - options = { - component_separators = { left = "", right = "" }, - extensions = { "fzf", "quickfix" }, - icons_enabled = false, - section_separators = { left = "", right = "" }, - theme = "catppuccin", - }, -} diff --git a/after/plugin/mini.lua b/after/plugin/mini.lua new file mode 100644 index 0000000..4b6bbc3 --- /dev/null +++ b/after/plugin/mini.lua @@ -0,0 +1,22 @@ +require("mini.ai").setup {} + +require("mini.align").setup {} + +require("mini.bracketed").setup {} + +require("mini.hipatterns").setup { + highlighters = { + note = { pattern = "%f[%w]()NOTE()%f[%W]", group = "MiniHipatternsNote" }, + todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, + }, +} + +require("mini.move").setup {} + +require("mini.operators").setup {} + +require("mini.splitjoin").setup {} + +require("mini.statusline").setup {} + +require("mini.surround").setup {} diff --git a/after/plugin/projectionist.lua b/after/plugin/projectionist.lua deleted file mode 100644 index 81467bb..0000000 --- a/after/plugin/projectionist.lua +++ /dev/null @@ -1,58 +0,0 @@ -local heuristics = { - ["composer.json"] = { - ["src/*.php"] = { - type = "source", - alternate = "tests/{}Test.php", - }, - - ["src/Controller/*.php"] = { - type = "controller", - }, - - ["src/Model/*.php"] = { - type = "model", - }, - - ["src/Service/*.php"] = { - type = "service", - }, - - ["tests/*Test.php"] = { - type = "test", - alternate = "src/{}.php", - }, - }, - - ["fractal.config.js"] = { - ["*.config.yml"] = { - alternate = "{dirname}/{basename}.twig", - }, - - ["*.twig"] = { - alternate = "{dirname}/{basename}.config.yml", - }, - }, - - ["package.json"] = { - ["src/*.ts"] = { - type = "source", - alternate = "tests/{}.test.ts", - }, - - ["src/*.service.ts"] = { - type = "source", - alternate = "tests/{}.test.ts", - }, - - ["tests/*.test.ts"] = { - type = "test", - alternate = "src/{}.ts", - }, - }, -} - -vim.g.projectionist_heuristics = heuristics - -local nmap = require("opdavies.keymap").nmap - -nmap { "aa", "A" } diff --git a/after/plugin/vim-wiki.lua b/after/plugin/vim-wiki.lua deleted file mode 100644 index c667a6a..0000000 --- a/after/plugin/vim-wiki.lua +++ /dev/null @@ -1,7 +0,0 @@ -vim.g.vimwiki_list = { - { - ext = 'md', - path = '~/Documents/Google Drive/vim-wiki', - syntax = 'markdown', - } -} diff --git a/flake.lock b/flake.lock index fd0ada9..176b082 100644 --- a/flake.lock +++ b/flake.lock @@ -19,11 +19,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1708118438, - "narHash": "sha256-kk9/0nuVgA220FcqH/D2xaN6uGyHp/zoxPNUmPCMmEE=", + "lastModified": 1708655239, + "narHash": "sha256-ZrP/yACUvDB+zbqYJsln4iwotbH6CTZiTkANJ0AgDv4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5863c27340ba4de8f83e7e3c023b9599c3cb3c80", + "rev": "cbc4211f0afffe6dfd2478a62615dd5175a13f9a", "type": "github" }, "original": { @@ -33,6 +33,22 @@ "type": "github" } }, + "nixpkgs-2305": { + "locked": { + "lastModified": 1704290814, + "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-lib": { "locked": { "dir": "lib", @@ -54,7 +70,8 @@ "root": { "inputs": { "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-2305": "nixpkgs-2305" } } }, diff --git a/flake.nix b/flake.nix index 9e55795..107071d 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,8 @@ { - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs-2305.url = "github:NixOS/nixpkgs/nixos-23.05"; + }; outputs = inputs @ { self, diff --git a/justfile b/justfile new file mode 100644 index 0000000..16e7883 --- /dev/null +++ b/justfile @@ -0,0 +1,8 @@ +_default: + just --list + +build profile: + nix build --json --no-link --print-build-logs ".#{{ profile }}" + +check: + nix flake check diff --git a/lib/default.nix b/lib/default.nix index cf2e659..c4bed11 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -4,6 +4,7 @@ in rec { mkVimPlugin = {system}: let inherit (pkgs) vimUtils; inherit (vimUtils) buildVimPlugin; + pkgs = legacyPackages.${system}; in buildVimPlugin { @@ -11,9 +12,11 @@ in rec { postInstall = '' rm -rf $out/.envrc rm -rf $out/.gitignore + rm -rf $out/.luacheckrc rm -rf $out/CHANGELOG.md rm -rf $out/flake.lock rm -rf $out/flake.nix + rm -rf $out/justfile rm -rf $out/lib rm -rf $out/run rm -rf $out/stylua.toml @@ -22,7 +25,7 @@ in rec { }; mkNeovimPlugins = {system}: let - inherit (pkgs) vimPlugins; + inherit (pkgs) php82Packages vimPlugins; pkgs = import inputs.nixpkgs { inherit system; @@ -30,6 +33,8 @@ in rec { config.allowUnfree = true; }; + pkgs2305 = inputs.nixpkgs-2305.legacyPackages.${system}; + customVim = { tabline-vim = pkgs.vimUtils.buildVimPlugin { name = "tabline-vim"; @@ -41,16 +46,6 @@ in rec { }; }; - toggle-checkbox-nvim = pkgs.vimUtils.buildVimPlugin { - name = "toggle-checkbox-nvim"; - src = pkgs.fetchFromGitHub { - owner = "opdavies"; - repo = "toggle-checkbox.nvim"; - rev = "main"; - sha256 = "4YSEagQnLK5MBl2z53e6sOBlCDm220GYVlc6A+HNywg="; - }; - }; - vim-caser = pkgs.vimUtils.buildVimPlugin { name = "vim-caser"; src = pkgs.fetchFromGitHub { @@ -100,43 +95,31 @@ in rec { customVim.vim-textobj-xmlattr customVim.vim-zoom - # { - # plugin = customVim.toggle-checkbox-nvim; - # type = "lua"; - # config = '' - # vim.keymap.set("n", "t", ":lua require('toggle-checkbox').toggle()") - # ''; - # } - - vimPlugins.fidget-nvim - vimPlugins.harpoon - vimPlugins.refactoring-nvim vimPlugins.comment-nvim vimPlugins.dial-nvim + vimPlugins.fidget-nvim vimPlugins.gitsigns-nvim + vimPlugins.harpoon vimPlugins.impatient-nvim + vimPlugins.mini-nvim + vimPlugins.neodev-nvim vimPlugins.nvim-web-devicons + vimPlugins.refactoring-nvim vimPlugins.rest-nvim vimPlugins.undotree - vimPlugins.vim-easy-align vimPlugins.vim-eunuch vimPlugins.vim-highlightedyank - vimPlugins.vim-nix vimPlugins.vim-just + vimPlugins.vim-nix vimPlugins.vim-obsession vimPlugins.vim-pasta vimPlugins.vim-polyglot - vimPlugins.vim-projectionist vimPlugins.vim-repeat vimPlugins.vim-sleuth - vimPlugins.vim-surround vimPlugins.vim-terraform vimPlugins.vim-textobj-user vimPlugins.vim-tmux-navigator vimPlugins.vim-unimpaired - vimPlugins.vim-visual-star-search - - vimPlugins.lualine-nvim # { # plugin = vimPlugins.vim-sort-motion; @@ -160,7 +143,6 @@ in rec { # Git vimPlugins.vim-fugitive - vimPlugins.vim-rhubarb # Debugging vimPlugins.nvim-dap @@ -175,22 +157,19 @@ in rec { # LSP, linting and formatting vimPlugins.conform-nvim vimPlugins.lsp-status-nvim - vimPlugins.none-ls-nvim + vimPlugins.nvim-lint vimPlugins.nvim-lspconfig # Completion + pkgs2305.vimPlugins.phpactor vimPlugins.cmp-buffer vimPlugins.cmp-cmdline vimPlugins.cmp-nvim-lsp - vimPlugins.cmp-nvim-lsp-signature-help vimPlugins.cmp-path - vimPlugins.cmp-tabnine vimPlugins.cmp-treesitter - vimPlugins.cmp-vsnip vimPlugins.cmp_luasnip vimPlugins.lspkind-nvim vimPlugins.nvim-cmp - vimPlugins.phpactor # Snippets vimPlugins.friendly-snippets @@ -211,8 +190,6 @@ in rec { vimPlugins.vim-dadbod-ui vimPlugins.vim-dadbod-completion - vimPlugins.vim-floaterm - # # Markdown # { # plugin = vimPlugins.markdown-preview-nvim; @@ -225,15 +202,12 @@ in rec { # Themes vimPlugins.catppuccin-nvim - # Wiki - vimPlugins.vimwiki - # Configuration. opdavies-nvim ]; mkExtraPackages = {system}: let - inherit (pkgs) nodePackages; + inherit (pkgs) nodePackages lua54Packages php82Packages; pkgs = import inputs.nixpkgs { inherit system; @@ -246,6 +220,7 @@ in rec { pkgs.php81 # Language servers + lua54Packages.luacheck nodePackages."@tailwindcss/language-server" nodePackages.bash-language-server nodePackages.dockerfile-language-server-nodejs @@ -272,11 +247,11 @@ in rec { pkgs.stylua # Tools + nodePackages.markdownlint-cli + php82Packages.phpcbf + php82Packages.phpcs + php82Packages.phpstan pkgs.html-tidy - pkgs.lazygit - pkgs.lazydocker - pkgs.nnn - pkgs.nodePackages.markdownlint-cli pkgs.proselint pkgs.shellcheck ]; diff --git a/lua/opdavies/lsp/init.lua b/lua/opdavies/lsp/init.lua index d131336..ea75ba3 100644 --- a/lua/opdavies/lsp/init.lua +++ b/lua/opdavies/lsp/init.lua @@ -33,7 +33,7 @@ local custom_attach = function(client) nvim_status.on_attach(client) - buf_inoremap { "", vim.lsp.buf.signature_help } + buf_inoremap { "", vim.lsp.buf.signature_help } buf_nnoremap { "ca", vim.lsp.buf.code_action } buf_nnoremap { "d", vim.diagnostic.open_float } buf_nnoremap { "rn", vim.lsp.buf.rename } @@ -66,6 +66,8 @@ local custom_attach = function(client) -- filetype_attach[filetype](client) end +require("neodev").setup {} + local servers = { ansiblels = true, bashls = true, @@ -85,9 +87,21 @@ local servers = { lua_ls = { settings = { Lua = { + completion = { + callSnippet = "Replace", + }, + diagnostics = { globals = { "vim" }, }, + + runtime = { + version = "LuaJIT", + }, + + workspace = { + checkThirdParty = false, + }, }, }, }, @@ -146,9 +160,42 @@ vim.diagnostic.config { virtual_text = { spacing = 2 }, } +local conform = require "conform" + +conform.setup { + formatters_by_ft = { + bash = { "shellcheck" }, + javascript = { { "prettierd", "prettier" } }, + just = { "just" }, + lua = { "stylua" }, + nix = { { "alejandra", "nixfmt" } }, + php = { { "php_cs_fixer", "phpcbf" } }, + terraform = { "terraform_fmt" }, + yaml = { "yamlfmt" }, + }, +} + vim.keymap.set("n", "f", function() - vim.lsp.buf.format { async = true } + conform.format { lsp_fallback = true, async = false, timeout_ms = 500 } end) -require "opdavies.lsp.none-ls" -require "opdavies.lsp.signature" +local lint = require "lint" + +lint.linters_by_ft = { + dockerfile = { "hadolint" }, + javascript = { "eslint_d" }, + json = { "jsonlint" }, + lua = { "luacheck" }, + markdown = { "markdownlint" }, + nix = { "nix" }, + php = { "php", "phpcs", "phpstan" }, +} + +local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + +vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, +}) diff --git a/lua/opdavies/lsp/none-ls.lua b/lua/opdavies/lsp/none-ls.lua deleted file mode 100644 index 8bb291e..0000000 --- a/lua/opdavies/lsp/none-ls.lua +++ /dev/null @@ -1,47 +0,0 @@ -local status_ok, null_ls = pcall(require, "null-ls") -if not status_ok then - return -end - -local code_actions = null_ls.builtins.code_actions -local diagnostics = null_ls.builtins.diagnostics -local formatting = null_ls.builtins.formatting - -null_ls.setup { - sources = { - code_actions.gitsigns, - - formatting.alejandra, - formatting.black, - formatting.markdownlint, - formatting.phpcbf.with { - command = "./vendor/bin/phpcbf", - condition = function(utils) - return utils.root_has_file { "phpcs.xml.dist" } - end, - }, - formatting.prettier, - formatting.rustywind, - formatting.stylua, - - diagnostics.eslint.with { - condition = function(utils) - return utils.root_has_file { ".eslintrc.js" } - end, - }, - diagnostics.markdownlint.with { - extra_args = { "--config", "~/.markdownlint.yaml" }, - }, - diagnostics.php, - diagnostics.phpcs.with { - command = "./vendor/bin/phpcs", - condition = function(utils) - return utils.root_has_file { "phpcs.xml.dist" } - end, - }, - diagnostics.phpstan, - diagnostics.shellcheck, - }, - - temp_dir = "/tmp", -} diff --git a/lua/opdavies/lsp/signature.lua b/lua/opdavies/lsp/signature.lua deleted file mode 100644 index 365c973..0000000 --- a/lua/opdavies/lsp/signature.lua +++ /dev/null @@ -1,6 +0,0 @@ -local status_ok, lsp_signature = pcall(require, "lsp_signature") -if not status_ok then - return -end - -lsp_signature.setup {}