From 35561b6aa5d1cf4efde15bbd72cb4f243d7ed0f2 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Wed, 17 Jul 2024 17:27:53 -0700 Subject: [PATCH] Remove some more v0.7 hacks --- neovim/lua/lazy_plugins.lua | 9 ++-- neovim/lua/plugins/lsp.lua | 87 ++++++--------------------------- neovim/lua/plugins/whichkey.lua | 12 ----- 3 files changed, 22 insertions(+), 86 deletions(-) delete mode 100644 neovim/lua/plugins/whichkey.lua diff --git a/neovim/lua/lazy_plugins.lua b/neovim/lua/lazy_plugins.lua index febaaf7..920835b 100644 --- a/neovim/lua/lazy_plugins.lua +++ b/neovim/lua/lazy_plugins.lua @@ -61,9 +61,12 @@ return { -- Make it easier to discover some of my keymaps { "https://github.com/folke/which-key.nvim", - config = function() - require("plugins.whichkey").configure() - end, + opts = { + triggers_blacklist = { + i = { "j", "k", "`" }, + v = { "j", "k" }, + }, + }, version = "1.x.x", }, -- Better commenting diff --git a/neovim/lua/plugins/lsp.lua b/neovim/lua/plugins/lsp.lua index d26600a..36e8232 100644 --- a/neovim/lua/plugins/lsp.lua +++ b/neovim/lua/plugins/lsp.lua @@ -36,55 +36,16 @@ function M.config_lsp_ui() end) end -local function get_server_capabilities(client) - -- HACK: Support for <0.8 - if client.server_capabilities ~= nil then - return client.server_capabilities - end - - local capabilities = client.resolved_capabilities - if capabilities.documentSymbolProvider == nil then - capabilities.documentSymbolProvider = capabilities.goto_definition - end - if capabilities.documentFormattingProvider == nil then - capabilities.documentFormattingProvider = capabilities.document_formatting - end - if capabilities.documentRangeFormattingProvider == nil then - capabilities.documentRangeFormattingProvider = capabilities.document_range_formatting - end - if capabilities.documentHighlightProvider == nil then - capabilities.documentHighlightProvider = capabilities.document_highlight - end - if capabilities.workspaceSymbolProvider == nil then - -- Not sure what the legacy version of this is - capabilities.workspaceSymbolProvider = capabilities.goto_definition - end - - return capabilities -end - local function get_default_attach(override_capabilities) return function(client, bufnr) -- Allow overriding capabilities to avoid duplicate lsps with capabilities -- Using custom method to extract for <0.8 support - local server_capabilities = get_server_capabilities(client) + local server_capabilities = client.server_capabilities if override_capabilities ~= nil then server_capabilities = vim.tbl_extend("force", server_capabilities, override_capabilities or {}) end - -- Set built in features to use lsp functions (automatic in nvim-0.8) - -- HACK: Support for <0.8 - if vim.fn.has("nvim-0.8") ~= 1 then - vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - if server_capabilities.documentSymbolProvider then - vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc") - end - if server_capabilities.documentFormattingProvider then - vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr()") - end - end - -- Mappings local lsp_keymap = utils.curry_keymap("n", "l", { buffer = bufnr, group_desc = "LSP" }) lsp_keymap("h", vim.lsp.buf.hover, { desc = "Display hover" }) @@ -137,37 +98,21 @@ local function get_default_attach(override_capabilities) end -- Set some keybinds conditional on server capabilities - if vim.fn.has("nvim-0.8") == 1 then - lsp_keymap("f", function() - vim.lsp.buf.format({ async = true }) - end, { desc = "Format code" }) - lsp_keymap("f", function() - vim.lsp.buf.format({ async = true }) - end, { mode = "v", desc = "Format selected code" }) - if server_capabilities.documentFormattingProvider then - vim.api.nvim_create_autocmd({ "BufWritePre" }, { - pattern = { "*.rs", "*.go", "*.sh", "*.lua" }, - callback = function() - vim.lsp.buf.format({ async = false, timeout_ms = 1000 }) - end, - group = vim.api.nvim_create_augroup("lsp_format", { clear = true }), - desc = "Auto format code on save", - }) - end - else - -- HACK: Support for <0.8 with older formatting - lsp_keymap("f", vim.lsp.buf.formatting, { desc = "Format code" }) - lsp_keymap("f", vim.lsp.buf.range_formatting, { mode = "v", desc = "Format selected code" }) - if server_capabilities.documentFormattingProvider then - vim.api.nvim_create_autocmd({ "BufWritePre" }, { - pattern = { "*.rs", "*.go", "*.sh", "*.lua" }, - callback = function() - vim.lsp.buf.formatting_sync(nil, 1000) - end, - group = vim.api.nvim_create_augroup("lsp_format", { clear = true }), - desc = "Auto format code on save", - }) - end + lsp_keymap("f", function() + vim.lsp.buf.format({ async = true }) + end, { desc = "Format code" }) + lsp_keymap("f", function() + vim.lsp.buf.format({ async = true }) + end, { mode = "v", desc = "Format selected code" }) + if server_capabilities.documentFormattingProvider then + vim.api.nvim_create_autocmd({ "BufWritePre" }, { + pattern = { "*.rs", "*.go", "*.sh", "*.lua" }, + callback = function() + vim.lsp.buf.format({ async = false, timeout_ms = 1000 }) + end, + group = vim.api.nvim_create_augroup("lsp_format", { clear = true }), + desc = "Auto format code on save", + }) end -- Set autocommands conditional on server_capabilities diff --git a/neovim/lua/plugins/whichkey.lua b/neovim/lua/plugins/whichkey.lua deleted file mode 100644 index f716752..0000000 --- a/neovim/lua/plugins/whichkey.lua +++ /dev/null @@ -1,12 +0,0 @@ -local M = {} - -function M.configure() - require("which-key").setup({ - triggers_blacklist = { - i = { "j", "k", "`" }, - v = { "j", "k" }, - }, - }) -end - -return M