feat: add inlay hints

This commit is contained in:
Fabio Lenherr / DashieTM 2023-01-05 16:55:02 +01:00
parent f3a0d0d35f
commit b0664537c3
16 changed files with 661 additions and 641 deletions

View file

@ -12,3 +12,4 @@ vim.cmd([[highlight BufferInactive guifg=#888888 guibg=#131a24]])
vim.cmd([[highlight BufferInactiveMod guifg=#dbc074 guibg=#131a24]]) vim.cmd([[highlight BufferInactiveMod guifg=#dbc074 guibg=#131a24]])
vim.cmd([[highlight BufferInactiveSign guifg=#719cd6 guibg=#131a24]]) vim.cmd([[highlight BufferInactiveSign guifg=#719cd6 guibg=#131a24]])
vim.cmd([[highlight LspInlayHint guibg=#192330]])

View file

@ -40,4 +40,3 @@ end)
nvim_tree_events.subscribe("TreeClose", function() nvim_tree_events.subscribe("TreeClose", function()
bufferline_api.set_offset(0) bufferline_api.set_offset(0)
end) end)

View file

@ -5,12 +5,12 @@ end
local dashboard = require("alpha.themes.dashboard") local dashboard = require("alpha.themes.dashboard")
dashboard.section.header.val = { dashboard.section.header.val = {
[[ _______ ___ _______. __ __ __ _______ ]], [[ _______ ___ _______. __ __ __ _______ ]],
[[| \ / \ / || | | | | | | ____|]], [[| \ / \ / || | | | | | | ____|]],
[[| .--. | / ^ \ | (----`| |__| | | | | |__ ]], [[| .--. | / ^ \ | (----`| |__| | | | | |__ ]],
[[| | | | / /_\ \ \ \ | __ | | | | __| ]], [[| | | | / /_\ \ \ \ | __ | | | | __| ]],
[[| '--' | / _____ \ .----) | | | | | | | | |____ ]], [[| '--' | / _____ \ .----) | | | | | | | | |____ ]],
[[|_______/ /__/ \__\ |_______/ |__| |__| |__| |_______|]] [[|_______/ /__/ \__\ |_______/ |__| |__| |__| |_______|]]
} }
dashboard.section.buttons.val = { dashboard.section.buttons.val = {
dashboard.button("f", " Find file", ":Telescope find_files <CR>"), dashboard.button("f", " Find file", ":Telescope find_files <CR>"),

View file

@ -1,9 +1,9 @@
local status_ok , _ = pcall (require, "nvim-web-devicons") local status_ok, _ = pcall(require, "nvim-web-devicons")
if not status_ok then if not status_ok then
return return
end end
require'nvim-web-devicons'.setup { require 'nvim-web-devicons'.setup {
-- your personnal icons can go here (to override) -- your personnal icons can go here (to override)
-- you can specify color or cterm_color instead of specifying both of them -- you can specify color or cterm_color instead of specifying both of them
-- DevIcon will be appended to `name` -- DevIcon will be appended to `name`
@ -19,4 +19,4 @@ require'nvim-web-devicons'.setup {
default = true; default = true;
} }
require'nvim-web-devicons'.get_icons() require 'nvim-web-devicons'.get_icons()

View file

@ -12,7 +12,7 @@ keymap("n", "<F10>", ':lua require("dap").close()<CR> :lua require("dapui").togg
-- file tree -- file tree
keymap("n", "t", ":ToggleTerm<CR>", opts) keymap("n", "t", ":ToggleTerm<CR>", opts)
keymap("n", "n", ':lua require("nvim-tree").toggle()<CR>', opts) keymap("n", "f", ':lua require("nvim-tree").toggle()<CR>', opts)
-- tab switching -- tab switching
keymap("n", "<F1>", ":BufferPrev<CR>", opts) keymap("n", "<F1>", ":BufferPrev<CR>", opts)
@ -44,4 +44,3 @@ require("trouble").setup({
open_tab = {}, open_tab = {},
}, },
}) })

View file

@ -25,6 +25,7 @@ require("mason-lspconfig").setup({
"ansiblels", -- ansible "ansiblels", -- ansible
"marksman", -- markdown "marksman", -- markdown
"asm_lsp", -- assembly "asm_lsp", -- assembly
"tsserver", -- js and ts
}, },
automatic_installation = true, automatic_installation = true,
}) })
@ -33,9 +34,13 @@ local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protoc
capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.snippetSupport = true
-- LSP -- LSP
-- require("lsp-format").setup {}
require("lsp-inlayhints").setup()
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
local optslsp = { noremap = false, silent = true, buffer = bufnr } local optslsp = { noremap = false, silent = true, buffer = bufnr }
-- require("lsp-format").on_attach(client)
require("lsp-inlayhints").on_attach(client, bufnr)
end end
require("mason-lspconfig").setup_handlers({ require("mason-lspconfig").setup_handlers({
@ -50,13 +55,41 @@ require("mason-lspconfig").setup_handlers({
}) })
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 -- special server setups
require("clangd_extensions").setup() require("clangd_extensions").setup()
@ -67,13 +100,3 @@ require("rust-tools").setup({
loadOutputiDirs = false, 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,
},
})

View file

@ -216,12 +216,12 @@ nvim_tree.setup { -- BEGIN_DEFAULT_OPTS
watcher = false, watcher = false,
}, },
}, },
} }
-- nvim-tree is also there in modified buffers so this function filter it out -- nvim-tree is also there in modified buffers so this function filter it out
local modifiedBufs = function(bufs) local modifiedBufs = function(bufs)
local t = 0 local t = 0
for k,v in pairs(bufs) do for k, v in pairs(bufs) do
if v.name:match("NvimTree_") == nil then if v.name:match("NvimTree_") == nil then
t = t + 1 t = t + 1
end end
@ -234,7 +234,7 @@ vim.api.nvim_create_autocmd("BufEnter", {
callback = function() callback = function()
if #vim.api.nvim_list_wins() == 1 and if #vim.api.nvim_list_wins() == 1 and
vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil and vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil and
modifiedBufs(vim.fn.getbufinfo({bufmodified = 1})) == 0 then modifiedBufs(vim.fn.getbufinfo({ bufmodified = 1 })) == 0 then
vim.cmd "quit" vim.cmd "quit"
end end
end end

View file

@ -15,7 +15,7 @@ npairs.setup({
disable_filetype = { "TelescopePrompt", "spectre_panel" }, disable_filetype = { "TelescopePrompt", "spectre_panel" },
fast_wrap = { fast_wrap = {
map = "<M-e>", map = "<M-e>",
chars = { "{", "[", "(", "<", '"', "'"}, chars = { "{", "[", "(", "<", '"', "'" },
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
offset = 0, -- Offset from pattern match offset = 0, -- Offset from pattern match
end_key = "$", end_key = "$",
@ -26,7 +26,7 @@ npairs.setup({
}, },
}) })
npairs.add_rule(Rule("<",">")) npairs.add_rule(Rule("<", ">"))
local cmp_autopairs = require("nvim-autopairs.completion.cmp") local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp_status_ok, cmp = pcall(require, "cmp") local cmp_status_ok, cmp = pcall(require, "cmp")

View file

@ -53,9 +53,8 @@ Plug('akinsho/toggleterm.nvim',{ ["tag"] = "*" }) -- better
Plug("iamcco/markdown-preview.nvim", -- markdown preview Plug("iamcco/markdown-preview.nvim", -- markdown preview
{ ["do"] = "cd app && yarn install" }) { ["do"] = "cd app && yarn install" })
Plug('p00f/clangd_extensions.nvim') -- clangd_extensions Plug('p00f/clangd_extensions.nvim') -- clangd_extensions
Plug('jose-elias-alvarez/typescript.nvim') -- typescript extensions
Plug('kdarkhan/rust-tools.nvim') -- rust extensions Plug('kdarkhan/rust-tools.nvim') -- rust extensions
Plug('lvimuser/lsp-inlayhints.nvim') -- inlay hints
Plug('preservim/tagbar') -- tags on the right Plug('preservim/tagbar') -- tags on the right
Plug('lukas-reineke/lsp-format.nvim')
vim.call("plug#end") vim.call("plug#end")

View file

@ -10,10 +10,10 @@ require('telescope').setup {
project = { project = {
base_dirs = { base_dirs = {
'~/dev/src', '~/dev/src',
{'~/dev/src2'}, { '~/dev/src2' },
{'~/dev/src3', max_depth = 4}, { '~/dev/src3', max_depth = 4 },
{path = '~/dev/src4'}, { path = '~/dev/src4' },
{path = '~/dev/src5', max_depth = 2}, { path = '~/dev/src5', max_depth = 2 },
}, },
hidden_files = true, -- default: false hidden_files = true, -- default: false
theme = "dropdown", theme = "dropdown",

View file

@ -1,4 +1,3 @@
local t = require("telescope") local t = require("telescope")
local z_utils = require("telescope._extensions.zoxide.utils") local z_utils = require("telescope._extensions.zoxide.utils")