Update for nvim 0.9+

This commit is contained in:
ViViDboarder 2023-06-01 17:11:50 -07:00
parent 625879cacb
commit b4cb73b4e4
5 changed files with 254 additions and 28 deletions

View File

@ -24,6 +24,7 @@ local use = packer.use
packer.init({ packer.init({
-- Always load default -- Always load default
snapshot = utils.map_version_rule({ snapshot = utils.map_version_rule({
[">=0.9.0"] = "latest-0.9",
[">=0.8.0"] = "latest-0.8", [">=0.8.0"] = "latest-0.8",
[">=0.7.0"] = "latest-0.7", [">=0.7.0"] = "latest-0.7",
[">=0.5.0"] = "latest", [">=0.5.0"] = "latest",
@ -37,6 +38,10 @@ packer.init({
}) })
-- Load things faster! -- Load things faster!
if vim.fn.has("nvim-0.9.0") == 1 then
-- Not needed on nvim 0.9+
vim.loader.enable()
else
use({ use({
"lewis6991/impatient.nvim", "lewis6991/impatient.nvim",
config = [[require('impatient')]], config = [[require('impatient')]],
@ -46,6 +51,7 @@ use({
[">=0.5.0"] = "v0.1", [">=0.5.0"] = "v0.1",
}), }),
}) })
end
-- Let Packer manage and lazyload itself -- Let Packer manage and lazyload itself
use({ use({
@ -177,20 +183,24 @@ use({
}) })
-- Custom status line -- Custom status line
-- nvim-gps is deprecated in favor of https://github.com/SmiteshP/nvim-navic using LSP rather than TS use({
use({ "SmiteshP/nvim-gps", requires = "nvim-treesitter/nvim-treesitter" }) "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({ use({
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
config = function() config = function()
require("plugins.lualine").config_lualine() require("plugins.lualine").config_lualine()
end, end,
requires = { after = vim.fn.has("nvim-0.7.0") == 1 and "nvim-navic" or "nvim-gps",
-- Show my current location in my status bar
-- { "SmiteshP/nvim-gps", requires = "nvim-treesitter/nvim-treesitter" },
},
after = {
"nvim-gps",
},
}) })
-- On Mac, update colors when dark mode changes -- On Mac, update colors when dark mode changes
@ -218,7 +228,7 @@ use({
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
tag = utils.map_version_rule({ tag = utils.map_version_rule({
-- [">=0.8.0"] = utils.nil_val, -- [">=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.1"] = "v0.1.2",
[">=0.6.0"] = "v0.1.0", [">=0.6.0"] = "v0.1.0",
}), }),
@ -257,8 +267,14 @@ use({
-- Generic linter/formatters in diagnostics API -- Generic linter/formatters in diagnostics API
use({ use({
"jose-elias-alvarez/null-ls.nvim", "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({ 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.6.0"] = "4b403d2d724f48150ded41189ae4866492a8158b",
[">=0.5.1"] = "739a98c12bedaa2430c4a3c08d1d22ad6c16513e", [">=0.5.1"] = "739a98c12bedaa2430c4a3c08d1d22ad6c16513e",
[">=0.5.0"] = "3e7390735501d0507bf2c2b5c2e7a16f58deeb81", [">=0.5.0"] = "3e7390735501d0507bf2c2b5c2e7a16f58deeb81",

View File

@ -143,7 +143,6 @@ local function get_default_attach(override_capabilities)
end end
-- Set some keybinds conditional on server capabilities -- Set some keybinds conditional on server capabilities
-- HACK: Support for <0.8
if vim.fn.has("nvim-0.8") == 1 then if vim.fn.has("nvim-0.8") == 1 then
buf_set_keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.format({async=true})<CR>", opts) 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) buf_set_keymap("v", "<leader>lf", "<cmd>lua vim.lsp.buf.format({async=true})<CR>", opts)
@ -156,6 +155,7 @@ local function get_default_attach(override_capabilities)
]]) ]])
end end
else else
-- HACK: Support for <0.8
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)
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 if server_capabilities.documentFormattingProvider then
@ -206,6 +206,13 @@ local function get_default_attach(override_capabilities)
buf_set_keymap("n", "<leader>ca", "<cmd>Telescope lsp_code_actions<CR>", opts) buf_set_keymap("n", "<leader>ca", "<cmd>Telescope lsp_code_actions<CR>", opts)
buf_set_keymap("v", "<leader>lA", "<cmd>Telescope lsp_range_code_actions<CR>", opts) buf_set_keymap("v", "<leader>lA", "<cmd>Telescope lsp_range_code_actions<CR>", opts)
end 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
end end
@ -249,7 +256,13 @@ function M.config_lsp()
-- Auto setup mason installed servers -- Auto setup mason installed servers
utils.try_require("mason-lspconfig", function(mason_lspconfig) utils.try_require("mason-lspconfig", function(mason_lspconfig)
-- Get list of servers that are installed but not set up -- 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) local needs_setup = vim.tbl_filter(function(server)
return not vim.tbl_contains(already_setup, server) return not vim.tbl_contains(already_setup, server)
end, mason_lspconfig.get_installed_servers()) end, mason_lspconfig.get_installed_servers())

View File

@ -46,9 +46,9 @@ function M.config_lualine(theme_name)
theme_name = "wombat" theme_name = "wombat"
end end
local gps = {} -- gps / navic
if utils.is_plugin_loaded("nvim-gps") then local code_loc = {}
gps = require("nvim-gps") utils.try_require("nvim-gps", function(gps)
gps.setup({ gps.setup({
icons = { icons = {
["class-name"] = "(c) ", ["class-name"] = "(c) ",
@ -58,7 +58,12 @@ function M.config_lualine(theme_name)
["tag-name"] = "(t) ", ["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" local diagnostic_plugin = "nvim_diagnostic"
-- HACK: Support for <0.6 -- HACK: Support for <0.6
@ -83,7 +88,7 @@ function M.config_lualine(theme_name)
}, },
}, },
lualine_b = { "FugitiveHead", "diff" }, 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_x = { M.custom_ffenc, "filetype" },
lualine_y = { "progress", "location" }, lualine_y = { "progress", "location" },
lualine_z = { lualine_z = {

View File

@ -5,11 +5,18 @@ local function disable_formatter_filetypes_for_existing_servers(sources, preserv
-- Aggregate filetypes with language servers -- Aggregate filetypes with language servers
local server_filetypes = {} local server_filetypes = {}
utils.try_require("lspconfig", function(lsp_config) 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) vim.tbl_map(function(server)
if lsp_config[server].filetypes ~= nil then if lsp_config[server].filetypes ~= nil then
vim.list_extend(server_filetypes, lsp_config[server].filetypes) vim.list_extend(server_filetypes, lsp_config[server].filetypes)
end end
end, lsp_config.available_servers()) end, available_servers)
end) end)
-- Remove filetypes for formatters I want to preserve -- Remove filetypes for formatters I want to preserve

View File

@ -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"
}
}