Update with nvim 0.8 support

This commit is contained in:
ViViDboarder 2022-11-02 16:57:18 -07:00
parent cad8b97da4
commit 61171df4a8
6 changed files with 265 additions and 65 deletions

View File

@ -213,6 +213,7 @@ use({
use({ use({
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
tag = utils.map_version_rule({ tag = utils.map_version_rule({
-- [">=0.8.0"] = utils.nil_val,
[">=0.7.0"] = "v0.1.3", [">=0.7.0"] = "v0.1.3",
[">=0.6.1"] = "v0.1.2", [">=0.6.1"] = "v0.1.2",
[">=0.6.0"] = "v0.1.0", [">=0.6.0"] = "v0.1.0",
@ -283,7 +284,8 @@ use({
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
run = ":TSUpdate", run = ":TSUpdate",
commit = utils.map_version_rule({ commit = utils.map_version_rule({
[">=0.7.0"] = utils.nil_value, [">=0.8.0"] = utils.nil_val,
[">=0.7.0"] = "4cccb6f494eb255b32a290d37c35ca12584c74d0",
[">=0.5.0"] = "a189323454d1215c682c7ad7db3e6739d26339c4", [">=0.5.0"] = "a189323454d1215c682c7ad7db3e6739d26339c4",
}), }),
config = function() config = function()

View File

@ -1,38 +0,0 @@
local function config_airline()
-- Use short-form mode text
vim.g.airline_mode_map = {
["__"] = "-",
["n"] = "N",
["i"] = "I",
["R"] = "R",
["c"] = "C",
["v"] = "V",
["V"] = "V",
[""] = "V",
["s"] = "S",
["S"] = "S",
[""] = "S",
["t"] = "T",
}
-- abbreviate trailing whitespace and mixed indent
vim.g["airline#extensions#whitespace#trailing_format"] = "tw[%s]"
vim.g["airline#extensions#whitespace#mixed_indent_format"] = "i[%s]"
-- Vertical separators for all
vim.g.airline_left_sep = ""
vim.g.airline_left_alt_sep = ""
vim.g.airline_right_sep = ""
vim.g.airline_right_alt_sep = ""
vim.g["airline#extensions#tabline#enabled"] = 1
vim.g["airline#extensions#tabline#left_sep"] = " "
vim.g["airline#extensions#tabline#left_alt_sep"] = "|"
-- Slimmer section z
vim.g.airline_section_z = "%2l/%L:%2v"
-- Skip most common encoding
vim.g["airline#parts#ffenc#skip_expected_string"] = "utf-8[unix]"
-- If UTF-8 symbols don't work, use ASCII
-- vim.g.airline_symbols_ascii = 1
vim.g["airline#extensions#nvimlsp#enabled"] = 1
end
config_airline()

View File

@ -38,12 +38,41 @@ function M.config_lsp_ui()
end) end)
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) local function get_default_attach(override_capabilities)
return function(client, bufnr) return function(client, bufnr)
-- Allow overriding capabilities to avoid duplicate lsps with capabilities -- 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)
if override_capabilities ~= nil then if override_capabilities ~= nil then
client.resolved_capabilities = server_capabilities = vim.tbl_extend("force", server_capabilities, override_capabilities or {})
vim.tbl_extend("force", client.resolved_capabilities, override_capabilities or {})
end end
local function buf_set_keymap(...) local function buf_set_keymap(...)
@ -54,13 +83,16 @@ local function get_default_attach(override_capabilities)
vim.api.nvim_buf_set_option(bufnr, ...) vim.api.nvim_buf_set_option(bufnr, ...)
end end
-- Set built in features to use lsp functions -- Set built in features to use lsp functions (automatic in nvim-0.8)
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- HACK: Support for <0.8
if client.resolved_capabilities.goto_definition then if not vim.fn.has("nvim-0.8") then
buf_set_option("tagfunc", "v:lua.vim.lsp.tagfunc") buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
end if server_capabilities.documentSymbolProvider then
if client.resolved_capabilities.document_formatting then buf_set_option("tagfunc", "v:lua.vim.lsp.tagfunc")
buf_set_option("formatexpr", "v:lua.vim.lsp.formatexpr()") end
if server_capabilities.documentFormattingProvider then
buf_set_option("formatexpr", "v:lua.vim.lsp.formatexpr()")
end
end end
-- Mappings -- Mappings
@ -107,26 +139,39 @@ local function get_default_attach(override_capabilities)
-- Use IncRename if available -- Use IncRename if available
if utils.try_require("inc_rename") ~= nil then if utils.try_require("inc_rename") ~= nil then
lsp_keymap("rn", "<cmd>IncRename()<CR>") vim.keymap.set("n", "<leader>rn", function()
return ":IncRename " .. vim.fn.expand("<cword>")
end, { expr = true, buffer = true, desc = "Rename current symbol" })
end end
-- Set some keybinds conditional on server capabilities -- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then -- HACK: Support for <0.8
if vim.fn.has("nvim-0.8") then
buf_set_keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.format({async=true})<CR>", opts)
buf_set_keymap("v", "<leader>lf", "<cmd>lua vim.lsp.buf.format({async=true})<CR>", opts)
if server_capabilities.documentFormattingProvider then
vim.cmd([[
augroup lsp_format
autocmd!
autocmd BufWritePre *.rs,*.go,*.sh,*.lua lua vim.lsp.buf.format({async=false, timeout_ms=1000})
augroup END
]])
end
else
buf_set_keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) buf_set_keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
vim.cmd([[
augroup lsp_format
autocmd!
autocmd BufWritePre *.rs,*.go,*.sh,*.lua lua vim.lsp.buf.formatting_sync(nil, 1000)
" autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_sync(nil, 1000)
augroup END
]])
end
if client.resolved_capabilities.document_range_formatting then
buf_set_keymap("n", "<leader>lfr", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts) buf_set_keymap("n", "<leader>lfr", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
if server_capabilities.documentFormattingProvider then
vim.cmd([[
augroup lsp_format
autocmd!
autocmd BufWritePre *.rs,*.go,*.sh,*.lua lua vim.lsp.buf.formatting_sync(nil, 1000)
augroup END
]])
end
end end
-- Set autocommands conditional on server_capabilities -- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then if server_capabilities.documentHighlightProvider then
vim.cmd([[ vim.cmd([[
:highlight link LspReferenceRead MatchParen :highlight link LspReferenceRead MatchParen
:highlight link LspReferenceText MatchParen :highlight link LspReferenceText MatchParen
@ -142,15 +187,18 @@ local function get_default_attach(override_capabilities)
-- Some override some fuzzy finder bindings to use lsp sources -- Some override some fuzzy finder bindings to use lsp sources
if utils.try_require("telescope") ~= nil then if utils.try_require("telescope") ~= nil then
-- Replace some Telescope bindings with LSP versions -- Replace some Telescope bindings with LSP versions
if client.resolved_capabilities.goto_definition then if server_capabilities.documentSymbolProvider then
buf_set_keymap("n", "<leader>t", "<cmd>Telescope lsp_document_symbols<CR>", opts) buf_set_keymap("n", "<leader>t", "<cmd>Telescope lsp_document_symbols<CR>", opts)
buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts) end
if server_capabilities.workspaceSymbolProvider then
buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts) buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts)
end end
-- Replace some LSP bindings with Telescope ones -- Replace some LSP bindings with Telescope ones
if client.resolved_capabilities.goto_definition then if server_capabilities.definitionProvider then
lsp_keymap("d", "<cmd>Telescope lsp_definitions<CR>") lsp_keymap("d", "<cmd>Telescope lsp_definitions<CR>")
end
if server_capabilities.typeDefinitionProvider then
lsp_keymap("t", "<cmd>Telescope lsp_type_definition()<CR>") lsp_keymap("t", "<cmd>Telescope lsp_type_definition()<CR>")
end end
lsp_keymap("i", "<cmd>Telescope lsp_implementations<CR>") lsp_keymap("i", "<cmd>Telescope lsp_implementations<CR>")
@ -165,10 +213,11 @@ end
local function merged_capabilities() local function merged_capabilities()
-- Maybe update capabilities -- Maybe update capabilities
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = nil
utils.try_require("cmp-nvim-lsp", function(cmp_nvim_lsp) utils.try_require("cmp-nvim-lsp", function(cmp_nvim_lsp)
capabilities = cmp_nvim_lsp.update_capabilities(capabilities) capabilities = cmp_nvim_lsp.default_capabilities()
end) end)
return capabilities return capabilities
end end

View File

@ -61,6 +61,7 @@ function M.config_lualine(theme_name)
end end
local diagnostic_plugin = "nvim_diagnostic" local diagnostic_plugin = "nvim_diagnostic"
-- HACK: Support for <0.6
if vim.fn.has("nvim-0.6.0") ~= 1 then if vim.fn.has("nvim-0.6.0") ~= 1 then
diagnostic_plugin = "nvim_lsp" diagnostic_plugin = "nvim_lsp"
end end

View File

@ -67,6 +67,7 @@ function M.configure(options)
null_ls.builtins.diagnostics.hadolint, null_ls.builtins.diagnostics.hadolint,
} }
-- HACK: Support for <0.6
if vim.fn.has("nvim-0.6.0") then if vim.fn.has("nvim-0.6.0") then
vim.list_extend(sources, { vim.list_extend(sources, {
-- Text -- Text

View File

@ -0,0 +1,185 @@
{
"LuaSnip": {
"commit": "619796e"
},
"cmp-buffer": {
"commit": "3022dbc"
},
"cmp-nvim-lsp": {
"commit": "78924d1"
},
"cmp-spell": {
"commit": "60584cb"
},
"cmp_luasnip": {
"commit": "1809552"
},
"colorbuddy.vim": {
"commit": "cdb5b06"
},
"dark-notify": {
"commit": "891adc0"
},
"file-line": {
"commit": "67c3590"
},
"friendly-snippets": {
"commit": "c93311f"
},
"goyo.vim": {
"commit": "7f5d35a"
},
"impatient.nvim": {
"commit": "b842e16"
},
"inc-rename.nvim": {
"commit": "b71ff4b"
},
"limelight.vim": {
"commit": "86aaec1"
},
"lsp_signature.nvim": {
"commit": "7a1845e"
},
"lualine.nvim": {
"commit": "3325d5d"
},
"lush.nvim": {
"commit": "57e0b85"
},
"mason-lspconfig.nvim": {
"commit": "a910b4d"
},
"mason.nvim": {
"commit": "1ec0dd2"
},
"neodev.nvim": {
"commit": "5e68553"
},
"null-ls.nvim": {
"commit": "f1add23"
},
"nvim-cmp": {
"commit": "9bb8ee6"
},
"nvim-colorizer.lua": {
"commit": "36c610a"
},
"nvim-gps": {
"commit": "f4734df"
},
"nvim-lspconfig": {
"commit": "99596a8"
},
"nvim-solarized-lua": {
"commit": "b5a77b5"
},
"nvim-treesitter": {
"commit": "c6992f6"
},
"nvim-treesitter-refactor": {
"commit": "75f5895"
},
"nvim-treesitter-textobjects": {
"commit": "13739a5"
},
"packer.nvim": {
"commit": "6afb674"
},
"plenary.nvim": {
"commit": "4b7e520"
},
"popup.nvim": {
"commit": "b7404d3"
},
"rust.vim": {
"commit": "1cdc5cb"
},
"startuptime.vim": {
"commit": "dfa57f5"
},
"tcomment_vim": {
"commit": "e77e1bf"
},
"telescope-file-browser.nvim": {
"commit": "2429ecf"
},
"telescope.nvim": {
"commit": "b79cd6c"
},
"todo-comments.nvim": {
"commit": "530eb3a"
},
"tokyonight.nvim": {
"commit": "29e2c68"
},
"trouble.nvim": {
"commit": "ed65f84"
},
"vim-android": {
"commit": "8911f86"
},
"vim-argwrap": {
"commit": "feaba6b"
},
"vim-endwise": {
"commit": "4e5c835"
},
"vim-eunuch": {
"commit": "291ef1f"
},
"vim-forcedotcom": {
"commit": "a30ba7e"
},
"vim-fugitive": {
"commit": "01f3e0a"
},
"vim-grepper": {
"commit": "2b93535"
},
"vim-gutentags": {
"commit": "b77b8fa"
},
"vim-pencil": {
"commit": "5b4110d"
},
"vim-polyglot": {
"commit": "bc8a81d"
},
"vim-repeat": {
"commit": "24afe92"
},
"vim-rsi": {
"commit": "4c673fb"
},
"vim-startify": {
"commit": "81e36c3"
},
"vim-surround": {
"commit": "3d188ed"
},
"vim-textobj-sentence": {
"commit": "c5dd562"
},
"vim-textobj-user": {
"commit": "41a675d"
},
"vim-togglelist": {
"commit": "48f0d30"
},
"vim-vinegar": {
"commit": "bb1bcdd"
},
"which-key.nvim": {
"commit": "61553ae"
},
"wombat.nvim": {
"commit": "96989b1"
},
"wombat256.vim": {
"commit": "8734ba4"
},
"wombuddy.nvim": {
"commit": "29deb8f"
}
}