minor updates sync

This commit is contained in:
Solomon Laing 2023-12-04 09:24:09 +10:30
parent c2a74cff58
commit 8de69d02bd
6 changed files with 337 additions and 337 deletions

View File

@ -7,7 +7,7 @@ return {
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
"hrsh7th/cmp-emoji", "hrsh7th/cmp-emoji",
"hrsh7th/cmp-buffer", "hrsh7th/cmp-buffer",
"saadparwaiz1/cmp_luasnip", -- "saadparwaiz1/cmp_luasnip",
{ {
"zbirenbaum/copilot-cmp", "zbirenbaum/copilot-cmp",
dependencies = "copilot.lua", dependencies = "copilot.lua",
@ -31,11 +31,11 @@ return {
completion = { completion = {
completeopt = "menu,menuone,noinsert", completeopt = "menu,menuone,noinsert",
}, },
snippet = { -- snippet = {
expand = function(args) -- expand = function(args)
require("luasnip").lsp_expand(args.body) -- require("luasnip").lsp_expand(args.body)
end, -- end,
}, -- },
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
@ -47,7 +47,7 @@ return {
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, -- { name = "luasnip" },
{ name = "path" }, { name = "path" },
{ name = "emoji" }, { name = "emoji" },
{ name = "buffer" }, { name = "buffer" },

View File

@ -1,31 +1,32 @@
return { return {
{ {
"folke/todo-comments.nvim", "folke/todo-comments.nvim",
cmd = { "TodoTrouble", "TodoTelescope" }, cmd = { "TodoTrouble", "TodoTelescope" },
event = "BufReadPost", event = "BufReadPost",
config = true, config = true,
-- stylua: ignore -- stylua: ignore
keys = { keys = {
{ "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, { "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" },
{ "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" },
{ "<leader>tt", "<cmd>TodoTrouble<cr>", desc = "Todo Trouble" }, { "<leader>tt", "<cmd>TodoTrouble<cr>", desc = "Todo Trouble" },
{ "<leader>tT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo Trouble" }, { "<leader>tT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo Trouble" },
{ "<leader>tf", "<cmd>TodoTelescope<cr>", desc = "Todo Telescope" }, { "<leader>tf", "<cmd>TodoTelescope<cr>", desc = "Todo Telescope" },
}, },
}, },
{ "JoosepAlviste/nvim-ts-context-commentstring" }, { "JoosepAlviste/nvim-ts-context-commentstring" },
{ {
"echasnovski/mini.comment", "echasnovski/mini.comment",
event = "VeryLazy", event = "VeryLazy",
opts = { opts = {
hooks = { hooks = {
pre = function() pre = function()
require("ts_context_commentstring.internal").update_commentstring({}) require('ts_context_commentstring').setup {}
end, vim.g.skip_ts_context_commentstring_module = true
}, end,
}, },
config = function(_, opts) },
require("mini.comment").setup(opts) config = function(_, opts)
end, require("mini.comment").setup(opts)
}, end,
},
} }

View File

@ -1,222 +1,222 @@
return { return {
-- lspconfig -- lspconfig
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
event = "BufReadPre", event = "BufReadPre",
dependencies = { dependencies = {
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true }, { "folke/neoconf.nvim", cmd = "Neoconf", config = true },
{ "folke/neodev.nvim", config = true }, { "folke/neodev.nvim", config = true },
"mason.nvim", "mason.nvim",
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
}, },
opts = { opts = {
-- options for vim.diagnostic.config() -- options for vim.diagnostic.config()
diagnostics = { diagnostics = {
underline = true, underline = true,
update_in_insert = true, update_in_insert = true,
virtual_text = { spacing = 4, prefix = "" }, virtual_text = { spacing = 4, prefix = "" },
severity_sort = true, severity_sort = true,
}, },
autoformat = true, autoformat = true,
servers = { servers = {
lua_ls = { lua_ls = {
mason = true, mason = true,
settings = { settings = {
Lua = { Lua = {
workspace = { workspace = {
checkThirdParty = false, checkThirdParty = false,
}, },
completion = { completion = {
callSnippet = "Replace", callSnippet = "Replace",
}, },
}, },
}, },
}, },
ltex = { ltex = {
mason = true, mason = true,
settings = { settings = {
ltex = { ltex = {
language = "en-AU", language = "en-AU",
}, },
}, },
}, },
rust_analyzer = { rust_analyzer = {
mason = false, mason = false,
cmd = { cmd = {
"rustup", "rustup",
"run", "run",
"stable", "stable",
"rust-analyzer", "rust-analyzer",
}, },
}, },
omnisharp = {}, omnisharp = {},
}, },
setup = { setup = {
-- additional setup can be added here. -- additional setup can be added here.
omnisharp = function(_, _) omnisharp = function(_, _)
require("lazyvim.utils").on_attach(function(client, _) require("lazyvim.utils").on_attach(function(client, _)
if client.name == "omnisharp" then if client.name == "omnisharp" then
---@type string[] ---@type string[]
local tokenModifiers = local tokenModifiers =
client.server_capabilities.semanticTokensProvider.legend.tokenModifiers client.server_capabilities.semanticTokensProvider.legend.tokenModifiers
for i, v in ipairs(tokenModifiers) do for i, v in ipairs(tokenModifiers) do
tokenModifiers[i] = v:gsub(" ", "_") tokenModifiers[i] = v:gsub(" ", "_")
end end
---@type string[] ---@type string[]
local tokenTypes = client.server_capabilities.semanticTokensProvider.legend.tokenTypes local tokenTypes = client.server_capabilities.semanticTokensProvider.legend.tokenTypes
for i, v in ipairs(tokenTypes) do for i, v in ipairs(tokenTypes) do
tokenTypes[i] = v:gsub(" ", "_") tokenTypes[i] = v:gsub(" ", "_")
end end
end end
end) end)
return false return false
end, end,
}, },
}, },
config = function(_, opts) config = function(_, opts)
local Util = require("lazyvim.utils") local Util = require("lazyvim.utils")
-- setup autoformat -- setup autoformat
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
-- setup formatting and keymaps -- setup formatting and keymaps
Util.on_attach(function(client, buffer) Util.on_attach(function(client, buffer)
require("lazyvim.plugins.lsp.format").on_attach(client, buffer) require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
end) end)
-- diagnostics -- diagnostics
for name, icon in pairs(require("lazyvim.config.icons").diagnostics) do for name, icon in pairs(require("lazyvim.config.icons").diagnostics) do
name = "DiagnosticSign" .. name name = "DiagnosticSign" .. name
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
end end
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "" opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and ""
or function(diagnostic) or function(diagnostic)
local icons = require("lazyvim.config").icons.diagnostics local icons = require("lazyvim.config").icons.diagnostics
for d, icon in pairs(icons) do for d, icon in pairs(icons) do
if diagnostic.severity == vim.diagnostic.severity[d:upper()] then if diagnostic.severity == vim.diagnostic.severity[d:upper()] then
return icon return icon
end end
end end
end end
end end
vim.diagnostic.config(vim.deepcopy(opts.diagnostics)) vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
local servers = opts.servers local servers = opts.servers
local capabilities = vim.tbl_deep_extend( local capabilities = vim.tbl_deep_extend(
"force", "force",
{}, {},
vim.lsp.protocol.make_client_capabilities(), vim.lsp.protocol.make_client_capabilities(),
require("cmp_nvim_lsp").default_capabilities(), require("cmp_nvim_lsp").default_capabilities(),
opts.capabilities or {} opts.capabilities or {}
) )
local function setup(server) local function setup(server)
local server_opts = vim.tbl_deep_extend("force", { local server_opts = vim.tbl_deep_extend("force", {
capabilities = vim.deepcopy(capabilities), capabilities = vim.deepcopy(capabilities),
}, servers[server] or {}) }, servers[server] or {})
if opts.setup[server] then if opts.setup[server] then
if opts.setup[server](server, server_opts) then if opts.setup[server](server, server_opts) then
return return
end end
elseif opts.setup["*"] then elseif opts.setup["*"] then
if opts.setup["*"](server, server_opts) then if opts.setup["*"](server, server_opts) then
return return
end end
end end
require("lspconfig")[server].setup(server_opts) require("lspconfig")[server].setup(server_opts)
end end
-- get all the servers that are available thourgh mason-lspconfig -- get all the servers that are available thourgh mason-lspconfig
local have_mason, mlsp = pcall(require, "mason-lspconfig") local have_mason, mlsp = pcall(require, "mason-lspconfig")
local all_mslp_servers = {} local all_mslp_servers = {}
if have_mason then if have_mason then
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package) all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
end end
local ensure_installed = {} ---@type string[] local ensure_installed = {} ---@type string[]
for server, server_opts in pairs(servers) do for server, server_opts in pairs(servers) do
if server_opts then if server_opts then
server_opts = server_opts == true and {} or server_opts server_opts = server_opts == true and {} or server_opts
-- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
setup(server) setup(server)
else else
ensure_installed[#ensure_installed + 1] = server ensure_installed[#ensure_installed + 1] = server
end end
end end
end end
if have_mason then if have_mason then
mlsp.setup({ ensure_installed = ensure_installed }) mlsp.setup({ ensure_installed = ensure_installed })
mlsp.setup_handlers({ setup }) mlsp.setup_handlers({ setup })
end end
end, end,
}, },
-- formatting -- formatting
{ {
"stevearc/conform.nvim", "stevearc/conform.nvim",
opts = { opts = {
formatters_by_ft = { formatters_by_ft = {
lua = { "stylua" }, lua = { "stylua" },
-- Conform will run multiple formatters sequentially -- Conform will run multiple formatters sequentially
python = { "isort", "black" }, python = { "isort", "black" },
-- Use a sub-list to run only the first available formatter -- Use a sub-list to run only the first available formatter
typescript = { { "prettierd", "prettier" } }, typescript = { { "prettierd", "prettier" } },
cs = { "csharpier" }, cs = { "csharpier" },
}, },
formatters = { formatters = {
csharpier = { csharpier = {
command = "dotnet-csharpier", command = "dotnet-csharpier",
args = { "--write-stdout" }, args = { "--write-stdout" },
}, },
}, },
}, },
}, },
-- cmdline tools and lsp servers -- cmdline tools and lsp servers
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
cmd = "Mason", cmd = "Mason",
keys = { { "<leader>lM", "<cmd>Mason<cr>", desc = "Mason" } }, keys = { { "<leader>lM", "<cmd>Mason<cr>", desc = "Mason" } },
opts = { opts = {
automatic_istallation = false, automatic_istallation = false,
ensure_installed = { ensure_installed = {
"stylua", "stylua",
"shellcheck", "shellcheck",
"shfmt", "shfmt",
}, },
}, },
config = function(_, opts) config = function(_, opts)
require("mason").setup() require("mason").setup()
local mr = require("mason-registry") local mr = require("mason-registry")
for _, tool in ipairs(opts.ensure_installed) do for _, tool in ipairs(opts.ensure_installed) do
local p = mr.get_package(tool) local p = mr.get_package(tool)
if not p:is_installed() then if not p:is_installed() then
p:install() p:install()
end end
end end
end, end,
}, },
-- language specific tooling -- language specific tooling
{ {
"simrat39/rust-tools.nvim", "simrat39/rust-tools.nvim",
opts = { opts = {
server = { server = {
on_attach = function(_, bufnr) on_attach = function(_, bufnr)
local rt = require("rust-tools") local rt = require("rust-tools")
-- Hover actions -- Hover actions
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr }) vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups -- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr }) vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
end, end,
}, },
}, },
}, },
} }

