From b4cb73b4e4c8fca528d5b70f376abe670ad63240 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 1 Jun 2023 17:11:50 -0700 Subject: [PATCH] Update for nvim 0.9+ --- neovim/lua/plugins.lua | 56 ++++++--- neovim/lua/plugins/lsp.lua | 17 ++- neovim/lua/plugins/lualine.lua | 15 ++- neovim/lua/plugins/null-ls/init.lua | 9 +- neovim/packer_snapshots/latest-0.9 | 185 ++++++++++++++++++++++++++++ 5 files changed, 254 insertions(+), 28 deletions(-) create mode 100644 neovim/packer_snapshots/latest-0.9 diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index 722c15b..ac91ffa 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -24,6 +24,7 @@ local use = packer.use packer.init({ -- Always load default snapshot = utils.map_version_rule({ + [">=0.9.0"] = "latest-0.9", [">=0.8.0"] = "latest-0.8", [">=0.7.0"] = "latest-0.7", [">=0.5.0"] = "latest", @@ -37,15 +38,20 @@ packer.init({ }) -- Load things faster! -use({ - "lewis6991/impatient.nvim", - config = [[require('impatient')]], - tag = utils.map_version_rule({ - [">=0.7.0"] = utils.nil_val, - [">0.6.0"] = "v0.2", - [">=0.5.0"] = "v0.1", - }), -}) +if vim.fn.has("nvim-0.9.0") == 1 then + -- Not needed on nvim 0.9+ + vim.loader.enable() +else + use({ + "lewis6991/impatient.nvim", + config = [[require('impatient')]], + tag = utils.map_version_rule({ + [">=0.7.0"] = utils.nil_val, + [">0.6.0"] = "v0.2", + [">=0.5.0"] = "v0.1", + }), + }) +end -- Let Packer manage and lazyload itself use({ @@ -177,20 +183,24 @@ use({ }) -- Custom status line --- nvim-gps is deprecated in favor of https://github.com/SmiteshP/nvim-navic using LSP rather than TS -use({ "SmiteshP/nvim-gps", requires = "nvim-treesitter/nvim-treesitter" }) +use({ + "SmiteshP/nvim-gps", + requires = "nvim-treesitter/nvim-treesitter", + disable = vim.fn.has("nvim-0.7.0") == 1, +}) +-- Replaces gps for 0.7+ +use({ + "SmiteshP/nvim-navic", + requires = "neovim/nvim-lspconfig", + disable = vim.fn.has("nvim-0.7.0") ~= 1, +}) + use({ "nvim-lualine/lualine.nvim", config = function() require("plugins.lualine").config_lualine() end, - requires = { - -- Show my current location in my status bar - -- { "SmiteshP/nvim-gps", requires = "nvim-treesitter/nvim-treesitter" }, - }, - after = { - "nvim-gps", - }, + after = vim.fn.has("nvim-0.7.0") == 1 and "nvim-navic" or "nvim-gps", }) -- On Mac, update colors when dark mode changes @@ -218,7 +228,7 @@ use({ "neovim/nvim-lspconfig", tag = utils.map_version_rule({ -- [">=0.8.0"] = utils.nil_val, - [">=0.7.0"] = "v0.1.3", + [">=0.7.0"] = "v0.1.6", [">=0.6.1"] = "v0.1.2", [">=0.6.0"] = "v0.1.0", }), @@ -257,8 +267,14 @@ use({ -- Generic linter/formatters in diagnostics API use({ "jose-elias-alvarez/null-ls.nvim", + branch = utils.map_version_rule({ + [">=0.8.0"] = utils.nil_val, + [">=0.7.0"] = "0.7-compat", + ["<0.7.0"] = utils.nil_val, -- use pinned commits + }), commit = utils.map_version_rule({ - [">=0.7.0"] = utils.nil_val, + [">=0.8.0"] = utils.nil_val, + [">=0.7.0"] = utils.nil_val, -- Use pinned branch [">=0.6.0"] = "4b403d2d724f48150ded41189ae4866492a8158b", [">=0.5.1"] = "739a98c12bedaa2430c4a3c08d1d22ad6c16513e", [">=0.5.0"] = "3e7390735501d0507bf2c2b5c2e7a16f58deeb81", diff --git a/neovim/lua/plugins/lsp.lua b/neovim/lua/plugins/lsp.lua index 983b0a7..51b70e6 100644 --- a/neovim/lua/plugins/lsp.lua +++ b/neovim/lua/plugins/lsp.lua @@ -143,7 +143,6 @@ local function get_default_attach(override_capabilities) end -- Set some keybinds conditional on server capabilities - -- HACK: Support for <0.8 if vim.fn.has("nvim-0.8") == 1 then buf_set_keymap("n", "lf", "lua vim.lsp.buf.format({async=true})", opts) buf_set_keymap("v", "lf", "lua vim.lsp.buf.format({async=true})", opts) @@ -156,6 +155,7 @@ local function get_default_attach(override_capabilities) ]]) end else + -- HACK: Support for <0.8 buf_set_keymap("n", "lf", "lua vim.lsp.buf.formatting()", opts) buf_set_keymap("n", "lfr", "lua vim.lsp.buf.range_formatting()", opts) if server_capabilities.documentFormattingProvider then @@ -206,6 +206,13 @@ local function get_default_attach(override_capabilities) buf_set_keymap("n", "ca", "Telescope lsp_code_actions", opts) buf_set_keymap("v", "lA", "Telescope lsp_range_code_actions", opts) end + + -- Attach navic for statusline location + if server_capabilities.documentSymbolProvider then + utils.try_require("nvim-navic", function(navic) + navic.attach(client, bufnr) + end) + end end end @@ -249,7 +256,13 @@ function M.config_lsp() -- Auto setup mason installed servers utils.try_require("mason-lspconfig", function(mason_lspconfig) -- Get list of servers that are installed but not set up - local already_setup = lsp_config.available_servers() + local already_setup + if lsp_config["util"] and lsp_config.util["available_servers"] then + already_setup = lsp_config.util.available_servers() + else + -- HACK: For lspconfig versions lower than 0.1.4 + already_setup = lsp_config.available_servers() + end local needs_setup = vim.tbl_filter(function(server) return not vim.tbl_contains(already_setup, server) end, mason_lspconfig.get_installed_servers()) diff --git a/neovim/lua/plugins/lualine.lua b/neovim/lua/plugins/lualine.lua index 0ac895c..753bd08 100644 --- a/neovim/lua/plugins/lualine.lua +++ b/neovim/lua/plugins/lualine.lua @@ -46,9 +46,9 @@ function M.config_lualine(theme_name) theme_name = "wombat" end - local gps = {} - if utils.is_plugin_loaded("nvim-gps") then - gps = require("nvim-gps") + -- gps / navic + local code_loc = {} + utils.try_require("nvim-gps", function(gps) gps.setup({ icons = { ["class-name"] = "(c) ", @@ -58,7 +58,12 @@ function M.config_lualine(theme_name) ["tag-name"] = "(t) ", }, }) - end + code_loc = { gps.get_location, cond = gps.is_available } + end) + utils.try_require("nvim-navic", function(navic) + navic.setup() + code_loc = { navic.get_location, cond = navic.is_available } + end) local diagnostic_plugin = "nvim_diagnostic" -- HACK: Support for <0.6 @@ -83,7 +88,7 @@ function M.config_lualine(theme_name) }, }, lualine_b = { "FugitiveHead", "diff" }, - lualine_c = { { "filename", path = 1 }, { gps.get_location, cond = gps.is_available } }, + lualine_c = { { "filename", path = 1 }, code_loc }, lualine_x = { M.custom_ffenc, "filetype" }, lualine_y = { "progress", "location" }, lualine_z = { diff --git a/neovim/lua/plugins/null-ls/init.lua b/neovim/lua/plugins/null-ls/init.lua index d30be50..35cd82d 100644 --- a/neovim/lua/plugins/null-ls/init.lua +++ b/neovim/lua/plugins/null-ls/init.lua @@ -5,11 +5,18 @@ local function disable_formatter_filetypes_for_existing_servers(sources, preserv -- Aggregate filetypes with language servers local server_filetypes = {} utils.try_require("lspconfig", function(lsp_config) + local available_servers + if lsp_config["util"] and lsp_config.util["available_servers"] then + available_servers = lsp_config.util.available_servers() + else + -- HACK: For lspconfig versions lower than 0.1.4 + available_servers = lsp_config.available_servers() + end vim.tbl_map(function(server) if lsp_config[server].filetypes ~= nil then vim.list_extend(server_filetypes, lsp_config[server].filetypes) end - end, lsp_config.available_servers()) + end, available_servers) end) -- Remove filetypes for formatters I want to preserve diff --git a/neovim/packer_snapshots/latest-0.9 b/neovim/packer_snapshots/latest-0.9 new file mode 100644 index 0000000..5a366ac --- /dev/null +++ b/neovim/packer_snapshots/latest-0.9 @@ -0,0 +1,185 @@ +{ + "LuaSnip": { + "commit": "51ebb4b" + }, + "cmp-buffer": { + "commit": "3022dbc" + }, + "cmp-nvim-lsp": { + "commit": "0e6b2ed" + }, + "cmp-spell": { + "commit": "60584cb" + }, + "cmp_luasnip": { + "commit": "1809552" + }, + "colorbuddy.vim": { + "commit": "cdb5b06" + }, + "dark-notify": { + "commit": "891adc0" + }, + "file-line": { + "commit": "67c3590" + }, + "friendly-snippets": { + "commit": "0dd6114" + }, + "goyo.vim": { + "commit": "fa0263d" + }, + "inc-rename.nvim": { + "commit": "fb1b746" + }, + "limelight.vim": { + "commit": "86aaec1" + }, + "lsp_signature.nvim": { + "commit": "17ff7a4" + }, + "lualine.nvim": { + "commit": "05d78e9" + }, + "lush.nvim": { + "commit": "fb148c0" + }, + "mason-lspconfig.nvim": { + "commit": "f0ce33f" + }, + "mason.nvim": { + "commit": "7d7efc7" + }, + "neodev.nvim": { + "commit": "358f11c" + }, + "null-ls.nvim": { + "commit": "c89333e" + }, + "nvim-cmp": { + "commit": "fc0f694" + }, + "nvim-colorizer.lua": { + "commit": "36c610a" + }, + "nvim-lspconfig": { + "commit": "255e07c" + }, + "nvim-navic": { + "commit": "15704c6" + }, + "nvim-notify": { + "commit": "f3024b9" + }, + "nvim-solarized-lua": { + "commit": "7bd46fa" + }, + "nvim-treesitter": { + "commit": "56c6352" + }, + "nvim-treesitter-refactor": { + "commit": "65ad2ec" + }, + "nvim-treesitter-textobjects": { + "commit": "95b76b9" + }, + "packer.nvim": { + "commit": "1d0cf98" + }, + "plenary.nvim": { + "commit": "499e074" + }, + "popup.nvim": { + "commit": "b7404d3" + }, + "rust.vim": { + "commit": "889b9a7" + }, + "startuptime.vim": { + "commit": "dfa57f5" + }, + "tcomment_vim": { + "commit": "b4930f9" + }, + "telescope-file-browser.nvim": { + "commit": "6cf29d5" + }, + "telescope.nvim": { + "commit": "b79cd6c" + }, + "todo-comments.nvim": { + "commit": "09b0b17" + }, + "tokyonight.nvim": { + "commit": "161114b" + }, + "trouble.nvim": { + "commit": "324c977" + }, + "vim-android": { + "commit": "8911f86" + }, + "vim-argwrap": { + "commit": "feaba6b" + }, + "vim-endwise": { + "commit": "e714ac3" + }, + "vim-eunuch": { + "commit": "291ef1f" + }, + "vim-forcedotcom": { + "commit": "a30ba7e" + }, + "vim-fugitive": { + "commit": "5f0d280" + }, + "vim-grepper": { + "commit": "2b93535" + }, + "vim-gutentags": { + "commit": "1337b18" + }, + "vim-pencil": { + "commit": "6d70438" + }, + "vim-polyglot": { + "commit": "bc8a81d" + }, + "vim-repeat": { + "commit": "24afe92" + }, + "vim-rsi": { + "commit": "4554063" + }, + "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": "e271c28" + }, + "wombat.nvim": { + "commit": "96989b1" + }, + "wombat256.vim": { + "commit": "8734ba4" + }, + "wombuddy.nvim": { + "commit": "29deb8f" + } +}