feat: add inlay hints
This commit is contained in:
parent
f3a0d0d35f
commit
b0664537c3
16 changed files with 661 additions and 641 deletions
|
|
@ -1,62 +1,95 @@
|
|||
local status_ok, _ = pcall(require, "lspconfig")
|
||||
if not status_ok then
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
require("mason").setup({
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
ui = {
|
||||
icons = {
|
||||
package_installed = "✓",
|
||||
package_pending = "➜",
|
||||
package_uninstalled = "✗",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"cssls", -- css
|
||||
"html", -- html
|
||||
"clangd", -- cpp / c
|
||||
"sumneko_lua", -- lua
|
||||
"pyright", -- python
|
||||
"cmake", -- cmake
|
||||
"bashls", -- shell
|
||||
"ansiblels", -- ansible
|
||||
ensure_installed = {
|
||||
"cssls", -- css
|
||||
"html", -- html
|
||||
"clangd", -- cpp / c
|
||||
"sumneko_lua", -- lua
|
||||
"pyright", -- python
|
||||
"cmake", -- cmake
|
||||
"bashls", -- shell
|
||||
"ansiblels", -- ansible
|
||||
"marksman", -- markdown
|
||||
"asm_lsp", -- assembly
|
||||
},
|
||||
automatic_installation = true,
|
||||
"tsserver", -- js and ts
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
-- LSP
|
||||
-- require("lsp-format").setup {}
|
||||
require("lsp-inlayhints").setup()
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
local optslsp = { noremap = false, silent = true, buffer = bufnr }
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
local optslsp = { noremap = false, silent = true, buffer = bufnr }
|
||||
-- require("lsp-format").on_attach(client)
|
||||
require("lsp-inlayhints").on_attach(client, bufnr)
|
||||
end
|
||||
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
function(server_name) -- default handler (optional)
|
||||
require("lspconfig")[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
function(server_name) -- default handler (optional)
|
||||
require("lspconfig")[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
-- Disable virtual_text
|
||||
virtual_text = true,
|
||||
}
|
||||
-- Disable virtual_text
|
||||
virtual_text = true,
|
||||
}
|
||||
|
||||
})
|
||||
end,
|
||||
})
|
||||
end,
|
||||
['tsserver'] = function()
|
||||
require('lspconfig').tsserver.setup {
|
||||
settings = {
|
||||
typescript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = 'all',
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
}
|
||||
},
|
||||
javascript = {
|
||||
inlayHints = {
|
||||
includeInlayParameterNameHints = 'all',
|
||||
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
|
||||
includeInlayFunctionParameterTypeHints = true,
|
||||
includeInlayVariableTypeHints = true,
|
||||
includeInlayPropertyDeclarationTypeHints = true,
|
||||
includeInlayFunctionLikeReturnTypeHints = true,
|
||||
includeInlayEnumMemberValueHints = true,
|
||||
}
|
||||
}
|
||||
},
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = true,
|
||||
}
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
require("lsp-format").setup {}
|
||||
|
||||
local on_attach = function(client)
|
||||
require("lsp-format").on_attach(client)
|
||||
end
|
||||
|
||||
-- special server setups
|
||||
require("clangd_extensions").setup()
|
||||
|
|
@ -67,13 +100,3 @@ require("rust-tools").setup({
|
|||
loadOutputiDirs = false,
|
||||
}
|
||||
})
|
||||
require("typescript").setup({
|
||||
disable_commands = false, -- prevent the plugin from creating Vim commands
|
||||
debug = false, -- enable debug logging for commands
|
||||
go_to_source_definition = {
|
||||
fallback = true, -- fall back to standard LSP definition on failure
|
||||
},
|
||||
server = { -- pass options to lspconfig's setup method
|
||||
on_attach = on_attach,
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue