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

@ -1,151 +1,151 @@
local cmp_status_ok, cmp = pcall(require, "cmp") local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then if not cmp_status_ok then
return return
end end
local snip_status_ok, luasnip = pcall(require, "luasnip") local snip_status_ok, luasnip = pcall(require, "luasnip")
if not snip_status_ok then if not snip_status_ok then
return return
end end
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" }) require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
luasnip.config.set_config({ luasnip.config.set_config({
history = true, history = true,
delete_check_events = "TextChanged", delete_check_events = "TextChanged",
updateevents = "TextChanged,TextChangedI", updateevents = "TextChanged,TextChangedI",
enable_autosnippets = true, enable_autosnippets = true,
ext_opts = { ext_opts = {
[require("luasnip.util.types").choiceNode] = { [require("luasnip.util.types").choiceNode] = {
active = { active = {
virt_text = { { virt_text = { {
Snippet = "", Snippet = "",
"Snippet", "Snippet",
} }, } },
}, },
}, },
}, },
}) })
require("luasnip/loaders/from_vscode").lazy_load() require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function() local check_backspace = function()
local col = vim.fn.col(".") - 1 local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end end
--   פּ ﯟ   some other good icons --   פּ ﯟ   some other good icons
local kind_icons = { local kind_icons = {
Text = "", Text = "",
Method = "m", Method = "m",
Function = "", Function = "",
Constructor = "", Constructor = "",
Field = "", Field = "",
Variable = "", Variable = "",
Class = "", Class = "",
Interface = "", Interface = "",
Module = "", Module = "",
Property = "", Property = "",
Unit = "", Unit = "",
Value = "", Value = "",
Enum = "", Enum = "",
Keyword = "", Keyword = "",
Snippet = "", Snippet = "",
Color = "", Color = "",
File = "", File = "",
Reference = "", Reference = "",
Folder = "", Folder = "",
EnumMember = "", EnumMember = "",
Constant = "", Constant = "",
Struct = "", Struct = "",
Event = "", Event = "",
Operator = "", Operator = "",
TypeParameter = "", TypeParameter = "",
} }
-- find more here: https://www.nerdfonts.com/cheat-sheet -- find more here: https://www.nerdfonts.com/cheat-sheet
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users. luasnip.lsp_expand(args.body) -- For `luasnip` users.
end, end,
}, },
mapping = { mapping = {
["<C-b>"] = cmp.mapping.scroll_docs(-1), ["<C-b>"] = cmp.mapping.scroll_docs(-1),
["<C-f>"] = cmp.mapping.scroll_docs(1), ["<C-f>"] = cmp.mapping.scroll_docs(1),
["<C-e>"] = cmp.mapping({ ["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(), i = cmp.mapping.abort(),
c = cmp.mapping.close(), c = cmp.mapping.close(),
}), }),
["<CR>"] = cmp.mapping.confirm({ select = false }), ["<CR>"] = cmp.mapping.confirm({ select = false }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
else else
fallback() fallback()
end end
end, { end, {
"i", "i",
"s", "s",
}), }),
["<C-j>"] = cmp.mapping(function(fallback) ["<C-j>"] = cmp.mapping(function(fallback)
if luasnip.expandable() then if luasnip.expandable() then
luasnip.expand() luasnip.expand()
elseif luasnip.expand_or_jumpable() then elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
else else
fallback() fallback()
end end
end, { end, {
"i", "i",
"s", "s",
}), }),
["<C-k>"] = cmp.mapping(function(fallback) ["<C-k>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable(-1) then if luasnip.expand_or_jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, { end, {
"i", "i",
"s", "s",
}), }),
}, },
view = { view = {
{ entries = "native" }, { entries = "native" },
}, },
formatting = { formatting = {
fields = { "kind", "abbr", "menu" }, fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item) format = function(entry, vim_item)
vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
vim_item.menu = ({ vim_item.menu = ({
nvim_lsp = "[LSP]", nvim_lsp = "[LSP]",
luasnip = "[Snippet]", luasnip = "[Snippet]",
buffer = "[Buffer]", buffer = "[Buffer]",
path = "[Path]", path = "[Path]",
})[entry.source.name] })[entry.source.name]
return vim_item return vim_item
end, end,
}, },
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "path" }, { name = "path" },
{ name = "buffer" }, { name = "buffer" },
}, },
window = { window = {
documentation = { documentation = {
border = { "", "", "", "", "", "", "", "" }, border = { "", "", "", "", "", "", "", "" },
}, },
}, },
experimental = { experimental = {
ghost_text = true, ghost_text = true,
}, },
}) })

