diff --git a/lua/conf/binds.lua b/lua/conf/binds.lua index 3c47c11..e9f40c1 100644 --- a/lua/conf/binds.lua +++ b/lua/conf/binds.lua @@ -42,6 +42,13 @@ map("i", "", function() end end end, { desc = "Trigger/select next completion" }) +map("i", "", function() + 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" }) diff --git a/lua/core/init.lua b/lua/core/init.lua index 5325cab..2f47744 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -35,45 +35,6 @@ local M = { } M.mason = { - packages = { - formatters = { "black" }, - daps = { "debugpy" }, - lsps = { - "clangd", - "mesonlsp", - "bashls", - "lua_ls", - "jdtls", - "basedpyright" - } - }, - - --- Attempt to install all desired packages. This only really works on first - --- install as mason seems to not remove the paths of the things we uninstall - --- and instead just removes the code, leaving behind it's metadata. - ensure_installed = function() - local to_install = {} - - for _, type in pairs(M.mason.packages) do - for _, pkg in ipairs(type) do - -- HACK: some servers don't have the same name in mason as they do in - -- the vim lsp, we use the vim lsp names, and therefore need to - -- convert them in here when they're incorrect for mason - if pkg == "bashls" then pkg = "bash-language-server" - elseif pkg == "lua_ls" then pkg = "lua-language-server" - end - - if vim.fn.isdirectory(M.mason.get_pkg_path(pkg)) == 0 then - table.insert(to_install, pkg) - end - end - end - - if #to_install > 0 then - vim.cmd.MasonInstall(to_install) - end - end, - --- Gets a path to a package in the Mason registry. --- Prefer this to `get_package`, since the package might not always be --- available yet and trigger errors. diff --git a/lua/core/lsp/completion.lua b/lua/core/lsp/completion.lua index cc4db9a..f8adbbb 100644 --- a/lua/core/lsp/completion.lua +++ b/lua/core/lsp/completion.lua @@ -94,6 +94,19 @@ auto("CompleteDonePre", { 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 + -- 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 diff --git a/lua/core/lsp/init.lua b/lua/core/lsp/init.lua index 15ef9c6..975bf30 100644 --- a/lua/core/lsp/init.lua +++ b/lua/core/lsp/init.lua @@ -2,9 +2,6 @@ local M = {} --- setup vim lsp options function M.setup() - -- ensure the severs are setup - require("core.lsp.servers") - -- confgiure lsp vim.diagnostic.config { virtual_lines = { diff --git a/lua/core/lsp/servers.lua b/lua/core/lsp/servers.lua deleted file mode 100644 index e4a0bb2..0000000 --- a/lua/core/lsp/servers.lua +++ /dev/null @@ -1,11 +0,0 @@ -local servers = require("core").mason.packages.lsps - --- enable the servers I want -for _, server in ipairs(servers) do - -- skip jdtls, we start this on our own - if servers == "jdtls" then - goto continue - end - vim.lsp.enable(server) - ::continue:: -end diff --git a/lua/core/lsp/wtf.lua b/lua/core/lsp/wtf.lua index daf0d7a..308789d 100644 --- a/lua/core/lsp/wtf.lua +++ b/lua/core/lsp/wtf.lua @@ -25,5 +25,12 @@ auto('LspAttach', { if client:supports_method('textDocument/linkedEditingRange') then vim.lsp.linked_editing_range.enable(true, { client_id = client.id }) end + + -- 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 + vim.lsp.on_type_formatting.enable(true, { client_id = client.id }) + end end })