From 83aaa5aef34962d7b522a65ce4598cc22060f4af Mon Sep 17 00:00:00 2001 From: Squibid Date: Sat, 22 Nov 2025 17:22:23 -0500 Subject: [PATCH] not quite sure what I've done here --- after/ftplugin/java.lua | 2 +- after/lsp/lua_ls.lua | 2 +- lua/conf/autos.lua | 8 +- lua/conf/binds.lua | 50 +++--- lua/conf/plugins/lsp.lua | 2 +- lua/conf/plugins/luasnip.lua | 80 ++++----- lua/conf/plugins/mellow.lua | 42 ++--- lua/conf/plugins/oil.lua | 22 +-- lua/conf/plugins/opencode.lua | 16 +- lua/conf/plugins/telescope.lua | 122 +++++++------- lua/conf/plugins/treesitter.lua | 12 +- lua/core/color.lua | 8 +- lua/core/lsp/binds.lua | 54 +++--- lua/core/lsp/completion.lua | 284 ++++++++++++++++---------------- lua/core/lsp/init.lua | 6 +- lua/core/lsp/wtf.lua | 32 ++-- lua/core/misc.lua | 26 +-- lua/snippets/lua.lua | 16 +- 18 files changed, 392 insertions(+), 392 deletions(-) diff --git a/after/ftplugin/java.lua b/after/ftplugin/java.lua index 4d98ca8..72d42a1 100644 --- a/after/ftplugin/java.lua +++ b/after/ftplugin/java.lua @@ -13,7 +13,7 @@ local java_dap_install = core.mason.get_pkg_path("java-debug-adapter") -- make sure to check if things with 💀 need updating local config = { cmd = { - "/usr/lib/jvm/openjdk21/bin/java", -- 💀 + "java", -- 💀 "-jar", vim.fn.glob(vim.fs.joinpath(jdtls_install, "plugins/org.eclipse.equinox.launcher_*.jar")), "-configuration", jdtls_install.."config_linux", diff --git a/after/lsp/lua_ls.lua b/after/lsp/lua_ls.lua index 00bfe12..1412197 100644 --- a/after/lsp/lua_ls.lua +++ b/after/lsp/lua_ls.lua @@ -14,7 +14,7 @@ return { checkThirdParty = "ApplyInMemory", library = { vim.env.VIMRUNTIME, - "${3rd}/luv/library" + "${3rd}/luv/library" } } } diff --git a/lua/conf/autos.lua b/lua/conf/autos.lua index c501dca..9682671 100644 --- a/lua/conf/autos.lua +++ b/lua/conf/autos.lua @@ -31,10 +31,10 @@ auto("BufWritePre", { }) auto({ "BufEnter", "CursorMoved", "CursorMovedI" }, { - group = bufcheck, - callback = function() - core.todo.todo_comments() - end + group = bufcheck, + callback = function() + core.todo.todo_comments() + end }) core.color.setup_termbg_sync() diff --git a/lua/conf/binds.lua b/lua/conf/binds.lua index b41b7ae..89eaa47 100644 --- a/lua/conf/binds.lua +++ b/lua/conf/binds.lua @@ -3,9 +3,9 @@ local map, lz = core.misc.map, core.misc.lz --- feed keys as userinput ---@param keys string keys local function feedkeys(keys) - vim.api.nvim_feedkeys( - vim.api.nvim_replace_termcodes(keys, true, false, true), - "n", true) + vim.api.nvim_feedkeys( + vim.api.nvim_replace_termcodes(keys, true, false, true), + "n", true) end -- vim binds @@ -27,27 +27,27 @@ map("n", "", lz "zz") -- trigger completion menu -- (stolen from https://gist.github.com/MariaSolOs/2e44a86f569323c478e5a078d0cf98cc) map("i", "", function() - -- if the completion menu is already visible just go to the next item - if vim.fn.pumvisible() ~= 0 then - feedkeys("") - else - if #vim.lsp.get_clients({ bufnr = 0 }) > 0 then - vim.lsp.completion.get() - else - if vim.bo.omnifunc == "" then - feedkeys("") - else - feedkeys("") - end - end - end + -- if the completion menu is already visible just go to the next item + if vim.fn.pumvisible() ~= 0 then + feedkeys("") + else + if #vim.lsp.get_clients({ bufnr = 0 }) > 0 then + vim.lsp.completion.get() + else + if vim.bo.omnifunc == "" then + feedkeys("") + else + feedkeys("") + end + end + end end, { desc = "Trigger/select next completion" }) map("i", "", function() - if vim.fn.pumvisible() ~= 0 then - feedkeys("") - else - feedkeys("") - end + if vim.fn.pumvisible() ~= 0 then + feedkeys("") + else + feedkeys("") + end end, { desc = "prevent omnifunc from completing on " }) map("i", "", "", { desc = "Trigger spell completion" }) map("n", "", lz "se spellease nospell", { desc = "Trigger spell completion" }) @@ -57,9 +57,9 @@ map("n", "", lz "cnextzz", { desc = "qf next" }) map("n", "", lz "cprevzz", { desc = "qf prev" }) map("n", "", "cclose", { desc = "qf close" }) map("n", "", lz(function() - local win = vim.api.nvim_get_current_win() - vim.cmd.cope() - vim.api.nvim_set_current_win(win) + local win = vim.api.nvim_get_current_win() + vim.cmd.cope() + vim.api.nvim_set_current_win(win) end), { desc = "qf open" }) -- man pages diff --git a/lua/conf/plugins/lsp.lua b/lua/conf/plugins/lsp.lua index cd44554..128d1f1 100644 --- a/lua/conf/plugins/lsp.lua +++ b/lua/conf/plugins/lsp.lua @@ -24,7 +24,7 @@ return { load = function() require("mason").setup { ui = { - -- not sure why these are nerdfont icons by default + -- not sure why these are nerdfont icons by default icons = { package_installed = "+", package_pending = "?", diff --git a/lua/conf/plugins/luasnip.lua b/lua/conf/plugins/luasnip.lua index 56491c7..0452b58 100644 --- a/lua/conf/plugins/luasnip.lua +++ b/lua/conf/plugins/luasnip.lua @@ -1,49 +1,49 @@ local map = core.misc.map return { "L3MON4D3/LuaSnip", - branch = "v2.*", - config = function() - vim.cmd("make install_jsregexp") - end, - lazy = function(load) - load:keymap({"i", "s"}, "") - load:keymap({"i", "s"}, "") - load:keymap({"i", "s"}, "") - load:keymap({"i", "s"}, "") - load:auto("InsertEnter") - end, - load = function() - local ls = require("luasnip") + branch = "v2.*", + config = function() + vim.cmd("make install_jsregexp") + end, + lazy = function(load) + load:keymap({"i", "s"}, "") + load:keymap({"i", "s"}, "") + load:keymap({"i", "s"}, "") + load:keymap({"i", "s"}, "") + load:auto("InsertEnter") + end, + load = function() + local ls = require("luasnip") - -- replace the builtin snippet handler with luasnip so I get all my fancy - -- stuff - vim.snippet.expand = ls.lsp_expand + -- replace the builtin snippet handler with luasnip so I get all my fancy + -- stuff + vim.snippet.expand = ls.lsp_expand - ls.config.setup { - keep_roots = true, - link_roots = true, - link_children = true, - exit_roots = not true - } + ls.config.setup { + keep_roots = true, + link_roots = true, + link_children = true, + exit_roots = not true + } - map({"i", "s"}, "", ls.expand) - map({"i", "s"}, "", function() ls.jump(1) end) - map({"i", "s"}, "", function() ls.jump(-1) end) - map({"i", "s"}, "", function() - if ls.choice_active() then - ls.change_choice(1) - end - end) + map({"i", "s"}, "", ls.expand) + map({"i", "s"}, "", function() ls.jump(1) end) + map({"i", "s"}, "", function() ls.jump(-1) end) + map({"i", "s"}, "", function() + if ls.choice_active() then + ls.change_choice(1) + end + end) - -- collect all snippets and add them - for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua", - true)) do - local fn = file:gsub("^.*/", ""):gsub("%.lua$", "") + -- collect all snippets and add them + for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua", + true)) do + local fn = file:gsub("^.*/", ""):gsub("%.lua$", "") - local ret = require("snippets."..fn) - if type(ret) ~= "boolean" then - ls.add_snippets(fn, ret, { key = fn }) - end - end - end + local ret = require("snippets."..fn) + if type(ret) ~= "boolean" then + ls.add_snippets(fn, ret, { key = fn }) + end + end + end } diff --git a/lua/conf/plugins/mellow.lua b/lua/conf/plugins/mellow.lua index fda4ec9..3bec316 100644 --- a/lua/conf/plugins/mellow.lua +++ b/lua/conf/plugins/mellow.lua @@ -20,14 +20,14 @@ return { "mellow-theme/mellow.nvim", ["NormalFloat"] = { fg = c.fg, bg = "#111111" }, ["FloatBorder"] = { bg = "#111111" }, - -- Make pmenu look good - ["Pmenu"] = { link = "NormalFloat" }, - ["PmenuSel"] = { link = "Normal" }, - ["PmenuKind"] = { link = "@constant" }, - ["PmenuKindSel"] = { - fg = core.color.copyhl("Comment").fg, - bold = true - }, + -- Make pmenu look good + ["Pmenu"] = { link = "NormalFloat" }, + ["PmenuSel"] = { link = "Normal" }, + ["PmenuKind"] = { link = "@constant" }, + ["PmenuKindSel"] = { + fg = core.color.copyhl("Comment").fg, + bold = true + }, -- make diagnostics have an undercurl ["DiagnosticUnderlineError"] = { fg = c.red, undercurl = true }, @@ -43,19 +43,19 @@ return { "mellow-theme/mellow.nvim", ["TelescopePreviewNormal"] = { link = "NormalFloat" }, ["TelescopePreviewBorder"] = { link = "TelescopePreviewNormal" }, - -- add highlight groups for my todo highlighting - ["TodoTODO"] = { link = "DiagnosticHint" }, - ["TodoTODOBG"] = { fg = c.bg, bg = c.cyan, bold = true }, - ["TodoTODOSIGN"] = { fg = c.cyan, bg = c.cyan, bold = true }, - ["TodoBUG"] = { link = "DiagnosticError" }, - ["TodoBUGBG"] = { fg = c.bg, bg = c.red, bold = true }, - ["TodoBUGSIGN"] = { fg = c.red, bg = c.red, bold = true }, - ["TodoTEST"] = { link = "DiagnosticInfo" }, - ["TodoTESTBG"] = { fg = c.bg, bg = c.blue, bold = true }, - ["TodoTESTSIGN"] = { fg = c.blue, bg = c.blue, bold = true }, - ["TodoWARN"] = { link = "DiagnosticWarn" }, - ["TodoWARNBG"] = { fg = c.bg, bg = c.yellow, bold = true }, - ["TodoWARNSIGN"] = { fg = c.yellow, bg = c.yellow, bold = true }, + -- add highlight groups for my todo highlighting + ["TodoTODO"] = { link = "DiagnosticHint" }, + ["TodoTODOBG"] = { fg = c.bg, bg = c.cyan, bold = true }, + ["TodoTODOSIGN"] = { fg = c.cyan, bg = c.cyan, bold = true }, + ["TodoBUG"] = { link = "DiagnosticError" }, + ["TodoBUGBG"] = { fg = c.bg, bg = c.red, bold = true }, + ["TodoBUGSIGN"] = { fg = c.red, bg = c.red, bold = true }, + ["TodoTEST"] = { link = "DiagnosticInfo" }, + ["TodoTESTBG"] = { fg = c.bg, bg = c.blue, bold = true }, + ["TodoTESTSIGN"] = { fg = c.blue, bg = c.blue, bold = true }, + ["TodoWARN"] = { link = "DiagnosticWarn" }, + ["TodoWARNBG"] = { fg = c.bg, bg = c.yellow, bold = true }, + ["TodoWARNSIGN"] = { fg = c.yellow, bg = c.yellow, bold = true }, } end end diff --git a/lua/conf/plugins/oil.lua b/lua/conf/plugins/oil.lua index f134083..4f7f127 100644 --- a/lua/conf/plugins/oil.lua +++ b/lua/conf/plugins/oil.lua @@ -14,11 +14,11 @@ return { "stevearc/oil.nvim", for i = 1, #permission_str do local char = permission_str:sub(i, i) table.insert(hls, { ({ - ["-"] = "NonText", - ["r"] = "DiagnosticSignWarn", - ["w"] = "DiagnosticSignHint", - ["x"] = "DiagnosticSignOk" - })[char], i - 1, i }) + ["-"] = "NonText", + ["r"] = "DiagnosticSignWarn", + ["w"] = "DiagnosticSignHint", + ["x"] = "DiagnosticSignOk" + })[char], i - 1, i }) end return hls end, @@ -26,12 +26,12 @@ return { "stevearc/oil.nvim", { "size", highlight = "@number" } }, - -- fix the damn border - confirmation = { winborder = vim.o.winborder }, - progress = { winborder = vim.o.winborder }, - ssh = { winborder = vim.o.winborder }, - keymaps_help = { winborder = vim.o.winborder } - } + -- fix the damn border + confirmation = { winborder = vim.o.winborder }, + progress = { winborder = vim.o.winborder }, + ssh = { winborder = vim.o.winborder }, + keymaps_help = { winborder = vim.o.winborder } + } map("n", "-", "Oil") end diff --git a/lua/conf/plugins/opencode.lua b/lua/conf/plugins/opencode.lua index 1ca8b36..bc317d4 100644 --- a/lua/conf/plugins/opencode.lua +++ b/lua/conf/plugins/opencode.lua @@ -1,10 +1,10 @@ return { "NickvanDyke/opencode.nvim", - load = function() - core.misc.map("n", "oa", function() - require("opencode").ask() - end, { desc = "Ask opencode" }) - core.misc.map("v", "oa", function() - require("opencode").ask("@selection: ") - end, { desc = "Ask opencode about selection" }) - end + load = function() + core.misc.map("n", "oa", function() + require("opencode").ask() + end, { desc = "Ask opencode" }) + core.misc.map("v", "oa", function() + require("opencode").ask("@selection: ") + end, { desc = "Ask opencode about selection" }) + end } diff --git a/lua/conf/plugins/telescope.lua b/lua/conf/plugins/telescope.lua index 0ed75be..56d5d1a 100644 --- a/lua/conf/plugins/telescope.lua +++ b/lua/conf/plugins/telescope.lua @@ -44,72 +44,72 @@ return { "nvim-telescope/telescope.nvim", load = function() local telescope = require("telescope") local actions = require("telescope.actions") - local action_state = require("telescope.actions.state") + local action_state = require("telescope.actions.state") - local function send_limited_to_qflist_and_open(prompt_bufnr) - local picker = action_state.get_current_picker(prompt_bufnr) - local entries = {} - local max_items = 100 - local count = 0 + local function send_limited_to_qflist_and_open(prompt_bufnr) + local picker = action_state.get_current_picker(prompt_bufnr) + local entries = {} + local max_items = 100 + local count = 0 - for entry in picker.manager:iter() do - if count >= max_items then - break - end + for entry in picker.manager:iter() do + if count >= max_items then + break + end - local filename = entry.path or entry.filename or entry.value - local text = entry.text or entry.value - if not text then - if type(entry.value) == "table" then - text = entry.value.text - else - text = entry.value - end - end + local filename = entry.path or entry.filename or entry.value + local text = entry.text or entry.value + if not text then + if type(entry.value) == "table" then + text = entry.value.text + else + text = entry.value + end + end - local pattern - if not entry.lnum then - if type(entry.display) == "string" then - pattern = entry.display - elseif type(entry.ordinal) == "string" then - pattern = entry.ordinal - elseif type(text) == "string" then - pattern = text - else - entry.lnum = 1 - end - end + local pattern + if not entry.lnum then + if type(entry.display) == "string" then + pattern = entry.display + elseif type(entry.ordinal) == "string" then + pattern = entry.ordinal + elseif type(text) == "string" then + pattern = text + else + entry.lnum = 1 + end + end - if filename then - table.insert(entries, { - filename = filename, - text = text, - lnum = entry.lnum, - col = entry.col, + if filename then + table.insert(entries, { + filename = filename, + text = text, + lnum = entry.lnum, + col = entry.col, - -- we try and put a pattern in based on the info we receive from - -- telescope so that the qf list takes us to the correct place - pattern = pattern - }) - count = count + 1 - end - end + -- we try and put a pattern in based on the info we receive from + -- telescope so that the qf list takes us to the correct place + pattern = pattern + }) + count = count + 1 + end + end - if #entries > 0 then - -- make sure errors get suppressed. I don't care - pcall(vim.fn.setqflist, {}, " ", { - title = "Telescope Limited Results", - items = entries - }) - end + if #entries > 0 then + -- make sure errors get suppressed. I don't care + pcall(vim.fn.setqflist, {}, " ", { + title = "Telescope Limited Results", + items = entries + }) + end - actions.select_default(prompt_bufnr) - end + actions.select_default(prompt_bufnr) + end telescope.setup { defaults = { - layout_strategy = "bottom_pane", - borderchars = { " ", " ", " ", " ", " ", " ", " ", " " }, + layout_strategy = "bottom_pane", + borderchars = { " ", " ", " ", " ", " ", " ", " ", " " }, mappings = { i = { [""] = actions.close, @@ -119,11 +119,11 @@ return { "nvim-telescope/telescope.nvim", } } }, - pickers = { - colorscheme = { - enable_preview = true - } - }, + pickers = { + colorscheme = { + enable_preview = true + } + }, extensions = { fzf = {} } @@ -154,6 +154,6 @@ return { "nvim-telescope/telescope.nvim", } end, { desc = "find files in plugin directory" }) - map("n", "tt", "Telescope") + map("n", "tt", "Telescope") end } diff --git a/lua/conf/plugins/treesitter.lua b/lua/conf/plugins/treesitter.lua index adf9311..f3d6efb 100644 --- a/lua/conf/plugins/treesitter.lua +++ b/lua/conf/plugins/treesitter.lua @@ -49,11 +49,11 @@ return { } } - core.misc.map("n", "t", function() - pcall(vim.cmd.TSInstall, vim.api.nvim_get_option_value("ft", { - buf = vim.api.nvim_get_current_buf() - })) - end) + core.misc.map("n", "t", function() + pcall(vim.cmd.TSInstall, vim.api.nvim_get_option_value("ft", { + buf = vim.api.nvim_get_current_buf() + })) + end) end }, @@ -77,7 +77,7 @@ return { { "windwp/nvim-ts-autotag", reqs = "nvim-treesitter/nvim-treesitter", - disable = true, + disable = true, -- lazy = dep_short.auto({ "BufReadPre", "BufNewFile" }), load = function() require("nvim-ts-autotag").setup {} diff --git a/lua/core/color.lua b/lua/core/color.lua index 08fe763..f02d467 100644 --- a/lua/core/color.lua +++ b/lua/core/color.lua @@ -7,10 +7,10 @@ local M = {} function M.copyhl(hlgroup, namespace) namespace = namespace or 0 local res = { - ["foreground"] = "#ff0000", - ["background"] = "#ff0000", - ["special"] = "#ff0000" - } + ["foreground"] = "#ff0000", + ["background"] = "#ff0000", + ["special"] = "#ff0000" + } local ok, hl = pcall(vim.api.nvim_get_hl, namespace, { name = hlgroup, diff --git a/lua/core/lsp/binds.lua b/lua/core/lsp/binds.lua index cffb4ec..84cf22d 100644 --- a/lua/core/lsp/binds.lua +++ b/lua/core/lsp/binds.lua @@ -8,8 +8,8 @@ local function on_list(opts) -- get to the closest reference to the cursor (likely the one gr or gd was -- called on) - -- - -- TODO: switch this to use opts.idx? + -- + -- TODO: switch this to use opts.idx? local closest, distance = 1, false for i, item in ipairs(opts.items) do if item.filename and vim.fn.expand("%:p") == item.filename then @@ -37,32 +37,32 @@ end local group = misc.augroup("lsp.bind") auto("LspAttach", { - group = group, - callback = function(ctx) - local list_opts = { on_list = on_list } - local opts = { buffer = ctx.buf, nowait = true } + group = group, + callback = function(ctx) + local list_opts = { on_list = on_list } + local opts = { buffer = ctx.buf, nowait = true } - -- LSP actions - map("n", "K", vim.lsp.buf.hover, opts) - map("n", "gd", function() vim.lsp.buf.definition(list_opts) end, opts) - map("n", "gD", function() vim.lsp.buf.declaration(list_opts) end, opts) - map("n", "gi", function() vim.lsp.buf.implementation(list_opts) end, opts) - map("n", "gy", function() vim.lsp.buf.type_definition(list_opts) end, opts) - map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts) - map("n", "", vim.lsp.buf.signature_help, opts) - map("n", "r", vim.lsp.buf.rename, opts) - map("n", "gA", vim.lsp.buf.code_action, opts) + -- LSP actions + map("n", "K", vim.lsp.buf.hover, opts) + map("n", "gd", function() vim.lsp.buf.definition(list_opts) end, opts) + map("n", "gD", function() vim.lsp.buf.declaration(list_opts) end, opts) + map("n", "gi", function() vim.lsp.buf.implementation(list_opts) end, opts) + map("n", "gy", function() vim.lsp.buf.type_definition(list_opts) end, opts) + map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts) + map("n", "", vim.lsp.buf.signature_help, opts) + map("n", "r", vim.lsp.buf.rename, opts) + map("n", "gA", vim.lsp.buf.code_action, opts) - -- Diagnostics - map("n", "[d", function() - vim.diagnostic.jump({ count = -1 }) - end, opts) - map("n", "]d", function() - vim.diagnostic.jump({ count = 1 }) - end, opts) - map("n", "gb", vim.diagnostic.setqflist, opts) + -- Diagnostics + map("n", "[d", function() + vim.diagnostic.jump({ count = -1 }) + end, opts) + map("n", "]d", function() + vim.diagnostic.jump({ count = 1 }) + end, opts) + map("n", "gb", vim.diagnostic.setqflist, opts) - -- formatting - map("n", "c", vim.lsp.buf.format) - end + -- formatting + map("n", "c", vim.lsp.buf.format) + end }) diff --git a/lua/core/lsp/completion.lua b/lua/core/lsp/completion.lua index f8adbbb..97eb65b 100644 --- a/lua/core/lsp/completion.lua +++ b/lua/core/lsp/completion.lua @@ -9,16 +9,16 @@ ---@param list table list of chars ---@param char number|string char to add local function add_to_client(list, char) - local c + local c - if type(char) == "string" then - c = char - elseif type(char) == "number" then - c = string.char(char) - end - if not table.contains(list, c) then - table.insert(list, c) - end + if type(char) == "string" then + c = char + elseif type(char) == "number" then + c = string.char(char) + end + if not table.contains(list, c) then + table.insert(list, c) + end end -- make sure we can add autos @@ -29,49 +29,49 @@ local completion_group = misc.augroup("lsp.completion") -- Configure the lsp completion menu. In addition to setting up lsp completion -- this also styles it to look nice. auto("LspAttach", { - group = completion_group, - callback = function(ctx) - local client = vim.lsp.get_client_by_id(ctx.data.client_id) - if not client or not client:supports_method("textDocument/completion") then - return - end + group = completion_group, + callback = function(ctx) + local client = vim.lsp.get_client_by_id(ctx.data.client_id) + if not client or not client:supports_method("textDocument/completion") then + return + end - -- Make completion menu appear whenever you type something. - local c = client.server_capabilities.completionProvider.triggerCharacters - if c then - for i = 32, 126 do - add_to_client(c, string.char(i)) - end - end + -- Make completion menu appear whenever you type something. + local c = client.server_capabilities.completionProvider.triggerCharacters + if c then + for i = 32, 126 do + add_to_client(c, string.char(i)) + end + end - vim.lsp.completion.enable(true, client.id, ctx.buf, { - autotrigger = true, - convert = function(item) + vim.lsp.completion.enable(true, client.id, ctx.buf, { + autotrigger = true, + convert = function(item) local kind = vim.lsp.protocol.CompletionItemKind[item.kind] or 'u' return { - -- in the future if we ever get the ability to highlight specific - -- entries in the pummenu I'd like to add treesitter highlighting to - -- the entries + -- in the future if we ever get the ability to highlight specific + -- entries in the pummenu I'd like to add treesitter highlighting to + -- the entries abbr = item.label:gsub('%b()', ''), kind = kind:sub(1, 1):lower(), menu = '' } - end - }) - end + end + }) + end }) -- attempt to style the completion documentation popup auto("CompleteChanged", { - group = completion_group, - callback = function() - local info = vim.fn.complete_info({ "selected" }) - if info.preview_bufnr and vim.bo[info.preview_bufnr].filetype == "" then - vim.bo[info.preview_bufnr].filetype = "markdown" - vim.wo[info.preview_winid].conceallevel = 2 - vim.wo[info.preview_winid].concealcursor = "niv" - end - end + group = completion_group, + callback = function() + local info = vim.fn.complete_info({ "selected" }) + if info.preview_bufnr and vim.bo[info.preview_bufnr].filetype == "" then + vim.bo[info.preview_bufnr].filetype = "markdown" + vim.wo[info.preview_winid].conceallevel = 2 + vim.wo[info.preview_winid].concealcursor = "niv" + end + end }) -- Add snippet support to lsp clients who don't do it for us. Currently this @@ -81,121 +81,121 @@ auto("CompleteChanged", { -- not follow the c-style function call style. I've only gotten this working in -- lua thus far. auto("CompleteDonePre", { - group = completion_group, - callback = function() - local item = vim.tbl_get( - vim.v.completed_item, - "user_data", - "nvim", - "lsp", - "completion_item" - ) - if not item then - return - end + group = completion_group, + callback = function() + local item = vim.tbl_get( + vim.v.completed_item, + "user_data", + "nvim", + "lsp", + "completion_item" + ) + if not item then + return + end - -- TODO: we need to truncate the item.label to ensure that we don't - -- duplicate any text below is my attempt to start work on it: - -- - -- local cursor = vim.api.nvim_win_get_cursor(0) - -- local line = vim.api.nvim_buf_get_lines( - -- vim.api.nvim_win_get_buf(0), - -- cursor[1] - 1, - -- cursor[1], - -- false - -- )[1] - -- item.label = string.gsub(item.label, string.sub(line, cursor[2] + 1), "") - -- item.insertText = item.label + -- TODO: we need to truncate the item.label to ensure that we don't + -- duplicate any text below is my attempt to start work on it: + -- + -- local cursor = vim.api.nvim_win_get_cursor(0) + -- local line = vim.api.nvim_buf_get_lines( + -- vim.api.nvim_win_get_buf(0), + -- cursor[1] - 1, + -- cursor[1], + -- false + -- )[1] + -- item.label = string.gsub(item.label, string.sub(line, cursor[2] + 1), "") + -- item.insertText = item.label - -- if the item isn't a snippet then we might want to create a snippet - if item.label and item.kind and item.insertTextFormat then - if item.insertTextFormat ~= 2 and item.kind == 3 then - local n_complete_item = vim.v.completed_item + -- if the item isn't a snippet then we might want to create a snippet + if item.label and item.kind and item.insertTextFormat then + if item.insertTextFormat ~= 2 and item.kind == 3 then + local n_complete_item = vim.v.completed_item - -- attempt to modify the function args to create a snippet - local paren1 = string.find(item.label, "%(") - if not paren1 then - return - end + -- attempt to modify the function args to create a snippet + local paren1 = string.find(item.label, "%(") + if not paren1 then + return + end - -- try and create a snippet from a function call - local i = 1 - local text = "" - local l_paren = paren1 - local next, is_paren - while not is_paren do - -- find the next token - next = string.find(item.label, "%,", l_paren + 1) - if not next then - next = string.find(item.label, "%)", l_paren + 1) - if not next then - return - end - is_paren = true - end + -- try and create a snippet from a function call + local i = 1 + local text = "" + local l_paren = paren1 + local next, is_paren + while not is_paren do + -- find the next token + next = string.find(item.label, "%,", l_paren + 1) + if not next then + next = string.find(item.label, "%)", l_paren + 1) + if not next then + return + end + is_paren = true + end - -- concat text - if text == "" then - -- start the snippet - text = string.sub(item.label, 0, l_paren).."${"..i..":" - else - -- continue the snippet - text = text.."}, ".."${"..i..":" - end + -- concat text + if text == "" then + -- start the snippet + text = string.sub(item.label, 0, l_paren).."${"..i..":" + else + -- continue the snippet + text = text.."}, ".."${"..i..":" + end - do -- add the content of the argument to the snippet - -- we need to account for cases in which the developer uses spaces - -- between their commas and code - local is_space = string.sub(item.label, l_paren + 1, l_paren + 1) - local plus = is_space == " " and 2 or 1 + do -- add the content of the argument to the snippet + -- we need to account for cases in which the developer uses spaces + -- between their commas and code + local is_space = string.sub(item.label, l_paren + 1, l_paren + 1) + local plus = is_space == " " and 2 or 1 - text = text..string.sub(item.label, l_paren + plus, next - 1) - end + text = text..string.sub(item.label, l_paren + plus, next - 1) + end - -- increment - l_paren = next - i = i + 1 - end - -- end the snippet - text = text.."})" + -- increment + l_paren = next + i = i + 1 + end + -- end the snippet + text = text.."})" - n_complete_item.user_data.nvim.lsp.completion_item.insertText = text - n_complete_item.user_data.nvim.lsp.completion_item.insertTextFormat = 2 - n_complete_item.user_data.nvim.lsp.completion_item.kind = 3 - vim.v.completed_item = n_complete_item - end - end - end + n_complete_item.user_data.nvim.lsp.completion_item.insertText = text + n_complete_item.user_data.nvim.lsp.completion_item.insertTextFormat = 2 + n_complete_item.user_data.nvim.lsp.completion_item.kind = 3 + vim.v.completed_item = n_complete_item + end + end + end }) -- show the signature help when inside a function call auto("CompleteDone", { - group = completion_group, - callback = function(ctx) - -- make sure there's an lsp client, and make sure the lsp client supports - -- textDocument/signatureHelp - local client = vim.lsp.get_clients({ bufnr = ctx.buf })[1] - if not client or not client:supports_method("textDocument/signatureHelp") then - return - end + group = completion_group, + callback = function(ctx) + -- make sure there's an lsp client, and make sure the lsp client supports + -- textDocument/signatureHelp + local client = vim.lsp.get_clients({ bufnr = ctx.buf })[1] + if not client or not client:supports_method("textDocument/signatureHelp") then + return + end - -- show the signature help - local item = vim.tbl_get( - vim.v.completed_item, - "user_data", - "nvim", - "lsp", - "completion_item" - ) - if not item then - return - end + -- show the signature help + local item = vim.tbl_get( + vim.v.completed_item, + "user_data", + "nvim", + "lsp", + "completion_item" + ) + if not item then + return + end - -- show signature help when the completion is a function - if item.kind == 3 and (item.textEdit ~= nil or item.insertText ~= nil) then - -- for some reason calling vim.schedule didn't work for me - vim.defer_fn(vim.lsp.buf.signature_help, 100) - end - end, - desc = "Auto show signature help when completion is done" + -- show signature help when the completion is a function + if item.kind == 3 and (item.textEdit ~= nil or item.insertText ~= nil) then + -- for some reason calling vim.schedule didn't work for me + vim.defer_fn(vim.lsp.buf.signature_help, 100) + end + end, + desc = "Auto show signature help when completion is done" }) diff --git a/lua/core/lsp/init.lua b/lua/core/lsp/init.lua index 975bf30..7ddc104 100644 --- a/lua/core/lsp/init.lua +++ b/lua/core/lsp/init.lua @@ -23,9 +23,9 @@ function M.setup() capabilities = vim.lsp.protocol.make_client_capabilities() } - require("core.lsp.binds") - require("core.lsp.completion") - require("core.lsp.wtf") + require("core.lsp.binds") + require("core.lsp.completion") + require("core.lsp.wtf") end return M diff --git a/lua/core/lsp/wtf.lua b/lua/core/lsp/wtf.lua index 89922be..04c3ee6 100644 --- a/lua/core/lsp/wtf.lua +++ b/lua/core/lsp/wtf.lua @@ -9,29 +9,29 @@ auto('LspAttach', { group = wtf_group, callback = function(ctx) local client = vim.lsp.get_client_by_id(ctx.data.client_id) - if not client then - return - end + if not client then + return + end - -- highlight color codes via lsp (supported by cssls) - -- #ff0000 + -- highlight color codes via lsp (supported by cssls) + _ = "#ff0000" if client:supports_method('textDocument/documentColor') then pcall(vim.lsp.document_color.enable, true, ctx.buf) end - -- enable linked editing this allows lsps to modify things like html tags - -- for example when you change

