Compare commits
2 commits
aee71d51e3
...
c5f293d5e2
Author | SHA1 | Date | |
---|---|---|---|
c5f293d5e2 | |||
ebc75de2c3 |
6 changed files with 129 additions and 141 deletions
4
config/nvim/after/lsp/clangd.lua
Normal file
4
config/nvim/after/lsp/clangd.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
---@type vim.lsp.Config
|
||||
return {
|
||||
cmd = { "clangd", "--header-insertion=never" },
|
||||
}
|
24
config/nvim/after/lsp/lua_ls.lua
Normal file
24
config/nvim/after/lsp/lua_ls.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
---@type vim.lsp.Config
|
||||
return {
|
||||
settings = {
|
||||
Lua = {
|
||||
-- I'm using lua only inside neovim, so the runtime is LuaJIT.
|
||||
runtime = { version = "LuaJIT" },
|
||||
|
||||
-- Get the language server to recognize the `vim` global.
|
||||
diagnostics = { globals = { "vim" } },
|
||||
|
||||
-- Make the server aware of Neovim runtime files.
|
||||
workspace = {
|
||||
library = { vim.env.VIMRUNTIME },
|
||||
|
||||
-- Alternatively, pull in all of 'runtimepath'.
|
||||
-- But see: https://github.com/neovim/nvim-lspconfig/issues/3189
|
||||
-- library = { vim.api.nvim_get_runtime_file("", true) }
|
||||
},
|
||||
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
}
|
18
config/nvim/after/lsp/omnisharp.lua
Normal file
18
config/nvim/after/lsp/omnisharp.lua
Normal file
|
@ -0,0 +1,18 @@
|
|||
---@type vim.lsp.Config
|
||||
return {
|
||||
-- Use .editoconfig for code style, naming convention and analyzer settings.
|
||||
enable_editorconfig_support = true,
|
||||
|
||||
-- Show unimported types and add`using` directives.
|
||||
enable_import_completion = true,
|
||||
|
||||
-- Enable roslyn analyzers, code fixes, and rulesets.
|
||||
enable_roslyn_analyzers = true,
|
||||
|
||||
-- Don't include preview versions of the .NET SDK.
|
||||
sdk_include_prereleases = false,
|
||||
|
||||
handlers = {
|
||||
["textDocument/definition"] = require("omnisharp_extended").handler,
|
||||
},
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
local border = { border = "rounded" }
|
||||
|
||||
local lsp_capabilities = function()
|
||||
local basic = vim.lsp.protocol.make_client_capabilities()
|
||||
local completion = vim.F.npcall(require, "cmp_nvim_lsp")
|
||||
if completion then
|
||||
return vim.tbl_deep_extend("force", basic, completion.default_capabilities())
|
||||
end
|
||||
return basic
|
||||
end
|
||||
|
||||
local lsp_handlers = function()
|
||||
return {
|
||||
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, border),
|
||||
["textDocument/signatureHelp"] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help,
|
||||
border
|
||||
),
|
||||
}
|
||||
end
|
||||
|
||||
local lsp_on_attach = function(--[[client]]_, buffer)
|
||||
local map, opts = vim.keymap.set, { buffer = buffer }
|
||||
-- stylua: ignore start
|
||||
map("n", "<localleader>c", vim.lsp.buf.code_action, opts)
|
||||
map("n", "<localleader>f", vim.lsp.buf.format, opts)
|
||||
map("n", "gd", vim.lsp.buf.definition, opts)
|
||||
map("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
map("n", "gi", vim.lsp.buf.implementation, opts)
|
||||
map("n", "grr", vim.lsp.buf.rename, opts)
|
||||
map("n", "gt", vim.lsp.buf.type_definition, opts)
|
||||
map("n", "K", vim.lsp.buf.hover, opts)
|
||||
map("i", "<c-,>", vim.lsp.buf.signature_help, opts)
|
||||
-- stylua: ignore end
|
||||
end
|
||||
|
||||
local lsp_on_init = function(client)
|
||||
-- Opt out of semantic highlighting because it has been causing the issues
|
||||
-- https://github.com/neovim/nvim-lspconfig/issues/2542#issuecomment-1547019213
|
||||
if client.server_capabilities then
|
||||
client.server_capabilities.semanticTokensProvider = false
|
||||
end
|
||||
end
|
||||
|
||||
local server_opts = setmetatable({
|
||||
clangd = function(opts)
|
||||
return vim.tbl_deep_extend("force", opts, {
|
||||
cmd = { "clangd", "--header-insertion=never" },
|
||||
})
|
||||
end,
|
||||
lua_ls = function(opts)
|
||||
return vim.tbl_deep_extend("force", opts, {
|
||||
settings = {
|
||||
Lua = {
|
||||
-- I'm using lua only inside neovim, so the runtime is LuaJIT.
|
||||
runtime = { version = "LuaJIT" },
|
||||
|
||||
-- Get the language server to recognize the `vim` global.
|
||||
diagnostics = { globals = { "vim" } },
|
||||
|
||||
-- Make the server aware of Neovim runtime files.
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
omnisharp = function(opts)
|
||||
return vim.tbl_deep_extend("force", opts, {
|
||||
-- Use .editoconfig for code style, naming convention and analyzer settings.
|
||||
enable_editorconfig_support = true,
|
||||
|
||||
-- Show unimported types and add`using` directives.
|
||||
enable_import_completion = true,
|
||||
|
||||
-- Enable roslyn analyzers, code fixes, and rulesets.
|
||||
enable_roslyn_analyzers = true,
|
||||
|
||||
-- Don't include preview versions of the .NET SDK.
|
||||
sdk_include_prereleases = false,
|
||||
|
||||
handlers = {
|
||||
["textDocument/definition"] = require("omnisharp_extended").handler,
|
||||
},
|
||||
})
|
||||
end,
|
||||
}, {
|
||||
-- The default is a just a passthrough of the options.
|
||||
__index = function()
|
||||
return function(opts) return opts end
|
||||
end,
|
||||
})
|
||||
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"Hoffs/omnisharp-extended-lsp.nvim",
|
||||
},
|
||||
|
||||
cmd = "Mason",
|
||||
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
|
||||
config = function()
|
||||
local icons = require("fschauen.util.icons")
|
||||
|
||||
require("lspconfig.ui.windows").default_options = border
|
||||
|
||||
require("mason").setup {
|
||||
ui = {
|
||||
border = border.border,
|
||||
icons = {
|
||||
package_installed = icons.git.file.Staged,
|
||||
package_pending = icons.git.file.Unstaged,
|
||||
package_uninstalled = icons.git.file.Deleted,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
require("mason-lspconfig").setup {
|
||||
ensure_installed = {},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require("lspconfig")[server_name].setup(server_opts[server_name] {
|
||||
capabilities = lsp_capabilities(),
|
||||
handlers = lsp_handlers(),
|
||||
on_attach = lsp_on_attach,
|
||||
lsp_on_init = lsp_on_init,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
61
config/nvim/lua/fschauen/plugins/lspconfig.lua
Normal file
61
config/nvim/lua/fschauen/plugins/lspconfig.lua
Normal file
|
@ -0,0 +1,61 @@
|
|||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
|
||||
dependencies = {
|
||||
"Hoffs/omnisharp-extended-lsp.nvim",
|
||||
},
|
||||
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
|
||||
config = function()
|
||||
local capabilities = (function()
|
||||
local cmp_nvim_lsp = vim.F.npcall(require, "cmp_nvim_lsp")
|
||||
if cmp_nvim_lsp then
|
||||
return cmp_nvim_lsp.default_capabilities()
|
||||
else
|
||||
return vim.lsp.protocol.make_client_capabilities()
|
||||
end
|
||||
end)()
|
||||
|
||||
vim.lsp.config("*", { capabilities = capabilities })
|
||||
|
||||
vim.lsp.enable("clangd")
|
||||
vim.lsp.enable("cmake")
|
||||
vim.lsp.enable("lua_ls")
|
||||
vim.lsp.enable("omnisharp")
|
||||
vim.lsp.enable("pyright")
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local toggle_inlay_hints = function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
|
||||
end
|
||||
|
||||
local rounded = function(action)
|
||||
return function() action { border = "rounded" } end
|
||||
end
|
||||
|
||||
-- stylua: ignore start
|
||||
vim.keymap.set("n", "<leader>sh", toggle_inlay_hints, { buffer = 0 })
|
||||
vim.keymap.set("n", "<localleader>c", vim.lsp.buf.code_action, { buffer = 0 } )
|
||||
vim.keymap.set("n", "<localleader>f", vim.lsp.buf.format, { buffer = 0 } )
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { buffer = 0 } )
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = 0 } )
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { buffer = 0 } )
|
||||
vim.keymap.set("n", "grr", vim.lsp.buf.rename, { buffer = 0 } )
|
||||
vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, { buffer = 0 } )
|
||||
vim.keymap.set("n", "gs", rounded(vim.lsp.buf.signature_help), { buffer = 0 } )
|
||||
vim.keymap.set("i", "<c-s>", rounded(vim.lsp.buf.signature_help), { buffer = 0 } )
|
||||
vim.keymap.set("n", "K", rounded(vim.lsp.buf.hover), { buffer = 0 } )
|
||||
-- stylua: ignore end
|
||||
|
||||
-- Opt out of semantic highlighting because it has been causing issues
|
||||
-- https://github.com/neovim/nvim-lspconfig/issues/2542#issuecomment-1547019213
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if client and client.server_capabilities then
|
||||
client.server_capabilities.semanticTokensProvider = nil
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
22
config/nvim/lua/fschauen/plugins/mason.lua
Normal file
22
config/nvim/lua/fschauen/plugins/mason.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
return {
|
||||
"williamboman/mason.nvim",
|
||||
|
||||
cmd = "Mason",
|
||||
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
|
||||
config = function()
|
||||
local icons = require("fschauen.util.icons")
|
||||
|
||||
require("mason").setup {
|
||||
ui = {
|
||||
border = "rounded",
|
||||
icons = {
|
||||
package_installed = icons.git.file.Staged,
|
||||
package_pending = icons.git.file.Unstaged,
|
||||
package_uninstalled = icons.git.file.Deleted,
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
Loading…
Add table
Reference in a new issue