View file

@ -1,12 +1,12 @@
local dap = require("dap") local dap = require("dap")
dap.adapters.codelldb = { dap.adapters.codelldb = {
type = "server", type = "server",
port = "${port}", port = "${port}",
executable = { executable = {
-- CHANGE THIS to your path! -- CHANGE THIS to your path!
command = "/home/dashie/.local/share/nvim/mason/packages/codelldb/extension/adapter/codelldb", command = "/home/dashie/.local/share/nvim/mason/packages/codelldb/extension/adapter/codelldb",
args = { "--port", "${port}" }, args = { "--port", "${port}" },
}, },
} }
local rust_dap = vim.fn.getcwd() local rust_dap = vim.fn.getcwd()
@ -14,111 +14,111 @@ local filename = ""
for w in rust_dap:gmatch("([^/]+)") do filename = w end for w in rust_dap:gmatch("([^/]+)") do filename = w end
dap.configurations.rust = { dap.configurations.rust = {
{ {
type = "codelldb", type = "codelldb",
request = "launch", request = "launch",
program = function() program = function()
return rust_dap .. "/target/debug/" .. filename return rust_dap .. "/target/debug/" .. filename
end, end,
--program = '${fileDirname}/${fileBasenameNoExtension}', --program = '${fileDirname}/${fileBasenameNoExtension}',
cwd = "${workspaceFolder}", cwd = "${workspaceFolder}",
stopOnEntry = true, stopOnEntry = true,
terminal = "integrated", terminal = "integrated",
}, },
} }
dap.configurations.cpp = { dap.configurations.cpp = {
{ {
type = "codelldb", type = "codelldb",
request = "launch", request = "launch",
program = function() program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/build/", "file") return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/build/", "file")
end, end,
--program = '${fileDirname}/${fileBasenameNoExtension}', --program = '${fileDirname}/${fileBasenameNoExtension}',
cwd = "${workspaceFolder}", cwd = "${workspaceFolder}",
terminal = "integrated", terminal = "integrated",
}, },
} }
dap.configurations.c = dap.configurations.cpp dap.configurations.c = dap.configurations.cpp
require("dapui").setup({ require("dapui").setup({
icons = { expanded = "", collapsed = "", current_frame = "" }, icons = { expanded = "", collapsed = "", current_frame = "" },
mappings = { mappings = {
-- Use a table to apply multiple mappings -- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>" }, expand = { "<CR>", "<2-LeftMouse>" },
open = "o", open = "o",
remove = "d", remove = "d",
edit = "e", edit = "e",
repl = "r", repl = "r",
toggle = "t", toggle = "t",
}, },
-- Expand lines larger than the window -- Expand lines larger than the window
-- Requires >= 0.7 -- Requires >= 0.7
expand_lines = vim.fn.has("nvim-0.7") == 1, expand_lines = vim.fn.has("nvim-0.7") == 1,
-- Layouts define sections of the screen to place windows. -- Layouts define sections of the screen to place windows.
-- The position can be "left", "right", "top" or "bottom". -- The position can be "left", "right", "top" or "bottom".
-- The size specifies the height/width depending on position. It can be an Int -- The size specifies the height/width depending on position. It can be an Int
-- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while
-- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns) -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
-- Elements are the elements shown in the layout (in order). -- Elements are the elements shown in the layout (in order).
-- Layouts are opened in order so that earlier layouts take priority in window sizing. -- Layouts are opened in order so that earlier layouts take priority in window sizing.
layouts = { layouts = {
{ {
elements = { elements = {
-- Elements can be strings or table with id and size keys. -- Elements can be strings or table with id and size keys.
{ id = "scopes", size = 0.25 }, { id = "scopes", size = 0.25 },
"breakpoints", "breakpoints",
"stacks", "stacks",
"watches", "watches",
}, },
size = 40, -- 40 columns size = 40, -- 40 columns
position = "left", position = "left",
}, },
{ {
elements = { elements = {
"repl", "repl",
"console", "console",
}, },
size = 0.25, -- 25% of total lines size = 0.25, -- 25% of total lines
position = "bottom", position = "bottom",
}, },
}, },
controls = { controls = {
-- Requires Neovim nightly (or 0.8 when released) -- Requires Neovim nightly (or 0.8 when released)
enabled = true, enabled = true,
-- Display controls in this element -- Display controls in this element
element = "repl", element = "repl",
icons = { icons = {
pause = "", pause = "",
play = "", play = "",
step_into = "", step_into = "",
step_over = "", step_over = "",
step_out = "", step_out = "",
step_back = "", step_back = "",
run_last = "", run_last = "",
terminate = "", terminate = "",
}, },
}, },
floating = { floating = {
max_height = nil, -- These can be integers or a float between 0 and 1. max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen. max_width = nil, -- Floats will be treated as percentage of your screen.
border = "single", -- Border style. Can be "single", "double" or "rounded" border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = { mappings = {
close = { "q", "<Esc>" }, close = { "q", "<Esc>" },
}, },
}, },
windows = { indent = 1 }, windows = { indent = 1 },
render = { render = {
max_type_length = nil, -- Can be integer or nil. max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil. max_value_lines = 100, -- Can be integer or nil.
}, },
}) })
require("mason-nvim-dap").setup({ require("mason-nvim-dap").setup({
ensure_installed = { ensure_installed = {
"codelldb", "codelldb",
"bash-debug-adapter", "bash-debug-adapter",
"firefox-debug-adapter", "firefox-debug-adapter",
"js-debug-adapter", "js-debug-adapter",
"node-debug2-adapter", "node-debug2-adapter",
}, },
}) })

View file

@ -1,30 +1,30 @@
local status_ok, alpha = pcall(require, "alpha") local status_ok, alpha = pcall(require, "alpha")
if not status_ok then if not status_ok then
return return
end 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>"),
dashboard.button("b", " Open File Browser", ":Telescope file_browser<CR>"), dashboard.button("b", " Open File Browser", ":Telescope file_browser<CR>"),
dashboard.button("e", " New file", ":ene <BAR> startinsert <CR>"), dashboard.button("e", " New file", ":ene <BAR> startinsert <CR>"),
dashboard.button("p", " Find project", ":Telescope project <CR>"), dashboard.button("p", " Find project", ":Telescope project <CR>"),
dashboard.button("r", " Recently used files", ":Telescope oldfiles <CR>"), dashboard.button("r", " Recently used files", ":Telescope oldfiles <CR>"),
dashboard.button("t", " Zoxide", ":Telescope zoxide list <CR>"), dashboard.button("t", " Zoxide", ":Telescope zoxide list <CR>"),
dashboard.button("c", " Configuration", ":e ~/.config/nvim/init.lua <CR>"), dashboard.button("c", " Configuration", ":e ~/.config/nvim/init.lua <CR>"),
dashboard.button("q", " Quit Neovim", ":qa<CR>"), dashboard.button("q", " Quit Neovim", ":qa<CR>"),
} }
local function footer() local function footer()
return "dashie@dashie.org" return "dashie@dashie.org"
end end
dashboard.section.footer.val = footer() dashboard.section.footer.val = footer()

View file

@ -1,22 +1,22 @@
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`
override = { override = {
zsh = { zsh = {
icon = "", icon = "",
color = "#428850", color = "#428850",
cterm_color = "65", cterm_color = "65",
name = "Zsh" name = "Zsh"
} }
}; };
default = true; default = true;
} }
require'nvim-web-devicons'.get_icons() require 'nvim-web-devicons'.get_icons()

View file

@ -1,17 +1,17 @@
local status_ok, indent_blankline = pcall(require, "indent_blankline") local status_ok, indent_blankline = pcall(require, "indent_blankline")
if not status_ok then if not status_ok then
return return
end end
vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" } vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" }
vim.g.indent_blankline_filetype_exclude = { vim.g.indent_blankline_filetype_exclude = {
"help", "help",
"startify", "startify",
"dashboard", "dashboard",
"packer", "packer",
"neogitstatus", "neogitstatus",
"NvimTree", "NvimTree",
"Trouble", "Trouble",
} }
vim.g.indentLine_enabled = 1 vim.g.indentLine_enabled = 1
-- vim.g.indent_blankline_char = "│" -- vim.g.indent_blankline_char = "│"
@ -22,30 +22,30 @@ vim.g.indent_blankline_show_first_indent_level = true
vim.g.indent_blankline_use_treesitter = true vim.g.indent_blankline_use_treesitter = true
vim.g.indent_blankline_show_current_context = true vim.g.indent_blankline_show_current_context = true
vim.g.indent_blankline_context_patterns = { vim.g.indent_blankline_context_patterns = {
"class", "class",
"return", "return",
"function", "function",
"def", "def",
"method", "method",
"^if", "^if",
"^else", "^else",
"^else if", "^else if",
"^elif", "^elif",
"^while", "^while",
"jsx_element", "jsx_element",
"^for", "^for",
"^object", "^object",
"^table", "^table",
"block", "block",
"arguments", "arguments",
"if_statement", "if_statement",
"else_clause", "else_clause",
"jsx_element", "jsx_element",
"jsx_self_closing_element", "jsx_self_closing_element",
"try_statement", "try_statement",
"catch_clause", "catch_clause",
"import_statement", "import_statement",
"operation_type", "operation_type",
} }
-- HACK: work-around for https://github.com/lukas-reineke/indent-blankline.nvim/issues/59 -- HACK: work-around for https://github.com/lukas-reineke/indent-blankline.nvim/issues/59
vim.wo.colorcolumn = "99999" vim.wo.colorcolumn = "99999"
@ -62,13 +62,13 @@ vim.wo.colorcolumn = "99999"
-- vim.opt.listchars:append "eol:↴" -- vim.opt.listchars:append "eol:↴"
indent_blankline.setup({ indent_blankline.setup({
show_end_of_line = true, show_end_of_line = true,
space_char_blankline = " ", space_char_blankline = " ",
show_current_context = true, show_current_context = true,
show_current_context_start = true, show_current_context_start = true,
-- char_highlight_list = { -- char_highlight_list = {
-- "IndentBlanklineIndent1", -- "IndentBlanklineIndent1",
-- "IndentBlanklineIndent2", -- "IndentBlanklineIndent2",
-- "IndentBlanklineIndent3", -- "IndentBlanklineIndent3",
-- }, -- },
}) })

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)
@ -39,9 +39,8 @@ vim.keymap.set("n", "<leader>z", ":lua require('telescope').extensions.zoxide.li
-- trouble -- trouble
keymap("n", "<C-f>", "<cmd>TroubleToggle<CR>", term_opts) keymap("n", "<C-f>", "<cmd>TroubleToggle<CR>", term_opts)
require("trouble").setup({ require("trouble").setup({
action_keys = { action_keys = {
--remove the fucking stupid keymap amk --remove the fucking stupid keymap amk
open_tab = {}, open_tab = {},
}, },
}) })

View file

@ -1,62 +1,95 @@
local status_ok, _ = pcall(require, "lspconfig") local status_ok, _ = pcall(require, "lspconfig")
if not status_ok then if not status_ok then
return return
end end
require("mason").setup({ require("mason").setup({
ui = { ui = {
icons = { icons = {
package_installed = "", package_installed = "",
package_pending = "", package_pending = "",
package_uninstalled = "", package_uninstalled = "",
}, },
}, },
}) })
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
ensure_installed = { ensure_installed = {
"cssls", -- css "cssls", -- css
"html", -- html "html", -- html
"clangd", -- cpp / c "clangd", -- cpp / c
"sumneko_lua", -- lua "sumneko_lua", -- lua
"pyright", -- python "pyright", -- python
"cmake", -- cmake "cmake", -- cmake
"bashls", -- shell "bashls", -- shell
"ansiblels", -- ansible "ansiblels", -- ansible
"marksman", -- markdown "marksman", -- markdown
"asm_lsp", -- assembly "asm_lsp", -- assembly
}, "tsserver", -- js and ts
automatic_installation = true, },
automatic_installation = true,
}) })
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
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({
function(server_name) -- default handler (optional) function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup({ require("lspconfig")[server_name].setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
vim.lsp.diagnostic.on_publish_diagnostics, { vim.lsp.diagnostic.on_publish_diagnostics, {
-- Disable virtual_text -- Disable virtual_text
virtual_text = true, 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 -- 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

@ -12,230 +12,230 @@ if not config_status_ok then
end end
nvim_tree.setup { -- BEGIN_DEFAULT_OPTS nvim_tree.setup { -- BEGIN_DEFAULT_OPTS
auto_reload_on_write = true, auto_reload_on_write = true,
create_in_closed_folder = false, create_in_closed_folder = false,
disable_netrw = false, disable_netrw = false,
hijack_cursor = false, hijack_cursor = false,
hijack_netrw = true, hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false, hijack_unnamed_buffer_when_opening = false,
ignore_buffer_on_setup = false, ignore_buffer_on_setup = false,
open_on_setup = true, open_on_setup = true,
open_on_setup_file = true, open_on_setup_file = true,
open_on_tab = true, open_on_tab = true,
ignore_buf_on_tab_change = {}, ignore_buf_on_tab_change = {},
sort_by = "name", sort_by = "name",
root_dirs = {}, root_dirs = {},
prefer_startup_root = false, prefer_startup_root = false,
sync_root_with_cwd = false, sync_root_with_cwd = false,
reload_on_bufenter = false, reload_on_bufenter = false,
respect_buf_cwd = false, respect_buf_cwd = false,
on_attach = "disable", -- function(bufnr). If nil, will use the deprecated mapping strategy on_attach = "disable", -- function(bufnr). If nil, will use the deprecated mapping strategy
remove_keymaps = false, -- boolean (disable totally or not) or list of key (lhs) remove_keymaps = false, -- boolean (disable totally or not) or list of key (lhs)
view = { view = {
adaptive_size = false, adaptive_size = false,
centralize_selection = false, centralize_selection = false,
width = 30,
hide_root_folder = false,
side = "right",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
-- @deprecated
mappings = {
custom_only = false,
list = {
-- user mappings go here
},
},
float = {
enable = false,
open_win_config = {
relative = "editor",
border = "rounded",
width = 30, width = 30,
hide_root_folder = false, height = 30,
side = "right", row = 1,
preserve_window_proportions = false, col = 1,
number = false, },
relativenumber = false, },
signcolumn = "yes", },
-- @deprecated renderer = {
mappings = { add_trailing = false,
custom_only = false, group_empty = true,
list = { highlight_git = false,
-- user mappings go here full_name = false,
}, highlight_opened_files = "none",
root_folder_modifier = ":~",
indent_width = 2,
indent_markers = {
enable = false,
inline_arrows = true,
icons = {
corner = "",
edge = "",
item = "",
bottom = "",
none = " ",
},
},
icons = {
webdev_colors = true,
git_placement = "before",
padding = " ",
symlink_arrow = "",
show = {
file = true,
folder = true,
folder_arrow = true,
git = true,
},
glyphs = {
default = "",
symlink = "",
bookmark = "",
folder = {
arrow_closed = "",
arrow_open = "",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
}, },
float = { git = {
enable = false, unstaged = "",
open_win_config = { staged = "",
relative = "editor", unmerged = "",
border = "rounded", renamed = "",
width = 30, untracked = "",
height = 30, deleted = "",
row = 1, ignored = "",
col = 1,
},
}, },
}, },
renderer = { },
add_trailing = false, special_files = { "cargo.toml", "makefile", "readme.md", "readme.md" },
group_empty = true, symlink_destination = true,
highlight_git = false, },
full_name = false, hijack_directories = {
highlight_opened_files = "none", enable = true,
root_folder_modifier = ":~", auto_open = true,
indent_width = 2, },
indent_markers = { update_focused_file = {
enable = false, enable = true,
inline_arrows = true, update_root = false,
icons = { ignore_list = {},
corner = "", },
edge = "", ignore_ft_on_setup = {},
item = "", system_open = {
bottom = "", cmd = "",
none = " ", args = {},
}, },
}, diagnostics = {
icons = { enable = false,
webdev_colors = true, show_on_dirs = false,
git_placement = "before", debounce_delay = 50,
padding = " ", icons = {
symlink_arrow = "", hint = "",
show = { info = "",
file = true, warning = "",
folder = true, error = "",
folder_arrow = true, },
git = true, },
}, filters = {
glyphs = { dotfiles = false,
default = "", custom = {},
symlink = "", exclude = {},
bookmark = "", },
folder = { filesystem_watchers = {
arrow_closed = "", enable = true,
arrow_open = "", debounce_delay = 50,
default = "", },
open = "", git = {
empty = "", enable = true,
empty_open = "", ignore = true,
symlink = "", show_on_dirs = true,
symlink_open = "", timeout = 400,
}, },
git = { actions = {
unstaged = "", use_system_clipboard = true,
staged = "", change_dir = {
unmerged = "", enable = true,
renamed = "", global = false,
untracked = "", restrict_above_cwd = false,
deleted = "", },
ignored = "", expand_all = {
}, max_folder_discovery = 300,
}, exclude = {},
}, },
special_files = { "cargo.toml", "makefile", "readme.md", "readme.md" }, file_popup = {
symlink_destination = true, open_win_config = {
col = 1,
row = 1,
relative = "cursor",
border = "shadow",
style = "minimal",
}, },
hijack_directories = { },
open_file = {
quit_on_open = false,
resize_window = true,
window_picker = {
enable = true, enable = true,
auto_open = true, chars = "abcdefghijklmnopqrstuvwxyz1234567890",
}, exclude = {
update_focused_file = { filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
enable = true, buftype = { "nofile", "terminal", "help" },
update_root = false,
ignore_list = {},
},
ignore_ft_on_setup = {},
system_open = {
cmd = "",
args = {},
},
diagnostics = {
enable = false,
show_on_dirs = false,
debounce_delay = 50,
icons = {
hint = "",
info = "",
warning = "",
error = "",
}, },
}, },
filters = { },
dotfiles = false, remove_file = {
custom = {}, close_window = true,
exclude = {}, },
}, },
filesystem_watchers = { trash = {
enable = true, cmd = "gio trash",
debounce_delay = 50, require_confirm = true,
}, },
git = { live_filter = {
enable = true, prefix = "[FILTER]: ",
ignore = true, always_show_folders = true,
show_on_dirs = true, },
timeout = 400, log = {
}, enable = false,
actions = { truncate = false,
use_system_clipboard = true, types = {
change_dir = { all = false,
enable = true, config = false,
global = false, copy_paste = false,
restrict_above_cwd = false, dev = false,
}, diagnostics = false,
expand_all = { git = false,
max_folder_discovery = 300, profile = false,
exclude = {}, watcher = false,
}, },
file_popup = { },
open_win_config = { }
col = 1,
row = 1,
relative = "cursor",
border = "shadow",
style = "minimal",
},
},
open_file = {
quit_on_open = false,
resize_window = true,
window_picker = {
enable = true,
chars = "abcdefghijklmnopqrstuvwxyz1234567890",
exclude = {
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
},
},
remove_file = {
close_window = true,
},
},
trash = {
cmd = "gio trash",
require_confirm = true,
},
live_filter = {
prefix = "[FILTER]: ",
always_show_folders = true,
},
log = {
enable = false,
truncate = false,
types = {
all = false,
config = false,
copy_paste = false,
dev = false,
diagnostics = false,
git = false,
profile = 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 end
return t end
return t
end end
vim.api.nvim_create_autocmd("BufEnter", { vim.api.nvim_create_autocmd("BufEnter", {
nested = true, nested = true,
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

@ -1,28 +1,28 @@
local options = { local options = {
clipboard = "unnamedplus", clipboard = "unnamedplus",
mouse = "n", mouse = "n",
fileencoding = "utf-8", fileencoding = "utf-8",
relativenumber = true, relativenumber = true,
cursorline = false, cursorline = false,
number = true, number = true,
smartindent = true, smartindent = true,
smartcase = true, smartcase = true,
showmode = true, showmode = true,
termguicolors = true, termguicolors = true,
ignorecase = true, ignorecase = true,
showtabline = 2, showtabline = 2,
timeoutlen = 200, -- time to wait for a mapped sequence to complete (in milliseconds) timeoutlen = 200, -- time to wait for a mapped sequence to complete (in milliseconds)
undofile = true, -- enable persistent undoi updatetime = 300, -- faster completion (4000ms default) undofile = true, -- enable persistent undoi updatetime = 300, -- faster completion (4000ms default)
writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
expandtab = true, -- convert tabs to spaces expandtab = true, -- convert tabs to spaces
shiftwidth = 2, -- the number of spaces inserted for each indentation shiftwidth = 2, -- the number of spaces inserted for each indentation
tabstop = 2, -- insert 2 spaces for a tab tabstop = 2, -- insert 2 spaces for a tab
scrolloff = 8, scrolloff = 8,
sidescrolloff = 8, sidescrolloff = 8,
spell = true, spell = true,
syntax = "off", syntax = "off",
spelllang = "en_us", spelllang = "en_us",
mousemodel = "popup_setpos", mousemodel = "popup_setpos",
shell = "/usr/bin/zsh" shell = "/usr/bin/zsh"
} }
@ -34,5 +34,5 @@ vim.g.mapleader = " "
vim.keymap.set("n", "<Space>", "<Nop>", { silent = true, noremap = false }) vim.keymap.set("n", "<Space>", "<Nop>", { silent = true, noremap = false })
for k, v in pairs(options) do for k, v in pairs(options) do
vim.opt[k] = v vim.opt[k] = v
end end

View file

@ -1,36 +1,36 @@
-- Setup nvim-cmp. -- Setup nvim-cmp.
local status_ok, npairs = pcall(require, "nvim-autopairs") local status_ok, npairs = pcall(require, "nvim-autopairs")
if not status_ok then if not status_ok then
return return
end end
local Rule = require('nvim-autopairs.rule') local Rule = require('nvim-autopairs.rule')
npairs.setup({ npairs.setup({
check_ts = true, check_ts = true,
ts_config = { ts_config = {
lua = { "string", "source" }, lua = { "string", "source" },
javascript = { "string", "template_string" }, javascript = { "string", "template_string" },
java = false, java = false,
}, },
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 = "$",
keys = "qwertyuiopzxcvbnmasdfghjkl", keys = "qwertyuiopzxcvbnmasdfghjkl",
check_comma = true, check_comma = true,
highlight = "PmenuSel", highlight = "PmenuSel",
highlight_grey = "LineNr", highlight_grey = "LineNr",
}, },
}) })
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")
if not cmp_status_ok then if not cmp_status_ok then
return return
end end
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } })) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))

View file

@ -49,13 +49,12 @@ Plug('sudormrfbin/cheatsheet.nvim') -- cheatsheet for keymaps
Plug('jvgrootveld/telescope-zoxide') -- zoxide integration Plug('jvgrootveld/telescope-zoxide') -- zoxide integration
Plug('ThePrimeagen/harpoon') -- harpoonman Plug('ThePrimeagen/harpoon') -- harpoonman
Plug 'folke/trouble.nvim' -- provides warning/error explanation tab Plug 'folke/trouble.nvim' -- provides warning/error explanation tab
Plug('akinsho/toggleterm.nvim',{ ["tag"] = "*" }) -- better terminal integration Plug('akinsho/toggleterm.nvim',{ ["tag"] = "*" }) -- better terminal integration
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

@ -1,6 +1,6 @@
local tele_status_ok, telescope = pcall(require, "telescope") local tele_status_ok, telescope = pcall(require, "telescope")
if not tele_status_ok then if not tele_status_ok then
return return
end end
telescope.load_extension("project") telescope.load_extension("project")
@ -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")

View file

@ -1,37 +1,37 @@
local status_ok, _ = pcall(require, "nvim-treesitter.configs") local status_ok, _ = pcall(require, "nvim-treesitter.configs")
if not status_ok then if not status_ok then
return return
end end
require("nvim-treesitter.configs").setup({ require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all" -- A list of parser names, or "all"
ensure_installed = { ensure_installed = {
"latex", "latex",
"c", "c",
"cpp", "cpp",
"rust", "rust",
"lua", "lua",
"haskell", "haskell",
"java", "java",
"javascript", "javascript",
"typescript", "typescript",
"python", "python",
"html", "html",
"css", "css",
"yaml", "yaml",
"bash", "bash",
"json", "json",
"c_sharp", "c_sharp",
}, },
highlight = { highlight = {
enable = true, enable = true,
additional_vim_regex_highlighting = false, additional_vim_regex_highlighting = false,
}, },
}) })
local status_ok2, _ = pcall(require, "spellsitter") local status_ok2, _ = pcall(require, "spellsitter")
if not status_ok2 then if not status_ok2 then
return return
end end
require("spellsitter").setup() require("spellsitter").setup()