View File

@ -1,53 +1,53 @@
local M = {} local M = {}
function M.disable_deno_formatting(client) function M.disable_deno_formatting(client)
if client.name == "denols" then if client.name == "denols" then
require("null-ls").disable({ "prettier" }) require("null-ls").disable({ "prettier" })
end end
end end
function M.resolve_tsserver_deno(client) function M.resolve_tsserver_deno(client)
local active_clients = vim.lsp.get_active_clients() local active_clients = vim.lsp.get_active_clients()
if client.name == "denols" then if client.name == "denols" then
for _, client_ in pairs(active_clients) do for _, client_ in pairs(active_clients) do
-- stop tsserver if denols is already active -- stop tsserver if denols is already active
if client_.name == "tsserver" then if client_.name == "tsserver" then
client_.stop() client_.stop()
end end
end end
elseif client.name == "tsserver" then elseif client.name == "tsserver" then
for _, client_ in pairs(active_clients) do for _, client_ in pairs(active_clients) do
-- prevent tsserver from starting if denols is already active -- prevent tsserver from starting if denols is already active
if client_.name == "denols" then if client_.name == "denols" then
client.stop() client.stop()
end end
end end
end end
end end
function M.disable_others_when_zk(client) function M.disable_others_when_zk(client)
local active_clients = vim.lsp.get_active_clients() local active_clients = vim.lsp.get_active_clients()
if client.name == "zk" then if client.name == "zk" then
for _, client_ in pairs(active_clients) do for _, client_ in pairs(active_clients) do
-- stop ltex if zk is already active -- stop ltex if zk is already active
if client_.name == "ltex" then if client_.name == "ltex" then
client_.stop() client_.stop()
end end
end end
elseif client.name == "ltex" then elseif client.name == "ltex" then
for _, client_ in pairs(active_clients) do for _, client_ in pairs(active_clients) do
-- prevent ltex from starting if zk is already active -- prevent ltex from starting if zk is already active
if client_.name == "zk" then if client_.name == "zk" then
client.stop() client.stop()
end end
end end
end end
end end
function M.on_attach(client, bufnr) function M.on_attach(client, bufnr)
M.disable_deno_formatting(client) -- M.disable_deno_formatting(client)
M.resolve_tsserver_deno(client) -- M.resolve_tsserver_deno(client)
M.disable_others_when_zk(client) M.disable_others_when_zk(client)
end end
return M return M