to

will be changed by the lsp - -- to + -- enable linked editing this allows lsps to modify things like html tags + -- for example when you change

to

will be changed by the lsp + -- to if client:supports_method('textDocument/linkedEditingRange') then - pcall(vim.lsp.linked_editing_range.enable, true, { client_id = client.id }) + pcall(vim.lsp.linked_editing_range.enable, true, { client_id = client.id }) end - -- disabled for now cause I don't like it - -- -- enable type formatting which allows lsps to modify text while you're - -- -- typing for example if you insert {} in a string in python basedpyright - -- -- will change the string to a format string - -- if client:supports_method('textDocument/onTypeFormatting') then - -- pcall(vim.lsp.on_type_formatting.enable, true, { client_id = client.id }) - -- end + -- disabled for now cause I don't like it + -- -- enable type formatting which allows lsps to modify text while you're + -- -- typing for example if you insert {} in a string in python basedpyright + -- -- will change the string to a format string + -- if client:supports_method('textDocument/onTypeFormatting') then + -- pcall(vim.lsp.on_type_formatting.enable, true, { client_id = client.id }) + -- end end }) diff --git a/lua/core/misc.lua b/lua/core/misc.lua index c6b7c13..58c7e99 100644 --- a/lua/core/misc.lua +++ b/lua/core/misc.lua @@ -24,7 +24,7 @@ function M.map(mode, bind, cmd, opts) end end - vim.keymap.set(mode, bind, cmd, opts) + vim.keymap.set(mode, bind, cmd, opts) end --- a small map wrapper to easily create local buffer mappings @@ -56,18 +56,18 @@ end ---@return string|function lazified ---@nodiscard function M.lz(txt) - if type(txt) == "string" then - return "se lz"..txt.."se lz!" - elseif type(txt) == "function" then - return function() - vim.cmd.se("lz") - -- gotta make sure we can always unset lz - pcall(txt) - vim.cmd.se("lz!") - end - else - return txt - end + if type(txt) == "string" then + return "se lz"..txt.."se lz!" + elseif type(txt) == "function" then + return function() + vim.cmd.se("lz") + -- gotta make sure we can always unset lz + pcall(txt) + vim.cmd.se("lz!") + end + else + return txt + end end return M diff --git a/lua/snippets/lua.lua b/lua/snippets/lua.lua index 0aa0e4e..698cef9 100644 --- a/lua/snippets/lua.lua +++ b/lua/snippets/lua.lua @@ -3,17 +3,17 @@ dofile(core.snippets) return { -- print inspect text s("inspect", { - t("print(vim.inspect("), - i(0), - t("))") + t("print(vim.inspect("), + i(0), + t("))") }), -- print inspect text s("M", { - i(1, "M"); - t({ " = {}", "" }), - i(0), - t({ "", "return " }), - r(1) + i(1, "M"); + t({ " = {}", "" }), + i(0), + t({ "", "return " }), + r(1) }) }