From 3581deb55099f2d37935ab7719bb249cea7b3480 Mon Sep 17 00:00:00 2001 From: Andrew Haynes Date: Thu, 12 Nov 2026 14:24:48 -0500 Subject: [PATCH] chore(blink): I added it back but will switch back and forth until native feels good --- nvim/.config/nvim/after/lsp/clangd.lua | 91 ----------- nvim/.config/nvim/after/lsp/gopls.lua | 85 ---------- nvim/.config/nvim/after/lsp/html.lua | 20 --- nvim/.config/nvim/after/lsp/lua_ls.lua | 40 ----- nvim/.config/nvim/after/lsp/vtsls.lua | 51 ------ nvim/.config/nvim/colors/minikanso-zen.lua | 41 ++--- nvim/.config/nvim/init.lua | 35 ++--- .../nvim/lua/DarthMooMancer/keymaps.lua | 37 +++-- nvim/.config/nvim/lua/DarthMooMancer/lsp.lua | 147 ++++++++++++++++++ .../nvim/lua/DarthMooMancer/plugins.lua | 18 ++- nvim/.config/nvim/nvim-pack-lock.json | 5 + nvim/.config/nvim/stylua.toml | 2 +- 12 files changed, 229 insertions(+), 343 deletions(-) delete mode 100644 nvim/.config/nvim/after/lsp/clangd.lua delete mode 100644 nvim/.config/nvim/after/lsp/gopls.lua delete mode 100644 nvim/.config/nvim/after/lsp/html.lua delete mode 100644 nvim/.config/nvim/after/lsp/lua_ls.lua delete mode 100644 nvim/.config/nvim/after/lsp/vtsls.lua create mode 100644 nvim/.config/nvim/lua/DarthMooMancer/lsp.lua diff --git a/nvim/.config/nvim/after/lsp/clangd.lua b/nvim/.config/nvim/after/lsp/clangd.lua deleted file mode 100644 index a06b980..0000000 --- a/nvim/.config/nvim/after/lsp/clangd.lua +++ /dev/null @@ -1,91 +0,0 @@ -local function switch_source_header(bufnr, client) - local method_name = 'textDocument/switchSourceHeader' - ---@diagnostic disable-next-line:param-type-mismatch - if not client or not client:supports_method(method_name) then - return vim.notify( - ('method %s is not supported by any servers active on the current buffer'):format(method_name) - ) - end - local params = vim.lsp.util.make_text_document_params(bufnr) - ---@diagnostic disable-next-line:param-type-mismatch - client:request(method_name, params, function(err, result) - if err then - error(tostring(err)) - end - if not result then - vim.notify('corresponding file cannot be determined') - return - end - vim.cmd.edit(vim.uri_to_fname(result)) - end, bufnr) -end - -local function symbol_info(bufnr, client) - local method_name = 'textDocument/symbolInfo' - ---@diagnostic disable-next-line:param-type-mismatch - if not client or not client:supports_method(method_name) then - return vim.notify('Clangd client not found', vim.log.levels.ERROR) - end - local win = vim.api.nvim_get_current_win() - local params = vim.lsp.util.make_position_params(win, client.offset_encoding) - ---@diagnostic disable-next-line:param-type-mismatch - client:request(method_name, params, function(err, res) - if err or #res == 0 then - -- Clangd always returns an error, there is no reason to parse it - return - end - local container = string.format('container: %s', res[1].containerName) ---@type string - local name = string.format('name: %s', res[1].name) ---@type string - vim.lsp.util.open_floating_preview({ name, container }, '', { - height = 2, - width = math.max(string.len(name), string.len(container)), - focusable = false, - focus = false, - title = 'Symbol Info', - }) - end, bufnr) -end - ----@class ClangdInitializeResult: lsp.InitializeResult ----@field offsetEncoding? string - -return { - cmd = { 'clangd' }, - filetypes = { 'c', 'c.doxygen', 'cpp', 'cpp.doxygen', 'objc', 'objcpp', 'cuda' }, - root_markers = { - '.clangd', - '.clang-tidy', - '.clang-format', - 'compile_commands.json', - 'compile_flags.txt', - 'configure.ac', -- AutoTools - '.git', - }, - get_language_id = function(_, ftype) - local t = { objc = 'objective-c', objcpp = 'objective-cpp', cuda = 'cuda-cpp' } - return t[ftype] or ftype - end, - capabilities = { - textDocument = { - completion = { - editsNearCursor = true, - }, - }, - offsetEncoding = { 'utf-8', 'utf-16' }, - }, - ---@param init_result ClangdInitializeResult - on_init = function(client, init_result) - if init_result.offsetEncoding then - client.offset_encoding = init_result.offsetEncoding - end - end, - on_attach = function(client, bufnr) - vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdSwitchSourceHeader', function() - switch_source_header(bufnr, client) - end, { desc = 'Switch between source/header' }) - - vim.api.nvim_buf_create_user_command(bufnr, 'LspClangdShowSymbolInfo', function() - symbol_info(bufnr, client) - end, { desc = 'Show symbol info' }) - end, -} diff --git a/nvim/.config/nvim/after/lsp/gopls.lua b/nvim/.config/nvim/after/lsp/gopls.lua deleted file mode 100644 index 807d4d5..0000000 --- a/nvim/.config/nvim/after/lsp/gopls.lua +++ /dev/null @@ -1,85 +0,0 @@ -local mod_cache = nil -local std_lib = nil - -local function identify_go_dir(custom_args, on_complete) - local cmd = { 'go', 'env', custom_args.envvar_id } - vim.system(cmd, { text = true }, function(output) - local res = vim.trim(output.stdout or '') - if output.code == 0 and res ~= '' then - if custom_args.custom_subdir and custom_args.custom_subdir ~= '' then - res = res .. custom_args.custom_subdir - end - on_complete(res) - else - vim.schedule(function() - vim.notify( - ('[gopls] identify ' .. custom_args.envvar_id .. ' dir cmd failed with code %d: %s\n%s'):format( - output.code, - vim.inspect(cmd), - output.stderr - ) - ) - end) - on_complete(nil) - end - end) -end - -local function get_std_lib_dir() - if std_lib and std_lib ~= '' then - return std_lib - end - - identify_go_dir({ envvar_id = 'GOROOT', custom_subdir = '/src' }, function(dir) - if dir then - std_lib = dir - end - end) - return std_lib -end - -local function get_mod_cache_dir() - if mod_cache and mod_cache ~= '' then - return mod_cache - end - - identify_go_dir({ envvar_id = 'GOMODCACHE' }, function(dir) - if dir then - mod_cache = dir - end - end) - return mod_cache -end - -local function get_root_dir(fname) - if mod_cache and fname:sub(1, #mod_cache) == mod_cache then - local clients = vim.lsp.get_clients({ name = 'gopls' }) - if #clients > 0 then - return clients[#clients].config.root_dir - end - end - if std_lib and fname:sub(1, #std_lib) == std_lib then - local clients = vim.lsp.get_clients({ name = 'gopls' }) - if #clients > 0 then - return clients[#clients].config.root_dir - end - end - return vim.fs.root(fname, 'go.work') or vim.fs.root(fname, 'go.mod') or vim.fs.root(fname, '.git') -end - -return { - cmd = { 'gopls' }, - filetypes = { 'go', 'gomod', 'gowork', 'gotmpl' }, - root_dir = function(bufnr, on_dir) - local fname = vim.api.nvim_buf_get_name(bufnr) - get_mod_cache_dir() - get_std_lib_dir() - -- see: https://github.com/neovim/nvim-lspconfig/issues/804 - on_dir(get_root_dir(fname)) - end, - settings = { - gopls = { - semanticTokens = true, - }, - }, -} diff --git a/nvim/.config/nvim/after/lsp/html.lua b/nvim/.config/nvim/after/lsp/html.lua deleted file mode 100644 index 6fb4ebc..0000000 --- a/nvim/.config/nvim/after/lsp/html.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - cmd = function(dispatchers, config) - local cmd = 'vscode-html-language-server' - if (config or {}).root_dir then - local local_cmd = vim.fs.joinpath(config.root_dir, 'node_modules/.bin', cmd) - if vim.fn.executable(local_cmd) == 1 then - cmd = local_cmd - end - end - return vim.lsp.rpc.start({ cmd, '--stdio' }, dispatchers) - end, - filetypes = { 'html' }, - root_markers = { 'package.json', '.git' }, - settings = {}, - init_options = { - provideFormatter = true, - embeddedLanguages = { css = true, javascript = true }, - configurationSection = { 'html', 'css', 'javascript' }, - }, -} diff --git a/nvim/.config/nvim/after/lsp/lua_ls.lua b/nvim/.config/nvim/after/lsp/lua_ls.lua deleted file mode 100644 index 06fab8c..0000000 --- a/nvim/.config/nvim/after/lsp/lua_ls.lua +++ /dev/null @@ -1,40 +0,0 @@ -local root_markers1 = { - '.emmyrc.json', - '.luarc.json', - '.luarc.jsonc', -} -local root_markers2 = { - '.luacheckrc', - '.stylua.toml', - 'stylua.toml', - 'selene.toml', - 'selene.yml', -} - -return { - cmd = { 'lua-language-server' }, - filetypes = { 'lua' }, - root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers1, root_markers2, { '.git' } } - or vim.list_extend(vim.list_extend(root_markers1, root_markers2), { '.git' }), - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - }, - diagnostics = { globals = { 'vim' } }, - completion = { callSnippet = 'Replace' }, - type = { - checkTableShape = true, -- Warns if you pass a table missing required fields - inferParamType = true, -- Tries to figure out argument types from usage - }, - workspace = { - checkThirdParty = false, - library = { - vim.env.VIMRUNTIME .. '/lua', - - '/Users/andrew/personal/Projects/Lua/vern-nvim/lua', - }, - }, - }, - }, -} diff --git a/nvim/.config/nvim/after/lsp/vtsls.lua b/nvim/.config/nvim/after/lsp/vtsls.lua deleted file mode 100644 index 85d3e56..0000000 --- a/nvim/.config/nvim/after/lsp/vtsls.lua +++ /dev/null @@ -1,51 +0,0 @@ -return { - cmd = { 'vtsls', '--stdio' }, - init_options = { - hostInfo = 'neovim', - }, - filetypes = { - 'javascript', - 'javascriptreact', - 'typescript', - 'typescriptreact', - }, - settings = { - vtsls = { - autoUseWorkspaceTsdk = true, - experimental = { - completion = { - enableServerSideFuzzyMatch = true, - }, - }, - }, - typescript = { - tsserver = { - maxTsServerMemory = 8192, - }, - updateImportsOnFileMove = { enabled = 'always' }, - preferences = { - importModuleSpecifier = 'non-relative', - }, - }, - javascript = { - updateImportsOnFileMove = { enabled = 'always' }, - }, - }, - - root_dir = function(bufnr, on_dir) - local root_markers = - { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' } - root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers, { '.git' } } - or vim.list_extend(root_markers, { '.git' }) - local deno_root = vim.fs.root(bufnr, { 'deno.json', 'deno.jsonc' }) - local deno_lock_root = vim.fs.root(bufnr, { 'deno.lock' }) - local project_root = vim.fs.root(bufnr, root_markers) - if deno_lock_root and (not project_root or #deno_lock_root > #project_root) then - return - end - if deno_root and (not project_root or #deno_root >= #project_root) then - return - end - on_dir(project_root or vim.fn.getcwd()) - end, -} diff --git a/nvim/.config/nvim/colors/minikanso-zen.lua b/nvim/.config/nvim/colors/minikanso-zen.lua index b8c6660..5ac4bc1 100644 --- a/nvim/.config/nvim/colors/minikanso-zen.lua +++ b/nvim/.config/nvim/colors/minikanso-zen.lua @@ -36,18 +36,21 @@ local palette = { gray4 = '#43464E', } -vim.api.nvim_set_hl(0, 'ColorColumn', { bg = palette.bg2 }) -vim.api.nvim_set_hl(0, 'Conceal', { fg = palette.gray3, bold = true }) +--- ColorColumn, Conceal, Cursor, lCursor, CursorIM, CursorLine, CursorColumn, +--- CursorLineSign, CursorLineFold, CursorLineNr, NormalNC, WildMenu, + +-- vim.api.nvim_set_hl(0, 'ColorColumn', { bg = palette.bg2 }) +-- vim.api.nvim_set_hl(0, 'Conceal', { fg = palette.gray3, bold = true }) vim.api.nvim_set_hl(0, 'CurSearch', { fg = palette.fg0, bg = palette.blue1, bold = true }) -vim.api.nvim_set_hl(0, 'Cursor', { fg = palette.bg0, bg = palette.fg1 }) -vim.api.nvim_set_hl(0, 'lCursor', { link = 'Cursor' }) -vim.api.nvim_set_hl(0, 'CursorIM', { link = 'Cursor' }) -vim.api.nvim_set_hl(0, 'CursorLine', { bg = palette.bg3 }) -vim.api.nvim_set_hl(0, 'CursorColumn', { link = 'CursorLine' }) -vim.api.nvim_set_hl(0, 'CursorLineSign', { link = 'CursorLine' }) -vim.api.nvim_set_hl(0, 'CursorLineFold', { link = 'CursorLine' }) -vim.api.nvim_set_hl(0, 'CursorLineNr', { fg = palette.fg1, bg = palette.none }) +-- vim.api.nvim_set_hl(0, 'Cursor', { fg = palette.bg0, bg = palette.fg1 }) +-- vim.api.nvim_set_hl(0, 'lCursor', { link = 'Cursor' }) +-- vim.api.nvim_set_hl(0, 'CursorIM', { link = 'Cursor' }) +-- vim.api.nvim_set_hl(0, 'CursorLine', { bg = palette.bg3 }) +-- vim.api.nvim_set_hl(0, 'CursorColumn', { link = 'CursorLine' }) +-- vim.api.nvim_set_hl(0, 'CursorLineSign', { link = 'CursorLine' }) +-- vim.api.nvim_set_hl(0, 'CursorLineFold', { link = 'CursorLine' }) +-- vim.api.nvim_set_hl(0, 'CursorLineNr', { fg = palette.fg1, bg = palette.none }) vim.api.nvim_set_hl(0, 'Directory', { fg = palette.blue3 }) vim.api.nvim_set_hl(0, 'EndOfBuffer', { fg = palette.bg0 }) @@ -67,7 +70,7 @@ vim.api.nvim_set_hl(0, 'MoreMsg', { link = 'DiagnosticInfo' }) vim.api.nvim_set_hl(0, 'NonText', { fg = palette.gray3 }) vim.api.nvim_set_hl(0, 'Normal', { fg = palette.fg0, bg = palette.bg0 }) -vim.api.nvim_set_hl(0, 'NormalNC', { link = 'Normal' }) +-- vim.api.nvim_set_hl(0, 'NormalNC', { link = 'Normal' }) vim.api.nvim_set_hl(0, 'NormalFloat', { fg = palette.gray0, bg = palette.bg1 }) vim.api.nvim_set_hl(0, 'FloatBorder', { fg = palette.gray4, bg = palette.bg1 }) @@ -75,7 +78,7 @@ vim.api.nvim_set_hl(0, 'FloatTitle', { fg = palette.gray3, bg = palette.bg1, bol vim.api.nvim_set_hl(0, 'FloatFooter', { fg = palette.gray3, bg = palette.bg1 }) vim.api.nvim_set_hl(0, 'Pmenu', { link = 'NormalFloat' }) vim.api.nvim_set_hl(0, 'PmenuSel', { fg = palette.none, bg = palette.gray4 }) -vim.api.nvim_set_hl(0, 'PmenuKind', { link = 'Pmenu' }) +-- vim.api.nvim_set_hl(0, 'PmenuKind', { link = 'Pmenu' }) vim.api.nvim_set_hl(0, 'PmenuKindSel', { fg = palette.gray0, bg = palette.gray4 }) vim.api.nvim_set_hl(0, 'PmenuExtra', { fg = palette.gray3, bg = palette.bg1 }) vim.api.nvim_set_hl(0, 'PmenuExtraSel', { fg = palette.gray3, bg = palette.gray4 }) @@ -93,12 +96,12 @@ vim.api.nvim_set_hl(0, 'Title', { fg = palette.blue3, bold = true }) vim.api.nvim_set_hl(0, 'Visual', { bg = palette.bg4 }) vim.api.nvim_set_hl(0, 'VisualNOS', { link = 'Visual' }) vim.api.nvim_set_hl(0, 'WarningMsg', { fg = palette.yellow0 }) -vim.api.nvim_set_hl(0, 'WildMenu', { link = 'Pmenu' }) +-- vim.api.nvim_set_hl(0, 'WildMenu', { link = 'Pmenu' }) -vim.api.nvim_set_hl(0, 'SpellBad', { link = 'DiagnosticUnderlineError' }) -vim.api.nvim_set_hl(0, 'SpellCap', { link = 'DiagnosticUnderlineWarn' }) -vim.api.nvim_set_hl(0, 'SpellRare', { undercurl = true, sp = palette.violet0 }) -vim.api.nvim_set_hl(0, 'SpellLocal', { undercurl = true, sp = palette.aqua1 }) +-- vim.api.nvim_set_hl(0, 'SpellBad', { link = 'DiagnosticUnderlineError' }) +-- vim.api.nvim_set_hl(0, 'SpellCap', { link = 'DiagnosticUnderlineWarn' }) +-- vim.api.nvim_set_hl(0, 'SpellRare', { undercurl = true, sp = palette.violet0 }) +-- vim.api.nvim_set_hl(0, 'SpellLocal', { undercurl = true, sp = palette.aqua1 }) vim.api.nvim_set_hl(0, 'DiagnosticError', { fg = palette.red0 }) vim.api.nvim_set_hl(0, 'DiagnosticWarn', { fg = palette.yellow0 }) @@ -113,6 +116,8 @@ vim.api.nvim_set_hl(0, 'DiagnosticUnderlineHint', { undercurl = true, sp = palet vim.api.nvim_set_hl(0, 'DiagnosticUnderlineOk', { undercurl = true, sp = palette.green0 }) vim.api.nvim_set_hl(0, 'LspSignatureActiveParameter', { fg = palette.yellow0 }) +--- +--- VertSplit, Ignore, PmenuKind, SpellBad, SpellCap, SpellRare, SpellLocal. vim.api.nvim_set_hl(0, 'Comment', { fg = palette.gray2, italic = true }) vim.api.nvim_set_hl(0, 'Constant', { fg = palette.orange0 }) @@ -134,7 +139,7 @@ vim.api.nvim_set_hl(0, 'Delimiter', { fg = palette.gray1 }) vim.api.nvim_set_hl(0, 'Underlined', { fg = palette.yellow1, underline = true }) vim.api.nvim_set_hl(0, 'Bold', { bold = true }) vim.api.nvim_set_hl(0, 'Italic', { italic = true }) -vim.api.nvim_set_hl(0, 'Ignore', { link = 'NonText' }) +-- vim.api.nvim_set_hl(0, 'Ignore', { link = 'NonText' }) vim.api.nvim_set_hl(0, 'Todo', { fg = palette.blue0, bg = palette.blue2, bold = true }) vim.api.nvim_set_hl(0, 'qfLineNr', { link = 'LineNr' }) vim.api.nvim_set_hl(0, 'qfFileName', { link = 'Directory' }) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 101ffa5..793d98d 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -14,20 +14,23 @@ vim.opt.signcolumn = 'yes' vim.opt.wrap = false vim.opt.confirm = true -vim.opt.scrolloff = 15 -vim.opt.sidescrolloff = 15 +vim.opt.scrolloff = 8 +vim.opt.sidescrolloff = 8 vim.opt.tabstop = 2 vim.opt.shiftwidth = 2 vim.opt.softtabstop = -1 vim.opt.expandtab = true -vim.opt.autocomplete = true -vim.opt.complete = 'o' -vim.opt.completeopt = { 'fuzzy', 'menu', 'menuone', 'noinsert', 'popup' } +-- vim.opt.autocomplete = true +-- vim.opt.autocompletedelay = 40 +-- vim.opt.complete = 'o' +-- vim.opt.complete = 'o,.^5,b^3' +-- vim.opt.complete = 'o,.,b^3' +-- vim.opt.completeopt:append({ 'fuzzy', 'menuone', 'noinsert' }) -vim.opt.pumheight = 10 -vim.opt.pumwidth = 15 +-- vim.opt.pummaxwidth = 100 +-- vim.opt.pumheight = 12 vim.diagnostic.config({ virtual_text = true, @@ -39,20 +42,4 @@ require('DarthMooMancer.plugins') vim.cmd.colorscheme('minikanso-zen') require('DarthMooMancer.keymaps') - -local capabilities = vim.lsp.protocol.make_client_capabilities() -if capabilities.workspace then - capabilities.workspace.didChangeWatchedFiles = nil -end - -vim.lsp.config('*', { - capabilities = capabilities, -}) - -vim.lsp.enable({ - 'lua_ls', - 'clangd', - 'gopls', - 'vtsls', - 'html', -}) +require('DarthMooMancer.lsp') diff --git a/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua b/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua index 85e7bc7..2278161 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua @@ -14,8 +14,6 @@ map('x', 'p', [["_dP]]) map('n', 'vs', ':vsplit') map('n', 'ss', ':split') --- map('n', '[', 'H', { silent = true }) --- map('n', ']', 'K', { silent = true }) map('n', 'E', ':Ex') @@ -31,31 +29,50 @@ map('n', 'uu', function() }) end, { desc = 'native undotree', silent = true }) +---- Used if mini.pairs is not active +-- vim.keymap.set('i', '', function() +-- if vim.fn.pumvisible() == 1 then +-- return '' +-- else +-- return '' +-- end +-- end, { expr = true, silent = true }) + +-- Used if mini.pairs is active +vim.keymap.set('i', '', function() + if vim.fn.pumvisible() == 1 then + return vim.keycode('') .. require('mini.pairs').cr() + end + return require('mini.pairs').cr() +end, { expr = true, replace_keycodes = true, desc = 'Newline, never accept completion' }) + +local qf_group = vim.api.nvim_create_augroup('DiagnosticsQuickfix', { clear = true }) + +local function set_diagnostics_qf() + local items = vim.diagnostic.toqflist(vim.diagnostic.get()) + vim.fn.setqflist(items, 'r') + return #items +end + map('n', 'xx', function() if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then vim.cmd('cclose') return end - local items = vim.diagnostic.toqflist(vim.diagnostic.get()) - if #items == 0 then + if set_diagnostics_qf() == 0 then vim.notify('No diagnostics found', vim.log.levels.WARN) return end - vim.fn.setqflist(items) vim.cmd('copen') end, { desc = 'Toggle diagnostics quickfix' }) -local qf_group = vim.api.nvim_create_augroup('DiagnosticsQuickfix', { clear = true }) - vim.api.nvim_create_autocmd('DiagnosticChanged', { group = qf_group, callback = function() if vim.fn.getqflist({ winid = 0 }).winid == 0 then return end - local items = vim.diagnostic.toqflist(vim.diagnostic.get()) - vim.fn.setqflist(items, 'r') - if #items == 0 then + if set_diagnostics_qf() == 0 then vim.cmd('cclose') end end, diff --git a/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua b/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua new file mode 100644 index 0000000..ba1fd7d --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua @@ -0,0 +1,147 @@ +-- local capabilities = vim.lsp.protocol.make_client_capabilities() +local capabilities = require('blink.cmp').get_lsp_capabilities(nil, true) +vim.lsp.config('*', { + capabilities = capabilities, +}) +if capabilities.workspace then + capabilities.workspace.didChangeWatchedFiles = nil +end + +vim.lsp.config('gopls', { + cmd = { 'gopls' }, + filetypes = { 'go', 'gomod', 'gowork' }, + root_markers = { { 'go.work' }, { 'go.mod' }, { '.git' } }, + settings = { + gopls = { + semanticTokens = true, + }, + }, +}) + +vim.lsp.config('lua_ls', { + cmd = { 'lua-language-server' }, + filetypes = { 'lua' }, + root_markers = { + { '.emmyrc.json', '.luarc.json', '.luarc.jsonc' }, + { '.luacheckrc', '.stylua.toml', 'stylua.toml', 'selene.toml', 'selene.yml' }, + { '.git' }, + }, + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + diagnostics = { globals = { 'vim' } }, + completion = { callSnippet = 'Replace' }, + type = { + checkTableShape = true, -- Warns if you pass a table missing required fields + inferParamType = true, -- Tries to figure out argument types from usage + }, + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME .. '/lua', + + '/Users/andrew/personal/Projects/Lua/vern-nvim/lua', + }, + }, + }, + }, +}) + +vim.lsp.config('clangd', { + cmd = { 'clangd' }, + filetypes = { 'c', 'cpp' }, + root_markers = { + '.clangd', + '.clang-tidy', + '.clang-format', + 'compile_commands.json', + 'compile_flags.txt', + 'configure.ac', + '.git', + }, +}) + +vim.lsp.config('html', { + cmd = { 'vscode-html-language-server', '--stdio' }, + filetypes = { 'html' }, + root_markers = { 'package.json', '.git' }, + init_options = { + provideFormatter = true, + embeddedLanguages = { css = true, javascript = true }, + configurationSection = { 'html', 'css', 'javascript' }, + }, +}) + +vim.lsp.config('vtsls', { + cmd = { 'vtsls', '--stdio' }, + init_options = { hostInfo = 'neovim' }, + filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' }, + settings = { + vtsls = { + autoUseWorkspaceTsdk = true, + experimental = { completion = { enableServerSideFuzzyMatch = true } }, + }, + typescript = { + tsserver = { maxTsServerMemory = 8192 }, + updateImportsOnFileMove = { enabled = 'always' }, + preferences = { importModuleSpecifier = 'non-relative' }, + }, + javascript = { + updateImportsOnFileMove = { enabled = 'always' }, + }, + }, + root_dir = function(bufnr, on_dir) + local root_markers = { + { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' }, + { '.git' }, + } + local deno_root = vim.fs.root(bufnr, { 'deno.json', 'deno.jsonc' }) + local deno_lock_root = vim.fs.root(bufnr, { 'deno.lock' }) + local project_root = vim.fs.root(bufnr, root_markers) + if deno_lock_root and (not project_root or #deno_lock_root > #project_root) then + return + end + if deno_root and (not project_root or #deno_root >= #project_root) then + return + end + on_dir(project_root or vim.fn.getcwd()) + end, +}) + +-- function _G.DarthMooMancer_omnifunc(findstart, base) +-- if findstart == 1 then +-- local col = vim.fn.col('.') +-- local line = vim.fn.getline('.') +-- local before = col > 1 and line:sub(col - 1, col - 1) or '' +-- if before == '' or before:match('%s') then +-- return -3 -- cancel silently, leave completion mode +-- end +-- end +-- return vim.lsp.omnifunc(findstart, base) +-- end +-- +-- vim.api.nvim_create_autocmd('LspAttach', { +-- callback = function(ev) +-- if vim.bo[ev.buf].omnifunc == 'v:lua.vim.lsp.omnifunc' then +-- vim.bo[ev.buf].omnifunc = 'v:lua.DarthMooMancer_omnifunc' +-- end +-- end, +-- }) +-- vim.api.nvim_create_autocmd('LspAttach', { +-- callback = function(ev) +-- local client = vim.lsp.get_client_by_id(ev.data.client_id) +-- if client and client:supports_method('textDocument/completion') then +-- vim.lsp.completion.enable(true, client.id, ev.buf) +-- end +-- end, +-- }) + +vim.lsp.enable({ + 'lua_ls', + 'clangd', + 'gopls', + 'vtsls', + 'html', +}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua index be39f3e..ae6f55c 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua @@ -3,6 +3,7 @@ vim.pack.add({ { src = 'https://github.com/nvim-treesitter/nvim-treesitter' }, { src = 'https://github.com/stevearc/conform.nvim' }, { src = 'https://github.com/alexghergh/nvim-tmux-navigation' }, + { src = 'https://github.com/saghen/blink.cmp', version = vim.version.range('*') }, }) local parsers = { @@ -93,8 +94,8 @@ conform.setup({ cpp = { 'clang-format' }, go = { 'goimports' }, - javascript = { 'prettier', stop_after_first = true }, - typescript = { 'prettier', stop_after_first = true }, + javascript = { 'prettier' }, + typescript = { 'prettier' }, json = { 'prettier' }, html = { 'prettier' }, css = { 'prettier' }, @@ -117,7 +118,6 @@ vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" vim.opt.rtp:append('/Users/andrew/personal/Projects/Lua/vern-nvim') require('vern-nvim').setup({ - workspace_root = '~/personal/Projects_Testing', env = { author = 'DarthMooMancer', }, @@ -132,3 +132,15 @@ require('nvim-tmux-navigation').setup({ right = '', }, }) + +require('blink.cmp').setup({ + completion = { + documentation = { + auto_show = true, + auto_show_delay_ms = 50, + }, + menu = { + scrollbar = false, + }, + }, +}) diff --git a/nvim/.config/nvim/nvim-pack-lock.json b/nvim/.config/nvim/nvim-pack-lock.json index 43b8684..a94e30c 100644 --- a/nvim/.config/nvim/nvim-pack-lock.json +++ b/nvim/.config/nvim/nvim-pack-lock.json @@ -1,5 +1,10 @@ { "plugins": { + "blink.cmp": { + "rev": "78336bc89ee5365633bcf754d93df01678b5c08f", + "src": "https://github.com/saghen/blink.cmp", + "version": ">=0.0.0" + }, "conform.nvim": { "rev": "016802de402556da54c36bd7359b441266b01cdd", "src": "https://github.com/stevearc/conform.nvim" diff --git a/nvim/.config/nvim/stylua.toml b/nvim/.config/nvim/stylua.toml index 48575be..294fd82 100644 --- a/nvim/.config/nvim/stylua.toml +++ b/nvim/.config/nvim/stylua.toml @@ -1,5 +1,5 @@ column_width = 100 -line_endings = "Unix" +# line_endings = "Unix" indent_type = "Spaces" indent_width = 2 quote_style = "AutoPreferSingle"