From 576989abe8aea0e6acb2d2a389bf6f6adbc9a212 Mon Sep 17 00:00:00 2001 From: winston Date: Sun, 14 May 2023 13:40:39 +0200 Subject: [PATCH] feat(nvim): notify, gitsigns, pre-commit, lazy types --- .luacheckrc | 14 ++++ flake.nix | 13 ++-- home/apps/neovim/.luarc.json | 4 ++ home/apps/neovim/lazy-lock.json | 11 ++-- home/apps/neovim/lua/plugins/alpha.lua | 1 + .../neovim/lua/plugins/auto-dark-mode.lua | 1 + home/apps/neovim/lua/plugins/auto-pairs.lua | 1 + home/apps/neovim/lua/plugins/bufferline.lua | 1 + home/apps/neovim/lua/plugins/catppuccin.lua | 2 + home/apps/neovim/lua/plugins/colorizer.lua | 1 + home/apps/neovim/lua/plugins/copilot.lua | 1 + home/apps/neovim/lua/plugins/databases.lua | 1 + home/apps/neovim/lua/plugins/editor.lua | 3 +- home/apps/neovim/lua/plugins/fidget.lua | 1 + home/apps/neovim/lua/plugins/git.lua | 64 +------------------ .../neovim/lua/plugins/indent-blankline.lua | 1 + home/apps/neovim/lua/plugins/lsp.lua | 1 + home/apps/neovim/lua/plugins/lualine.lua | 1 + .../neovim/lua/plugins/natural-language.lua | 1 + home/apps/neovim/lua/plugins/neorg.lua | 1 + home/apps/neovim/lua/plugins/notify.lua | 25 ++++++++ home/apps/neovim/lua/plugins/nvim-tree.lua | 1 + home/apps/neovim/lua/plugins/presence.lua | 7 +- home/apps/neovim/lua/plugins/spectre.lua | 1 + home/apps/neovim/lua/plugins/telescope.lua | 6 ++ home/apps/neovim/lua/plugins/tree-sitter.lua | 1 + home/apps/neovim/lua/plugins/which-key.lua | 15 +++-- 27 files changed, 94 insertions(+), 86 deletions(-) create mode 100644 .luacheckrc create mode 100644 home/apps/neovim/.luarc.json create mode 100644 home/apps/neovim/lua/plugins/notify.lua diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..9e6876e --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,14 @@ +---@diagnostic disable: undefined-global + +files["home/apps/neovim"] = { + globals = { "vim" }, + std = "lua51+luajit", +} + +return { + exclude_files = { + ".direnv/*", + "result/*", + }, + max_line_length = false, +} diff --git a/flake.nix b/flake.nix index 6affa76..b19f456 100644 --- a/flake.nix +++ b/flake.nix @@ -162,20 +162,17 @@ alejandra.enable = true; commitizen.enable = true; editorconfig-checker.enable = true; - nil.enable = true; - shellcheck.enable = true; - stylua.enable = true; flake-check = { - enable = false; + enable = true; types = ["nix"]; language = "system"; entry = "just check"; pass_filenames = false; }; - }; - settings.deadnix = { - noLambdaPatternNames = true; - noLambdaArg = true; + luacheck.enable = true; + nil.enable = true; + shellcheck.enable = true; + stylua.enable = true; }; }; }; diff --git a/home/apps/neovim/.luarc.json b/home/apps/neovim/.luarc.json new file mode 100644 index 0000000..6c63f59 --- /dev/null +++ b/home/apps/neovim/.luarc.json @@ -0,0 +1,4 @@ +{ + "Lua.runtime.version": "Lua 5.1", + "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json" +} diff --git a/home/apps/neovim/lazy-lock.json b/home/apps/neovim/lazy-lock.json index a50ef36..b3bbcba 100644 --- a/home/apps/neovim/lazy-lock.json +++ b/home/apps/neovim/lazy-lock.json @@ -23,7 +23,7 @@ "guihua.lua": { "branch": "master", "commit": "ab8b1f09603cc268770efd057115035dc6cfa83d" }, "headlines.nvim": { "branch": "master", "commit": "ddef41b2664f0ce25fe76520d708e2dc9dfebd70" }, "indent-blankline.nvim": { "branch": "master", "commit": "018bd04d80c9a73d399c1061fa0c3b14a7614399" }, - "lazy.nvim": { "branch": "main", "commit": "652b6febf8d5c99eb8cf4a1cec63da6db62e77d2" }, + "lazy.nvim": { "branch": "main", "commit": "aba872ec78ffe7f7367764ab0fff6f0170421fde" }, "lightspeed.nvim": { "branch": "main", "commit": "299eefa6a9e2d881f1194587c573dad619fdb96f" }, "lsp-status.nvim": { "branch": "master", "commit": "54f48eb5017632d81d0fd40112065f1d062d0629" }, "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, @@ -37,14 +37,15 @@ "nvim-cmp": { "branch": "main", "commit": "d153771162bd9795d9f7142df5c674b61066a585" }, "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, "nvim-dap": { "branch": "master", "commit": "6cedcb527e264c8f25e86afa8dae74c6692dee51" }, - "nvim-dap-ui": { "branch": "master", "commit": "078972d39338a49ec13fc43a44e235cc43189276" }, + "nvim-dap-ui": { "branch": "master", "commit": "4ce7b97dd8f50b4f672948a34bf8f3a56214fdb8" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "ab988dbb7d20cdaebf9b3ef7554a89f6895de042" }, "nvim-lspconfig": { "branch": "master", "commit": "df58d91c9351a9dc5be6cf8d54f49ab0d9a64e73" }, "nvim-navic": { "branch": "master", "commit": "15704c607569d6c5cfeab486d3ef9459645a70ce" }, + "nvim-notify": { "branch": "master", "commit": "f3024b912073774111202f5fa6518b0cd2a74432" }, "nvim-spectre": { "branch": "master", "commit": "1abe23ec9b7bc3082164f4cb842d521ef70e080e" }, "nvim-surround": { "branch": "main", "commit": "219bd66585aa467b1c90fd01b54a2a423aaed4ab" }, - "nvim-tree.lua": { "branch": "master", "commit": "270c95556cad96d18ca547d86ae65927334b108b" }, - "nvim-treesitter": { "branch": "master", "commit": "ec0d0ffe51fab458a346b8a8d6f9d69490f3d7e1" }, + "nvim-tree.lua": { "branch": "master", "commit": "89816ace70642e9d3db0dab3dc68918f8979ec31" }, + "nvim-treesitter": { "branch": "master", "commit": "680807fa6a482c639119098bc48ca3831c66db13" }, "nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" }, "nvim-ts-rainbow2": { "branch": "master", "commit": "1ffe68cdd594633dfee0762feebfef81ed6f1fbb" }, "nvim-web-devicons": { "branch": "master", "commit": "986875b7364095d6535e28bd4aac3a9357e91bbe" }, @@ -66,7 +67,7 @@ "vim-astro": { "branch": "main", "commit": "34732be5e9a5c28c2409f4490edf92d46d8b55a9" }, "vim-dadbod": { "branch": "master", "commit": "3f57c0cd41523423fd781422dfc833820095a3e8" }, "vim-dadbod-completion": { "branch": "master", "commit": "fc7321a17f4c55db11fae89a884ddf4724020bae" }, - "vim-dadbod-ui": { "branch": "master", "commit": "4c306bef457ebfdbe71c76b49672d48ef310ddd3" }, + "vim-dadbod-ui": { "branch": "master", "commit": "5f6a11d80128e05fcc8e5d5025b8acf6d77faa99" }, "vim-fugitive": { "branch": "master", "commit": "5f0d280b517cacb16f59316659966c7ca5e2bea2" }, "vim-gnupg": { "branch": "main", "commit": "f9b608f29003dfde6450931dc0f495a912973a88" }, "vim-helm": { "branch": "master", "commit": "c2e7b85711d410e1d73e64eb5df7b70b1c4c10eb" }, diff --git a/home/apps/neovim/lua/plugins/alpha.lua b/home/apps/neovim/lua/plugins/alpha.lua index 543c1bb..7f2f767 100644 --- a/home/apps/neovim/lua/plugins/alpha.lua +++ b/home/apps/neovim/lua/plugins/alpha.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "goolord/alpha-nvim", diff --git a/home/apps/neovim/lua/plugins/auto-dark-mode.lua b/home/apps/neovim/lua/plugins/auto-dark-mode.lua index 8000a44..fa84b01 100644 --- a/home/apps/neovim/lua/plugins/auto-dark-mode.lua +++ b/home/apps/neovim/lua/plugins/auto-dark-mode.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "f-person/auto-dark-mode.nvim", diff --git a/home/apps/neovim/lua/plugins/auto-pairs.lua b/home/apps/neovim/lua/plugins/auto-pairs.lua index b8b7c13..2b2b160 100644 --- a/home/apps/neovim/lua/plugins/auto-pairs.lua +++ b/home/apps/neovim/lua/plugins/auto-pairs.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "windwp/nvim-autopairs", diff --git a/home/apps/neovim/lua/plugins/bufferline.lua b/home/apps/neovim/lua/plugins/bufferline.lua index c32c16a..88c80a4 100644 --- a/home/apps/neovim/lua/plugins/bufferline.lua +++ b/home/apps/neovim/lua/plugins/bufferline.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "akinsho/bufferline.nvim", diff --git a/home/apps/neovim/lua/plugins/catppuccin.lua b/home/apps/neovim/lua/plugins/catppuccin.lua index c810e27..77cd040 100644 --- a/home/apps/neovim/lua/plugins/catppuccin.lua +++ b/home/apps/neovim/lua/plugins/catppuccin.lua @@ -1,3 +1,4 @@ +---@type LazySpec[] return { { "catppuccin/nvim", @@ -50,6 +51,7 @@ return { symbols_outline = true, ts_rainbow = true, vimwiki = true, + notify = true, }, highlight_overrides = { all = function(colors) diff --git a/home/apps/neovim/lua/plugins/colorizer.lua b/home/apps/neovim/lua/plugins/colorizer.lua index 187d280..89e4a77 100644 --- a/home/apps/neovim/lua/plugins/colorizer.lua +++ b/home/apps/neovim/lua/plugins/colorizer.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "nvchad/nvim-colorizer.lua", diff --git a/home/apps/neovim/lua/plugins/copilot.lua b/home/apps/neovim/lua/plugins/copilot.lua index 56c3082..99de57a 100644 --- a/home/apps/neovim/lua/plugins/copilot.lua +++ b/home/apps/neovim/lua/plugins/copilot.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "zbirenbaum/copilot.lua", diff --git a/home/apps/neovim/lua/plugins/databases.lua b/home/apps/neovim/lua/plugins/databases.lua index 2a217e2..327ee80 100644 --- a/home/apps/neovim/lua/plugins/databases.lua +++ b/home/apps/neovim/lua/plugins/databases.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { "tpope/vim-dadbod", "kristijanhusak/vim-dadbod-completion", diff --git a/home/apps/neovim/lua/plugins/editor.lua b/home/apps/neovim/lua/plugins/editor.lua index e0d3a9e..0810f50 100644 --- a/home/apps/neovim/lua/plugins/editor.lua +++ b/home/apps/neovim/lua/plugins/editor.lua @@ -1,6 +1,5 @@ +---@type LazyPluginSpec[] return { - -- TODO: remove in nvim 0.9 because of upstream merge - "luukvbaal/stabilize.nvim", -- zen mode "pocco81/true-zen.nvim", -- respect project settings diff --git a/home/apps/neovim/lua/plugins/fidget.lua b/home/apps/neovim/lua/plugins/fidget.lua index 9c1c188..912468a 100644 --- a/home/apps/neovim/lua/plugins/fidget.lua +++ b/home/apps/neovim/lua/plugins/fidget.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "j-hui/fidget.nvim", diff --git a/home/apps/neovim/lua/plugins/git.lua b/home/apps/neovim/lua/plugins/git.lua index 4371dcd..27efaab 100644 --- a/home/apps/neovim/lua/plugins/git.lua +++ b/home/apps/neovim/lua/plugins/git.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { "tpope/vim-fugitive", { @@ -25,7 +26,7 @@ return { local gs = require("gitsigns") gs.setup({ - on_attach = function(bufnr) + on_attach = function(_) -- Gitsigns wk.register({ ["h"] = { @@ -98,67 +99,8 @@ return { ["ih"] = { ":Gitsigns select_hunk", "Select inside Hunk" }, }, { mode = { "o", "x" } }) end, - signs = { - add = { - hl = "GitSignsAdd", - text = "+", - numhl = "GitSignsAddNr", - linehl = "GitSignsAddLn", - }, - change = { - hl = "GitSignsChange", - text = "~", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - delete = { - hl = "GitSignsDelete", - text = "_", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - topdelete = { - hl = "GitSignsDelete", - text = "‾", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - changedelete = { - hl = "GitSignsChange", - text = "x", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - }, - linehl = false, - numhl = false, - signcolumn = true, - word_diff = false, - watch_gitdir = { enable = false, interval = 1000, follow_files = true }, - attach_to_untracked = true, - -- current line highlighting - current_line_blame = false, - current_line_blame_opts = { - delay = 1000, - ignore_whitespace = true, - virt_text = true, - virt_text_pos = "eol", - }, + current_line_blame = true, current_line_blame_formatter = ", - | ", - -- perf - max_file_length = 40000, - sign_priority = 6, - update_debounce = 100, - -- use the included status formatter - status_formatter = nil, - preview_config = { - border = "single", - style = "minimal", - relative = "cursor", - row = 0, - col = 1, - }, - yadm = { enable = false }, }) end, }, diff --git a/home/apps/neovim/lua/plugins/indent-blankline.lua b/home/apps/neovim/lua/plugins/indent-blankline.lua index 90f3d4d..0a477ed 100644 --- a/home/apps/neovim/lua/plugins/indent-blankline.lua +++ b/home/apps/neovim/lua/plugins/indent-blankline.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "lukas-reineke/indent-blankline.nvim", diff --git a/home/apps/neovim/lua/plugins/lsp.lua b/home/apps/neovim/lua/plugins/lsp.lua index b87027e..223bb89 100644 --- a/home/apps/neovim/lua/plugins/lsp.lua +++ b/home/apps/neovim/lua/plugins/lsp.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "neovim/nvim-lspconfig", diff --git a/home/apps/neovim/lua/plugins/lualine.lua b/home/apps/neovim/lua/plugins/lualine.lua index a193dcf..d530b32 100644 --- a/home/apps/neovim/lua/plugins/lualine.lua +++ b/home/apps/neovim/lua/plugins/lualine.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "nvim-lualine/lualine.nvim", diff --git a/home/apps/neovim/lua/plugins/natural-language.lua b/home/apps/neovim/lua/plugins/natural-language.lua index 5722213..c999d36 100644 --- a/home/apps/neovim/lua/plugins/natural-language.lua +++ b/home/apps/neovim/lua/plugins/natural-language.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "dhruvasagar/vim-table-mode", diff --git a/home/apps/neovim/lua/plugins/neorg.lua b/home/apps/neovim/lua/plugins/neorg.lua index 011fbb6..5e3b3d1 100644 --- a/home/apps/neovim/lua/plugins/neorg.lua +++ b/home/apps/neovim/lua/plugins/neorg.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "nvim-neorg/neorg", diff --git a/home/apps/neovim/lua/plugins/notify.lua b/home/apps/neovim/lua/plugins/notify.lua new file mode 100644 index 0000000..8e1f81f --- /dev/null +++ b/home/apps/neovim/lua/plugins/notify.lua @@ -0,0 +1,25 @@ +---@type LazyPluginSpec[] +return { + { + "rcarriga/nvim-notify", + config = function() + local notify = require("notify") + local stages = require("notify.stages.static")("top_down") + notify.setup({ + background_colour = "#000000", + delay = 5000, + stages = { + function(...) + local opts = stages[1](...) + if opts then + opts.border = "double" + end + return opts + end, + unpack(stages, 2), + }, + }) + vim.notify = notify + end, + }, +} diff --git a/home/apps/neovim/lua/plugins/nvim-tree.lua b/home/apps/neovim/lua/plugins/nvim-tree.lua index f3fa98f..902163e 100644 --- a/home/apps/neovim/lua/plugins/nvim-tree.lua +++ b/home/apps/neovim/lua/plugins/nvim-tree.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "nvim-tree/nvim-tree.lua", diff --git a/home/apps/neovim/lua/plugins/presence.lua b/home/apps/neovim/lua/plugins/presence.lua index 63d60de..7f39513 100644 --- a/home/apps/neovim/lua/plugins/presence.lua +++ b/home/apps/neovim/lua/plugins/presence.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "andweeb/presence.nvim", @@ -5,7 +6,7 @@ return { config = function() local presence = require("presence") - function string.starts(self, str) + local function starts_with(self, str) return self:find("^" .. str) ~= nil end @@ -22,7 +23,7 @@ return { local conceal = function(activity, info) local cur_file = vim.fn.expand("%:p") for k, v in pairs(blacklist) do - if cur_file:starts(k) then + if starts_with(cur_file, k) then return v end end @@ -42,7 +43,7 @@ return { -- Main image display (either "neovim" or "file") main_image = "file", show_time = false, - buttons = function(buffer, repo_url) + buttons = function(_, repo_url) local concealed = conceal() if concealed then return { diff --git a/home/apps/neovim/lua/plugins/spectre.lua b/home/apps/neovim/lua/plugins/spectre.lua index c21d10f..f8f8e9c 100644 --- a/home/apps/neovim/lua/plugins/spectre.lua +++ b/home/apps/neovim/lua/plugins/spectre.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "nvim-pack/nvim-spectre", diff --git a/home/apps/neovim/lua/plugins/telescope.lua b/home/apps/neovim/lua/plugins/telescope.lua index bcb7447..c6cd93a 100644 --- a/home/apps/neovim/lua/plugins/telescope.lua +++ b/home/apps/neovim/lua/plugins/telescope.lua @@ -1,3 +1,4 @@ +---@type LazySpec[] return { { { @@ -9,6 +10,7 @@ return { pcall(telescope.load_extension, "asynctasks") pcall(telescope.load_extension, "file_browser") pcall(telescope.load_extension, "project") + pcall(telescope.load_extension, "notify") telescope.setup({ defaults = { @@ -25,6 +27,10 @@ return { }, }, extensions = { + file_browser = { + grouped = true, + sorting_strategy = "ascending", + }, fzf = { fuzzy = true, override_generic_sorter = true, diff --git a/home/apps/neovim/lua/plugins/tree-sitter.lua b/home/apps/neovim/lua/plugins/tree-sitter.lua index 099b061..94413c1 100644 --- a/home/apps/neovim/lua/plugins/tree-sitter.lua +++ b/home/apps/neovim/lua/plugins/tree-sitter.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "nvim-treesitter/nvim-treesitter", diff --git a/home/apps/neovim/lua/plugins/which-key.lua b/home/apps/neovim/lua/plugins/which-key.lua index 7853da2..73a6af7 100644 --- a/home/apps/neovim/lua/plugins/which-key.lua +++ b/home/apps/neovim/lua/plugins/which-key.lua @@ -1,3 +1,4 @@ +---@type LazyPluginSpec[] return { { "folke/which-key.nvim", @@ -22,12 +23,13 @@ return { wk.register({ ["f"] = { name = "+Telescope", - b = { "Telescope buffers", "File Browser" }, - d = { "Telescope find_files", "Find File" }, - g = { "Telescope live_grep", "Live Grep" }, - h = { "Telescope help_tags", "Help Tags" }, + b = { "Telescope file_browser grouped=true", "File browser" }, + d = { "Telescope find_files", "Find file" }, + g = { "Telescope live_grep", "Live grep" }, + h = { "Telescope help_tags", "Help tags" }, + n = { "Telescope notify", "Show notifications" }, p = { "Telescope project", "Project" }, - r = { "Telescope asynctasks all", "Run Asynctasks" }, + r = { "Telescope asynctasks all", "Run asynctasks" }, s = { function() local confpath = vim.fn.resolve(vim.fn.stdpath("config")) @@ -44,9 +46,8 @@ return { y = { '"+y', "Copy to clipboard" }, p = { '"+p', "Paste from clipboard" }, db = { "DBUIToggle", "Toggle DBUI" }, - gd = { "Gvdiff!", "Git Diff" }, + gd = { "Gvdiff!", "Git diff" }, ng = { "Neogit", "Neogit" }, - sl = { "SessionLoad", "Load Session" }, }, }, { mode = { "n", "v" } }) end,