View File

@ -1,21 +1,21 @@
return { return {
{ -- {
"L3MON4D3/LuaSnip", -- "L3MON4D3/LuaSnip",
dependencies = { -- dependencies = {
"rafamadriz/friendly-snippets", -- "rafamadriz/friendly-snippets",
config = function() -- config = function()
require("luasnip.loaders.from_vscode").lazy_load() -- require("luasnip.loaders.from_vscode").lazy_load()
end, -- end,
}, -- },
opts = { -- opts = {
history = true, -- history = true,
delete_check_events = "TextChanged", -- delete_check_events = "TextChanged",
}, -- },
-- stylua: ignore -- -- stylua: ignore
keys = { -- keys = {
{ "<tab>", function() return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>" end, expr = true, silent = true, mode = "i", }, -- { "<tab>", function() return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>" end, expr = true, silent = true, mode = "i", },
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s", }, -- { "<tab>", function() require("luasnip").jump(1) end, mode = "s", },
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" }, }, -- { "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" }, },
}, -- },
}, -- },
} }

View File

@ -1,42 +1,41 @@
return { return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", build = ":TSUpdate",
dependencies = { dependencies = {
"treesitter-context", "treesitter-context",
}, },
opts = { opts = {
matchup = { enable = true }, matchup = { enable = true },
highlight = { highlight = {
enable = true, enable = true,
additional_vim_regex_highlighting = false, additional_vim_regex_highlighting = false,
}, },
autopairs = { enable = true }, autopairs = { enable = true },
indent = { enable = true }, indent = { enable = true },
context_commentstring = { enable = true, enable_autocmd = false }, ensure_installed = {
ensure_installed = { "c_sharp",
"c_sharp", "lua",
"lua", "c",
"c", "vim",
"vim", "javascript",
"javascript", "regex",
"regex", "markdown_inline",
"markdown_inline", "typescript",
"typescript", "html",
"html", "jsonc",
"jsonc", "go",
"go", },
}, auto_install = true,
auto_install = true, },
}, config = function(_, opts)
config = function(_, opts) require("nvim-treesitter.configs").setup(opts)
require("nvim-treesitter.configs").setup(opts) end,
end, },
}, {
{ "nvim-treesitter/nvim-treesitter-context",
"nvim-treesitter/nvim-treesitter-context", name = "treesitter-context",
name = "treesitter-context", lazy = true,
lazy = true, opts = {},
opts = {}, },
},
} }