diff --git a/after/lsp/clangd.lua b/after/lsp/clangd.lua index c5041ed..9edfb9e 100644 --- a/after/lsp/clangd.lua +++ b/after/lsp/clangd.lua @@ -21,9 +21,9 @@ return { "clang-tidy", "--quiet", "--checks=-*," - .. "clang-analyzer-*," - .. "-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling," - .. "-clang-analyzer-security.insecureAPI.strcpy", + .. "clang-analyzer-*," + .. "-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling," + .. "-clang-analyzer-security.insecureAPI.strcpy", "%file%", }, events = { "BufWritePost" }, diff --git a/after/lsp/oxlint.lua b/after/lsp/oxlint.lua index 19bb2fd..0dca34d 100644 --- a/after/lsp/oxlint.lua +++ b/after/lsp/oxlint.lua @@ -1,3 +1,2 @@ ---@type vim.lsp.Config -return { -} +return {} diff --git a/after/lsp/svelte.lua b/after/lsp/svelte.lua index 15f8961..0dca34d 100644 --- a/after/lsp/svelte.lua +++ b/after/lsp/svelte.lua @@ -1,4 +1,2 @@ ---@type vim.lsp.Config -return { -} - +return {} diff --git a/after/lsp/tailwindcss.lua b/after/lsp/tailwindcss.lua index 15f8961..0dca34d 100644 --- a/after/lsp/tailwindcss.lua +++ b/after/lsp/tailwindcss.lua @@ -1,4 +1,2 @@ ---@type vim.lsp.Config -return { -} - +return {} diff --git a/after/lsp/tsgo.lua b/after/lsp/tsgo.lua index 19bb2fd..0dca34d 100644 --- a/after/lsp/tsgo.lua +++ b/after/lsp/tsgo.lua @@ -1,3 +1,2 @@ ---@type vim.lsp.Config -return { -} +return {} diff --git a/init.lua b/init.lua index b2f5189..c874d6a 100644 --- a/init.lua +++ b/init.lua @@ -96,7 +96,7 @@ require("pack").setup({ { "https://github.com/tree-sitter/tree-sitter-php", ts_parser = { - { lang = "php", location = "php" }, + { lang = "php", location = "php" }, { lang = "php_only", location = "php_only" }, }, }, @@ -125,7 +125,7 @@ require("pack").setup({ "https://github.com/tree-sitter/tree-sitter-typescript", ts_parser = { { lang = "typescript", location = "typescript" }, - { lang = "tsx", location = "tsx" }, + { lang = "tsx", location = "tsx" }, }, }, { @@ -157,9 +157,9 @@ ts.setup({ "gotmpl", "html", "json", - "lua", -- builtin + "lua", -- builtin "luadoc", - "markdown", -- builtin + "markdown", -- builtin "markdown_inline", -- builtin "php", "python", @@ -170,10 +170,10 @@ ts.setup({ "svelte", "tsx", "typescript", - "vim", -- builtin + "vim", -- builtin "vimdoc", -- builtin "xml", "yaml", "zsh", - } + }, }) diff --git a/lua/core/autocommands.lua b/lua/core/autocommands.lua index 5b8acf9..e2bd502 100644 --- a/lua/core/autocommands.lua +++ b/lua/core/autocommands.lua @@ -70,27 +70,27 @@ vim.api.nvim_create_autocmd("FileType", { pattern = { "c" }, callback = function() vim.o.errorformat = "%-Gmake: *** [Makefile:," - .. "%-Gg%\\?make[%*\\d]: *** [%f:%l:%m," - .. "%-Gg%\\?make: *** [%f:%l:%m," - .. "%-G%f:%l: (Each undeclared identifier is reported only once," - .. "%-G%f:%l: for each function it appears in.)," - .. "%-GIn file included from %f:%l:%c:," - .. "%-GIn file included from %f:%l:%c\\,," - .. "%-GIn file included from %f:%l:%c," - .. "%-GIn file included from %f:%l," - .. "%-G%*[ ]from %f:%l:%c," - .. "%-G%*[ ]from %f:%l:," - .. "%-G%*[ ]from %f:%l\\,," - .. "%-G%*[ ]from %f:%l," - .. "%-G%f:%l:%c: note: '%*[^']' declared here," - .. "%D%*\\a[%*\\d]: Entering directory %*[`']%f'," - .. "%X%*\\a[%*\\d]: Leaving directory %*[`']%f'," - .. "%D%*\\a: Entering directory %*[`']%f'," - .. "%X%*\\a: Leaving directory %*[`']%f'," - .. "%DMaking %*\\a in %f," - .. "%f:%l:%c: %t%*[^:]: %m," - .. "%*[^:]: %f:%l: %m," - .. "%-G%.%#" + .. "%-Gg%\\?make[%*\\d]: *** [%f:%l:%m," + .. "%-Gg%\\?make: *** [%f:%l:%m," + .. "%-G%f:%l: (Each undeclared identifier is reported only once," + .. "%-G%f:%l: for each function it appears in.)," + .. "%-GIn file included from %f:%l:%c:," + .. "%-GIn file included from %f:%l:%c\\,," + .. "%-GIn file included from %f:%l:%c," + .. "%-GIn file included from %f:%l," + .. "%-G%*[ ]from %f:%l:%c," + .. "%-G%*[ ]from %f:%l:," + .. "%-G%*[ ]from %f:%l\\,," + .. "%-G%*[ ]from %f:%l," + .. "%-G%f:%l:%c: note: '%*[^']' declared here," + .. "%D%*\\a[%*\\d]: Entering directory %*[`']%f'," + .. "%X%*\\a[%*\\d]: Leaving directory %*[`']%f'," + .. "%D%*\\a: Entering directory %*[`']%f'," + .. "%X%*\\a: Leaving directory %*[`']%f'," + .. "%DMaking %*\\a in %f," + .. "%f:%l:%c: %t%*[^:]: %m," + .. "%*[^:]: %f:%l: %m," + .. "%-G%.%#" end, }) @@ -105,15 +105,15 @@ vim.api.nvim_create_autocmd("FileType", { pattern = { "rust" }, callback = function() vim.bo.errorformat = "%Enote: test %m at %f:%l:%c," - .. "%E%\\%%(%.%#panicked%\\)%\\@=%m at %f:%l:%c:," - .. "%-Gerror: test failed\\, %.%#," - .. "%-G%*[^:]: %.%# generated %*\\d %.%#," - .. "%-Gnote: run with `RUST_BACKTRACE=%.%#," - .. "%-G%\\s%#Running%.%#," - .. vim.bo.errorformat:gsub( - "%%E left:%%m,%%C right:%%m %%f:%%l:%%c,", - "" - ) + .. "%E%\\%%(%.%#panicked%\\)%\\@=%m at %f:%l:%c:," + .. "%-Gerror: test failed\\, %.%#," + .. "%-G%*[^:]: %.%# generated %*\\d %.%#," + .. "%-Gnote: run with `RUST_BACKTRACE=%.%#," + .. "%-G%\\s%#Running%.%#," + .. vim.bo.errorformat:gsub( + "%%E left:%%m,%%C right:%%m %%f:%%l:%%c,", + "" + ) end, }) diff --git a/lua/linter.lua b/lua/linter.lua index 6d14cef..409a119 100644 --- a/lua/linter.lua +++ b/lua/linter.lua @@ -246,10 +246,17 @@ function Linter.validate(config) vim.validate("config", config, "table") vim.validate("cmd", config.cmd, list_of("string"), "list of strings") vim.validate( - "events", config.events, list_of("string"), true, "list of strings" + "events", + config.events, + list_of("string"), + true, + "list of strings" ) vim.validate( - "clear_events", config.clear_events, list_of("string"), true, + "clear_events", + config.clear_events, + list_of("string"), + true, "list of strings" ) vim.validate("stdin", config.stdin, "boolean", true) @@ -257,12 +264,15 @@ function Linter.validate(config) vim.validate("stderr", config.stderr, "boolean", true) vim.validate("pattern", config.pattern, "string", true) vim.validate( - "groups", config.groups, list_of("string"), true, "list of strings" + "groups", + config.groups, + list_of("string"), + true, + "list of strings" ) vim.validate("severity_map", config.severity_map, function(t) return util.is_map(t, "string", "number") - end, true, "map of string to number" - ) + end, true, "map of string to number") vim.validate("debounce", config.debounce, "number", true) vim.validate("source", config.source, "string", true) vim.validate("json", config.json, "table", true) @@ -430,7 +440,9 @@ function Linter.add(bufnr, config) end, config.debounce) vim.api.nvim_create_autocmd(config.events, { buffer = linter.bufnr, - callback = function() debouncer:call() end, + callback = function() + debouncer:call() + end, group = linter.augroup, }) diff --git a/lua/plugins/blink.lua b/lua/plugins/blink.lua index 45a65ca..fe6efb6 100644 --- a/lua/plugins/blink.lua +++ b/lua/plugins/blink.lua @@ -21,7 +21,7 @@ require("blink.cmp").setup({ align_to = "simple_label", columns = { { "simple_label" }, - { "kind_icon", "label_description", gap = 1 }, + { "kind_icon", "label_description", gap = 1 }, }, components = { simple_label = { @@ -35,7 +35,7 @@ require("blink.cmp").setup({ 0, #ctx.label, group = ctx.deprecated - and "BlinkCmpLabelDeprecated" + and "BlinkCmpLabelDeprecated" or "BlinkCmpLabel", }, } diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index 2114452..f936be9 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -4,12 +4,7 @@ require("gitsigns").setup({ }, on_attach = function(bufnr) local gs = require("gitsigns") - vim.keymap.set( - "n", - "gv", - gs.select_hunk, - { buffer = bufnr } - ) + vim.keymap.set("n", "gv", gs.select_hunk, { buffer = bufnr }) vim.keymap.set("n", "gs", gs.stage_hunk, { buffer = bufnr }) vim.keymap.set("x", "gs", function() gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) @@ -21,12 +16,7 @@ require("gitsigns").setup({ ":Gitsigns reset_hunk", { buffer = bufnr } ) - vim.keymap.set( - "n", - "g?", - gs.preview_hunk, - { buffer = bufnr } - ) + vim.keymap.set("n", "g?", gs.preview_hunk, { buffer = bufnr }) vim.keymap.set("n", "gb", function() gs.blame_line({ full = true, ignore_whitespace = true }) end, { buffer = bufnr }) diff --git a/lua/plugins/nvim-dap.lua b/lua/plugins/nvim-dap.lua index a01efab..d94b621 100644 --- a/lua/plugins/nvim-dap.lua +++ b/lua/plugins/nvim-dap.lua @@ -1,5 +1,5 @@ -local log = require("log") local dap = require("dap") +local log = require("log") vim.api.nvim_set_hl(0, "DebugPC", { bg = "NONE", @@ -149,4 +149,3 @@ vim.keymap.set("n", "", dap.step_over) vim.keymap.set("n", "", dap.step_out) vim.keymap.set("n", "", dap.continue) vim.keymap.set("n", "", dap.terminate) - diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index d43b9de..c803ff2 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -35,7 +35,7 @@ local function disable_highlights() end vim.keymap.set("n", "tt", function() - require("nvim-tree.api").tree.toggle({ find_file = true, focus = false, }) + require("nvim-tree.api").tree.toggle({ find_file = true, focus = false }) end) ---@class nvim_tree.api.decorator.UserDecorator diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua index 9f39a00..57cecb0 100644 --- a/lua/plugins/nvim-treesitter.lua +++ b/lua/plugins/nvim-treesitter.lua @@ -30,7 +30,7 @@ local languages = { local ts = require("nvim-treesitter") ts.setup({ - install_dir = string.format("%s/nvim-treesitter", vim.fn.stdpath("data")) + install_dir = string.format("%s/nvim-treesitter", vim.fn.stdpath("data")), }) ts.install(languages):await(function(err) if err then @@ -62,6 +62,5 @@ ts.install(languages):await(function(err) vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" end, }) - end - ) + end) end) diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index 008a549..48fdc15 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -30,4 +30,6 @@ require("oil").setup({ }, }) -vim.keymap.set("n", "fe", function() vim.cmd.Oil("--float") end) +vim.keymap.set("n", "fe", function() + vim.cmd.Oil("--float") +end) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 673ce4a..3923bc1 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,6 +1,6 @@ -local telescope = require("telescope") -local builtin = require("telescope.builtin") local actions = require("telescope.actions") +local builtin = require("telescope.builtin") +local telescope = require("telescope") local utils = require("telescope.utils") telescope.setup({ diff --git a/lua/plugins/vim-fugitive.lua b/lua/plugins/vim-fugitive.lua index 81a061d..3fb83f3 100644 --- a/lua/plugins/vim-fugitive.lua +++ b/lua/plugins/vim-fugitive.lua @@ -42,12 +42,22 @@ end, { nargs = "*", desc = "Pretty git log via fugitive" }) vim.keymap.set("n", "gl", vim.cmd.Glog) vim.keymap.set("n", "gd", vim.cmd.Gvdiffsplit) -vim.keymap.set("n", "gD", function() vim.cmd.Gvdiffsplit("HEAD") end) +vim.keymap.set("n", "gD", function() + vim.cmd.Gvdiffsplit("HEAD") +end) vim.keymap.set("n", "gh", vim.cmd.Ghdiffsplit) -vim.keymap.set("n", "gH", function() vim.cmd.Ghdiffsplit("HEAD") end) -vim.keymap.set("n", "gc", function() vim.cmd.G("commit") end) -vim.keymap.set("n", "ga", function() vim.cmd.G("commit --amend") end) -vim.keymap.set("n", "gp", function() vim.cmd.G("push") end) +vim.keymap.set("n", "gH", function() + vim.cmd.Ghdiffsplit("HEAD") +end) +vim.keymap.set("n", "gc", function() + vim.cmd.G("commit") +end) +vim.keymap.set("n", "ga", function() + vim.cmd.G("commit --amend") +end) +vim.keymap.set("n", "gp", function() + vim.cmd.G("push") +end) vim.keymap.set("n", "gg", toggle_git_status) vim.api.nvim_create_autocmd("User", { diff --git a/lua/ts.lua b/lua/ts.lua index 060136c..be9adf7 100644 --- a/lua/ts.lua +++ b/lua/ts.lua @@ -21,11 +21,7 @@ end local function start_treesitter(buf) local ok, err = pcall(vim.treesitter.start, buf) if not ok then - log.error( - "Failed to enable treesitter for buffer %d: %s", - buf, - err - ) + log.error("Failed to enable treesitter for buffer %d: %s", buf, err) return end for _, win in ipairs(vim.fn.win_findbuf(buf)) do @@ -38,7 +34,8 @@ end local function activate_open_buffers(lang) local fts = vim.treesitter.language.get_filetypes(lang) for _, buf in ipairs(vim.api.nvim_list_bufs()) do - if vim.api.nvim_buf_is_loaded(buf) + if + vim.api.nvim_buf_is_loaded(buf) and vim.list_contains(fts, vim.bo[buf].filetype) then start_treesitter(buf) @@ -49,8 +46,7 @@ end ---@param plugin ow.Pack.Plugin ---@param spec ow.TS.ParserSpec function M.build(plugin, spec) - local cwd = spec.location - and vim.fs.joinpath(plugin.path, spec.location) + local cwd = spec.location and vim.fs.joinpath(plugin.path, spec.location) or plugin.path local out = parser_path(plugin, spec.lang) vim.fn.mkdir(vim.fs.dirname(out), "p") @@ -78,26 +74,32 @@ function M.build(plugin, spec) if spec.generate then local cmd = { - "tree-sitter", "generate", - "--abi", tostring(vim.treesitter.language_version), + "tree-sitter", + "generate", + "--abi", + tostring(vim.treesitter.language_version), } if spec.from_json ~= false then table.insert(cmd, "src/grammar.json") end - vim.system(cmd, { - cwd = cwd, - env = { TREE_SITTER_JS_RUNTIME = "native" }, - }, vim.schedule_wrap(function(r) - if r.code ~= 0 then - log.error( - "Failed to generate parser for %s: %s", - spec.lang, - r.stderr or "" - ) - return - end - do_build() - end)) + vim.system( + cmd, + { + cwd = cwd, + env = { TREE_SITTER_JS_RUNTIME = "native" }, + }, + vim.schedule_wrap(function(r) + if r.code ~= 0 then + log.error( + "Failed to generate parser for %s: %s", + spec.lang, + r.stderr or "" + ) + return + end + do_build() + end) + ) else do_build() end