Add nvim config

This commit is contained in:
Thraix
2026-05-18 23:18:07 +02:00
commit e18df83174
19 changed files with 1499 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
require("core.keymaps")
require("core.options")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
error("Error cloning lazy.nvim:\n" .. out)
end
end
---@type vim.Option
local rtp = vim.opt.rtp
rtp:prepend(lazypath)
require("lazy").setup({
require("plugins.mason"),
-- require("plugins.neo-tree"),
require("plugins.bufferline"),
require("plugins.markdown_preview"),
require("plugins.colortheme"),
require("plugins.nerdtree"),
require("plugins.treesitter"),
require("plugins.telescope"),
require("plugins.lspconfig"),
require("plugins.autocompletion"),
require("plugins.autoformatting"),
require("plugins.indent-blankline"),
require("plugins.nvim-dap"),
require("plugins.ccc"),
})
+39
View File
@@ -0,0 +1,39 @@
{
"LuaSnip": { "branch": "master", "commit": "a62e1083a3cfe8b6b206e7d3d33a51091df25357" },
"blink.cmp": { "branch": "main", "commit": "d3874d2a13aa19b095bdd10d37a82a8f0aa7cad3" },
"blink.lib": { "branch": "main", "commit": "f29d8bac6549bc1e7d699c83f680823d7def98bd" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"fidget.nvim": { "branch": "main", "commit": "889e2e96edef4e144965571d46f7a77bcc4d0ddf" },
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
"indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "0c2823e0418f3d9230ff8b201c976e84de1cb401" },
"mason-null-ls.nvim": { "branch": "main", "commit": "8e7806acaa87fae64f0bfde25bb4b87c18bd19b4" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "9a10e096703966335bd5c46c8c875d5b0690dade" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" },
"mason.nvim": { "branch": "main", "commit": "cb8445f8ce85d957416c106b780efd51c6298f89" },
"nerdtree": { "branch": "master", "commit": "690d061b591525890f1471c6675bcb5bdc8cdff9" },
"none-ls-extras.nvim": { "branch": "main", "commit": "167f29529ff1438e673b1792a71aaf79ddd6c74f" },
"none-ls.nvim": { "branch": "main", "commit": "241ff8214b4ec051eb51e74a61ff729c0271b429" },
"nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" },
"nvim-dap": { "branch": "master", "commit": "45a69eba683a2c448dd9ecfc4de89511f0646b5f" },
"nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
"nvim-highlight-colors": { "branch": "main", "commit": "e4c7af0211866162d999ce0bdd6a029302e19139" },
"nvim-lspconfig": { "branch": "master", "commit": "31026a13eefb20681124706a79fc1df6bf11ab27" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" },
"nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" },
"plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" },
"ripgrep": { "branch": "master", "commit": "4519153e5e461527f4bca45b042fff45c4ec6fb9" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "master", "commit": "f04ab730b8f9c6bf3f54a206d0dcddfd70c52d59" },
"vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" },
"vscode.nvim": { "branch": "main", "commit": "aa1102a7e15195c9cca22730b09224a7f7745ba8" }
}
+19
View File
@@ -0,0 +1,19 @@
local helper = {}
function helper.find_conflict()
vim.cmd("normal! /^<<<<<<<\r")
end
function helper.resolve_top()
vim.cmd("normal! /^<<<<<<<\rdd/^=======\rd/^>>>>>>>\rdd")
end
function helper.resolve_bottom()
vim.cmd("normal! /^<<<<<<<\rd/^=======\rdd/^>>>>>>>\rdd")
end
function helper.resolve_both()
vim.cmd("normal! /^<<<<<<<\rdd/^=======\rdd/^>>>>>>>\rdd")
end
return helper
+28
View File
@@ -0,0 +1,28 @@
local helper = require("core.helper")
local opts = { noremap = true, silent = true }
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.keymap.set("n", "n", "nzzzv", opts)
vim.keymap.set("n", "N", "Nzzzv", opts)
vim.keymap.set("n", "<S-j>", "<C-d>zz", opts)
vim.keymap.set("n", "<S-k>", "<C-u>zz", opts)
vim.keymap.set("v", "<S-j>", "<C-d>zz", opts)
vim.keymap.set("v", "<S-k>", "<C-u>zz", opts)
-- vim.keymap.set('n', '<Tab>', '<cmd> bn <CR>', opts)
-- vim.keymap.set('n', '<S-Tab>', '<cmd> bp <CR>', opts)
-- vim.keymap.set('n', '<C-l>', '<cmd> tabn <CR>', opts)
-- vim.keymap.set('n', '<C-h>', '<cmd> tabp <CR>', opts)
vim.keymap.set("n", "<C-q>", "<cmd> Bd! <CR>", opts)
vim.keymap.set("n", "<leader>lw", "<cmd> set wrap! <CR>", opts)
vim.keymap.set("v", ">", ">gv", opts)
vim.keymap.set("v", "<", "<gv", opts)
vim.keymap.set("v", "p", '"_dP', opts)
vim.keymap.set("t", "<Leader><ESC>", "<C-\\><C-n>", opts)
vim.keymap.set("n", "gl", helper.find_conflict, { desc = "Find next conflict" })
vim.keymap.set("n", "[a", helper.resolve_both, { desc = "Keep both sides" })
vim.keymap.set("n", "[t", helper.resolve_top, { desc = "Keep top" })
vim.keymap.set("n", "[b", helper.resolve_bottom, { desc = "Keep bottom" })
+31
View File
@@ -0,0 +1,31 @@
vim.wo.number = true
vim.o.relativenumber = true
vim.o.clipboard = "unnamedplus"
vim.o.wrap = false
vim.o.linebreak = true
vim.o.mouse = "a"
vim.o.autoindent = true
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.shiftwidth = 2
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.expandtab = true
vim.o.cursorline = true
vim.o.smartindent = true
vim.o.showtabline = 2
vim.o.conceallevel = 0
vim.o.undofile = true
-- vim.o.colorcolumn = 120
-- Make neovim remember the last location the file was opened in
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
+154
View File
@@ -0,0 +1,154 @@
return {
"hrsh7th/nvim-cmp",
dependencies = {
-- Snippet Engine & its associated nvim-cmp source
{
"L3MON4D3/LuaSnip",
build = (function()
-- Build Step is needed for regex support in snippets.
-- This step is not supported in many windows environments.
-- Remove the below condition to re-enable on windows.
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
return
end
return "make install_jsregexp"
end)(),
dependencies = {
-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets
{
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
},
},
},
"saadparwaiz1/cmp_luasnip",
-- Adds other completion capabilities.
-- nvim-cmp does not ship with all sources by default. They are split
-- into multiple repos for maintenance purposes.
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
config = function()
-- See `:help cmp`
local cmp = require("cmp")
local luasnip = require("luasnip")
luasnip.config.setup({})
local kind_icons = {
Text = "󰉿",
Method = "m",
Function = "󰊕",
Constructor = "",
Field = "",
Variable = "󰆧",
Class = "󰌗",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "󰎠",
Enum = "",
Keyword = "󰌋",
Snippet = "",
Color = "󰏘",
File = "󰈙",
Reference = "",
Folder = "󰉋",
EnumMember = "",
Constant = "󰇽",
Struct = "",
Event = "",
Operator = "󰆕",
TypeParameter = "󰊄",
}
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = { completeopt = "menu,menuone,noselect" },
preselect = cmp.PreselectMode.None,
-- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert({
-- Select the [n]ext item
["<C-n>"] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
["<C-p>"] = cmp.mapping.select_prev_item(),
-- Scroll the documentation window [b]ack / [f]orward
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
["<C-l>"] = cmp.mapping.confirm({ select = true }),
-- If you prefer more traditional completion keymaps,
-- you can uncomment the following lines
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
["<C-Space>"] = cmp.mapping.complete({}),
-- Think of <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like:
-- function $name($args)
-- $body
-- end
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
-- ['<C-l>'] = cmp.mapping(function()
-- if luasnip.expand_or_locally_jumpable() then
-- luasnip.expand_or_jump()
-- end
-- end, { 'i', 's' }),
-- ['<C-h>'] = cmp.mapping(function()
-- if luasnip.locally_jumpable(-1) then
-- luasnip.jump(-1)
-- end
-- end, { 'i', 's' }),
}),
sources = {
{
name = "lazydev",
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "path" },
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
vim_item.menu = ({
nvim_lsp = "[LSP]",
luasnip = "[Snippet]",
buffer = "[Buffer]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
},
})
end,
}
+60
View File
@@ -0,0 +1,60 @@
return {
"nvimtools/none-ls.nvim",
dependencies = {
"nvimtools/none-ls-extras.nvim",
"jayp0521/mason-null-ls.nvim", -- ensure dependencies are installed
},
config = function()
local null_ls = require("null-ls")
-- Formatters & linters for mason to install
require("mason-null-ls").setup({
ensure_installed = {
"prettier", -- ts/js formatter
"eslint_d", -- ts/js linter
"shfmt", -- Shell formatter
"checkmake", -- linter for Makefiles
"stylua", -- lua formatter; Already installed via Mason
-- 'ruff', -- Python linter and formatter; Already installed via Mason
},
automatic_installation = true,
})
local sources = {
-- null_ls.builtins.formatting.prettier.with({ filetypes = { "html", "json", "yaml", "markdown" } }),
null_ls.builtins.formatting.stylua,
-- null_ls.builtins.formatting.terraform_fmt,
null_ls.builtins.diagnostics.checkmake,
null_ls.builtins.formatting.shfmt.with({ args = { "-i", "4" } }),
require("none-ls.formatting.ruff").with({ extra_args = { "--extend-select", "I" } }),
require("none-ls.formatting.ruff_format"),
null_ls.builtins.formatting.clang_format.with({
filetypes = { "cpp" },
}),
}
require("null-ls").setup({
sources = sources,
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
bufnr = bufnr,
filter = function(client)
return client.name == "null-ls"
end,
})
end,
})
end
end,
})
vim.keymap.set("n", "<leader>fo", vim.lsp.buf.format, {})
end,
}
+64
View File
@@ -0,0 +1,64 @@
return {
"akinsho/bufferline.nvim",
dependencies = {
"moll/vim-bbye",
"nvim-tree/nvim-web-devicons",
},
config = function()
vim.keymap.set("n", "<C-Left>", "<cmd>BufferLineMovePrev<CR>")
vim.keymap.set("n", "<C-Right>", "<cmd>BufferLineMoveNext<CR>")
vim.keymap.set("n", "<C-h>", "<cmd>BufferLineCyclePrev<CR>")
vim.keymap.set("n", "<C-l>", "<cmd>BufferLineCycleNext<CR>")
require("bufferline").setup({
options = {
mode = "buffers", -- set to "tabs" to only show tabpages instead
themable = true, -- allows highlight groups to be overriden i.e. sets highlights as default
numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string,
close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions"
buffer_close_icon = "",
close_icon = "",
path_components = 1, -- Show only the file name without the directory
modified_icon = "",
left_trunc_marker = "",
right_trunc_marker = "",
max_name_length = 30,
max_prefix_length = 30, -- prefix used when a buffer is de-duplicated
tab_size = 21,
diagnostics = false,
diagnostics_update_in_insert = false,
color_icons = true,
show_buffer_icons = true,
show_buffer_close_icons = true,
show_close_icon = true,
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
separator_style = { "", "" }, -- | "thick" | "thin" | { 'any', 'any' },
enforce_regular_tabs = true,
always_show_bufferline = true,
show_tab_indicators = false,
indicator = {
-- icon = '▎', -- this should be omitted if indicator style is not 'icon'
style = "none", -- Options: 'icon', 'underline', 'none'
},
icon_pinned = "󰐃",
minimum_padding = 1,
maximum_padding = 5,
maximum_length = 15,
sort_by = "insert_at_end",
},
highlights = {
separator = {
fg = "#434C5E",
},
buffer_selected = {
bold = true,
italic = false,
},
-- separator_selected = {},
-- tab_selected = {},
-- background = {},
-- indicator_selected = {},
-- fill = {},
},
})
end,
}
+6
View File
@@ -0,0 +1,6 @@
return {
"brenoprata10/nvim-highlight-colors",
config = function()
require("nvim-highlight-colors").setup({})
end,
}
+51
View File
@@ -0,0 +1,51 @@
return {
"Mofiqul/vscode.nvim",
lazy = false,
priority = 1000,
config = function()
-- Lua:
-- For dark theme (neovim's default)
vim.o.background = "dark"
local c = require("vscode.colors").get_colors()
require("vscode").setup({
-- Alternatively set style in setup
-- style = 'light'
-- Enable transparent background
transparent = true,
-- Enable italic comment
italic_comments = true,
-- Enable italic inlay type hints
italic_inlayhints = true,
-- Underline `@markup.link.*` variants
underline_links = true,
-- Disable nvim-tree background color
disable_nvimtree_bg = true,
-- Apply theme colors to terminal
terminal_colors = false,
-- Override colors (see ./lua/vscode/colors.lua)
color_overrides = {
vscLineNumber = "#FFFFFF",
},
-- Override highlight groups (see ./lua/vscode/theme.lua)
group_overrides = {
-- this supports the same val table as vim.api.nvim_set_hl
-- use colors from this colorscheme by requiring vscode.colors!
Cursor = { fg = c.vscDarkBlue, bg = c.vscLightGreen, bold = true },
CursorLine = { bg = c.vscTabOther },
},
})
-- require('vscode').load()
-- load the theme without affecting devicon colors.
vim.cmd.colorscheme("vscode")
end,
}
+26
View File
@@ -0,0 +1,26 @@
return
{
'lukas-reineke/indent-blankline.nvim',
main = 'ibl',
opts = {
indent = {
char = '',
},
scope = {
show_start = false,
show_end = false,
show_exact_scope = false,
},
exclude = {
filetypes = {
'help',
'startify',
'dashboard',
'packer',
'neogitstatus',
'NvimTree',
'Trouble',
},
},
},
}
+284
View File
@@ -0,0 +1,284 @@
return {
-- Main LSP Configuration
"neovim/nvim-lspconfig",
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
-- Mason must be loaded before its dependents so we need to set it up here.
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
{ "mason-org/mason.nvim", opts = {} },
"mason-org/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
-- Useful status updates for LSP.
{ "j-hui/fidget.nvim", opts = {} },
-- Allows extra capabilities provided by blink.cmp
{
"saghen/blink.cmp",
dependencies = {
"saghen/blink.lib",
},
},
},
config = function()
-- Brief aside: **What is LSP?**
--
-- LSP is an initialism you've probably heard, but might not understand what it is.
--
-- LSP stands for Language Server Protocol. It's a protocol that helps editors
-- and language tooling communicate in a standardized fashion.
--
-- In general, you have a "server" which is some tool built to understand a particular
-- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers
-- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone
-- processes that communicate with some "client" - in this case, Neovim!
--
-- LSP provides Neovim with features like:
-- - Go to definition
-- - Find references
-- - Autocompletion
-- - Symbol Search
-- - and more!
--
-- Thus, Language Servers are external tools that must be installed separately from
-- Neovim. This is where `mason` and related plugins come into play.
--
-- If you're wondering about lsp vs treesitter, you can check out the wonderfully
-- and elegantly composed help section, `:help lsp-vs-treesitter`
-- This function gets run when an LSP attaches to a particular buffer.
-- That is to say, every time a new file is opened that is associated with
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
-- function will be executed to configure the current buffer
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
callback = function(event)
-- NOTE: Remember that Lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself.
--
-- In this case, we create a function that lets us more easily define mappings specific
-- for LSP related items. It sets the mode, buffer and description for us each time.
local map = function(keys, func, desc, mode)
mode = mode or "n"
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
end
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
map("grn", vim.lsp.buf.rename, "[R]e[n]ame")
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
map("ga", vim.lsp.buf.code_action, "[G]oto Code [A]ction", { "n", "x" })
-- Find references for the word under your cursor.
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
map("gi", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
-- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>.
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header.
map("grD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
-- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc.
map("gO", require("telescope.builtin").lsp_document_symbols, "Open Document Symbols")
-- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project.
map("gW", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Open Workspace Symbols")
-- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*.
map("grt", require("telescope.builtin").lsp_type_definitions, "[G]oto [T]ype Definition")
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
---@param client vim.lsp.Client
---@param method vim.lsp.protocol.Method
---@param bufnr? integer some lsp support methods only in specific files
---@return boolean
local function client_supports_method(client, method, bufnr)
if vim.fn.has("nvim-0.11") == 1 then
return client:supports_method(method, bufnr)
else
return client.supports_method(method, { bufnr = bufnr })
end
end
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if
client
and client_supports_method(
client,
vim.lsp.protocol.Methods.textDocument_documentHighlight,
event.buf
)
then
local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd("LspDetach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
end,
})
end
-- The following code creates a keymap to toggle inlay hints in your
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if
client
and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf)
then
map("<leader>th", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
end, "[T]oggle Inlay [H]ints")
end
end,
})
-- Diagnostic Config
-- See :help vim.diagnostic.Opts
vim.diagnostic.config({
severity_sort = true,
float = { border = "rounded", source = "if_many" },
underline = { severity = vim.diagnostic.severity.ERROR },
signs = vim.g.have_nerd_font and {
text = {
[vim.diagnostic.severity.ERROR] = "󰅚 ",
[vim.diagnostic.severity.WARN] = "󰀪 ",
[vim.diagnostic.severity.INFO] = "󰋽 ",
[vim.diagnostic.severity.HINT] = "󰌶 ",
},
} or {},
virtual_text = {
source = "if_many",
spacing = 2,
format = function(diagnostic)
local diagnostic_message = {
[vim.diagnostic.severity.ERROR] = diagnostic.message,
[vim.diagnostic.severity.WARN] = diagnostic.message,
[vim.diagnostic.severity.INFO] = diagnostic.message,
[vim.diagnostic.severity.HINT] = diagnostic.message,
}
return diagnostic_message[diagnostic.severity]
end,
},
})
-- LSP servers and clients are able to communicate to each other what features they support.
-- By default, Neovim doesn't support everything that is in the LSP specification.
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
local capabilities = require("blink.cmp").get_lsp_capabilities()
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
-- Add any additional override configuration in the following tables. Available keys are:
-- - cmd (table): Override the default command used to start the server
-- - filetypes (table): Override the default list of associated filetypes for the server
-- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features.
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`ts_ls`) will work just fine
-- ts_ls = {},
--
lua_ls = {
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
runtime = { version = "LuaJIT" },
workspace = {
checkThirdParty = false,
library = vim.api.nvim_get_runtime_file("", true),
},
diagnostics = {
globals = { "vim" },
disable = { "missing-fields" },
},
format = {
enable = true,
},
},
},
},
}
-- Ensure the servers and tools above are installed
--
-- To check the current status of installed tools and/or manually install
-- other tools, you can run
-- :Mason
--
-- You can press `g?` for help in this menu.
--
-- `mason` had to be setup earlier: to configure its options see the
-- `dependencies` table for `nvim-lspconfig` above.
--
-- You can add other tools here that you want Mason to install
-- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
"stylua", -- Used to format Lua code
})
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
vim.lsp.handlers["textDocument/publishDiagnostics"] =
vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { update_in_insert = false })
require("mason-lspconfig").setup({
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
automatic_installation = false,
handlers = {
function(server_name)
local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for ts_ls)
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
require("lspconfig")[server_name].setup(server)
end,
},
})
end,
}
+9
View File
@@ -0,0 +1,9 @@
return {
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
build = "cd app && yarn install",
init = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
}
+9
View File
@@ -0,0 +1,9 @@
return {
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"clangd",
"codelldb",
},
},
}
+380
View File
@@ -0,0 +1,380 @@
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
"nvim-tree/nvim-web-devicons", -- optional, but recommended
},
config = function()
vim.keymap.set("n", "go", "<cmd> Neotree toggle position=left<CR>", opts)
require("neo-tree").setup({
close_if_last_window = false, -- Close Neo-tree if it is the last window left in the tab
popup_border_style = "NC", -- or "" to use 'winborder' on Neovim v0.11+
clipboard = {
sync = "none", -- or "global"/"universal" to share a clipboard for each/all Neovim instance(s), respectively
},
enable_git_status = true,
enable_diagnostics = true,
open_files_do_not_replace_types = { "terminal", "trouble", "qf" }, -- when opening files, do not use windows containing these filetypes or buftypes
open_files_using_relative_paths = false,
sort_case_insensitive = false, -- used when sorting files and directories in the tree
sort_function = nil, -- use a custom function for sorting files and directories in the tree
-- sort_function = function (a,b)
-- if a.type == b.type then
-- return a.path > b.path
-- else
-- return a.type > b.type
-- end
-- end , -- this sorts files and directories descendantly
default_component_configs = {
container = {
enable_character_fade = true,
},
indent = {
indent_size = 2,
padding = 1, -- extra padding on left hand side
-- indent guides
with_markers = true,
indent_marker = "",
last_indent_marker = "",
highlight = "NeoTreeIndentMarker",
-- expander config, needed for nesting files
with_expanders = nil, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
},
icon = {
folder_closed = "",
folder_open = "",
folder_empty = "󰜌",
provider = function(icon, node, state) -- default icon provider utilizes nvim-web-devicons if available
if node.type == "file" or node.type == "terminal" then
local success, web_devicons = pcall(require, "nvim-web-devicons")
local name = node.type == "terminal" and "terminal" or node.name
if success then
local devicon, hl = web_devicons.get_icon(name)
icon.text = devicon or icon.text
icon.highlight = hl or icon.highlight
end
end
end,
-- The next two settings are only a fallback, if you use nvim-web-devicons and configure default icons there
-- then these will never be used.
default = "*",
highlight = "NeoTreeFileIcon",
use_filtered_colors = true, -- Whether to use a different highlight when the file is filtered (hidden, dotfile, etc.).
},
modified = {
symbol = "[+]",
highlight = "NeoTreeModified",
},
name = {
trailing_slash = false,
use_filtered_colors = true, -- Whether to use a different highlight when the file is filtered (hidden, dotfile, etc.).
use_git_status_colors = true,
highlight = "NeoTreeFileName",
},
git_status = {
symbols = {
-- Change type
added = "", -- or "✚"
modified = "", -- or ""
deleted = "", -- this can only be used in the git_status source
renamed = "󰁕", -- this can only be used in the git_status source
-- Status type
untracked = "",
ignored = "",
unstaged = "󰄱",
staged = "",
conflict = "",
},
},
-- If you don't want to use these columns, you can set `enabled = false` for each of them individually
file_size = {
enabled = true,
width = 12, -- width of the column
required_width = 64, -- min width of window required to show this column
},
type = {
enabled = true,
width = 10, -- width of the column
required_width = 122, -- min width of window required to show this column
},
last_modified = {
enabled = true,
width = 20, -- width of the column
required_width = 88, -- min width of window required to show this column
},
created = {
enabled = true,
width = 20, -- width of the column
required_width = 110, -- min width of window required to show this column
},
symlink_target = {
enabled = false,
},
},
-- A list of functions, each representing a global custom command
-- that will be available in all sources (if not overridden in `opts[source_name].commands`)
-- see `:h neo-tree-custom-commands-global`
commands = {},
window = {
position = "left",
width = 40,
mapping_options = {
noremap = true,
nowait = true,
},
mappings = {
["<space>"] = {
"toggle_node",
nowait = false, -- disable `nowait` if you have existing combos starting with this char that you want to use
},
["u"] = "navigate_up",
["U"] = {
function(state)
local node = state.tree:get_node()
if not node then
return
end
local path
if node.type == "directory" then
path = node.path
else
path = vim.fn.fnamemodify(node.path, ":h")
end
vim.cmd("cd " .. vim.fn.fnameescape(path))
end,
desc = "cd to hovered directory",
},
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
["<esc>"] = "cancel", -- close preview or floating neo-tree window
["P"] = {
"toggle_preview",
config = {
use_float = true,
use_snacks_image = true,
use_image_nvim = true,
},
},
-- Read `# Preview Mode` for more information
["l"] = "focus_preview",
["S"] = "open_split",
["s"] = "open_vsplit",
-- ["S"] = "split_with_window_picker",
-- ["s"] = "vsplit_with_window_picker",
["t"] = "open_tabnew",
-- ["<cr>"] = "open_drop",
-- ["t"] = "open_tab_drop",
["w"] = "open_with_window_picker",
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
["C"] = "close_node",
-- ['C'] = 'close_all_subnodes',
["z"] = "close_all_nodes",
--["Z"] = "expand_all_nodes",
--["Z"] = "expand_all_subnodes",
["a"] = {
"add",
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
config = {
show_path = "none", -- "none", "relative", "absolute"
},
},
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
["d"] = "delete",
["r"] = "rename",
["b"] = "rename_basename",
["y"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["<C-r>"] = "clear_clipboard",
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
-- ["c"] = {
-- "copy",
-- config = {
-- show_path = "none" -- "none", "relative", "absolute"
-- }
--}
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
["q"] = "close_window",
["R"] = "refresh",
["?"] = "show_help",
["<"] = "prev_source",
[">"] = "next_source",
["i"] = "show_file_details",
-- ["i"] = {
-- "show_file_details",
-- -- format strings of the timestamps shown for date created and last modified (see `:h os.date()`)
-- -- both options accept a string or a function that takes in the date in seconds and returns a string to display
-- -- config = {
-- -- created_format = "%Y-%m-%d %I:%M %p",
-- -- modified_format = "relative", -- equivalent to the line below
-- -- modified_format = function(seconds) return require('neo-tree.utils').relative_date(seconds) end
-- -- }
-- },
},
},
nesting_rules = {},
filesystem = {
filtered_items = {
visible = false, -- when true, they will just be displayed differently than normal items
hide_dotfiles = true,
hide_gitignored = true,
hide_ignored = true, -- hide files that are ignored by other gitignore-like files
-- other gitignore-like files, in descending order of precedence.
ignore_files = {
".neotreeignore",
".ignore",
-- ".rgignore"
},
hide_hidden = true, -- only works on Windows for hidden files/directories
hide_by_name = {
--"node_modules"
},
hide_by_pattern = { -- uses glob style patterns
--"*.meta",
--"*/src/*/tsconfig.json",
},
always_show = { -- remains visible even if other settings would normally hide it
--".gitignored",
},
always_show_by_pattern = { -- uses glob style patterns
--".env*",
},
never_show = { -- remains hidden even if visible is toggled to true, this overrides always_show
--".DS_Store",
--"thumbs.db"
},
never_show_by_pattern = { -- uses glob style patterns
--".null-ls_*",
},
},
follow_current_file = {
enabled = false, -- This will find and focus the file in the active buffer every time
-- -- the current file is changed while the tree is open.
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
},
group_empty_dirs = false, -- when true, empty folders will be grouped together
hijack_netrw_behavior = "open_default", -- netrw disabled, opening a directory opens neo-tree
-- in whatever position is specified in window.position
-- "open_current", -- netrw disabled, opening a directory opens within the
-- window like netrw would, regardless of window.position
-- "disabled", -- netrw left alone, neo-tree does not handle opening dirs
use_libuv_file_watcher = false, -- This will use the OS level file watchers to detect changes
-- instead of relying on nvim autocmd events.
window = {
mappings = {
["<bs>"] = "navigate_up",
["."] = "set_root",
["H"] = "toggle_hidden",
["/"] = "fuzzy_finder",
["D"] = "fuzzy_finder_directory",
["#"] = "fuzzy_sorter", -- fuzzy sorting using the fzy algorithm
-- ["D"] = "fuzzy_sorter_directory",
["f"] = "filter_on_submit",
["<c-x>"] = "clear_filter",
["[g"] = "prev_git_modified",
["]g"] = "next_git_modified",
["o"] = {
"show_help",
nowait = false,
config = { title = "Order by", prefix_key = "o" },
},
["oc"] = { "order_by_created", nowait = false },
["od"] = { "order_by_diagnostics", nowait = false },
["og"] = { "order_by_git_status", nowait = false },
["om"] = { "order_by_modified", nowait = false },
["on"] = { "order_by_name", nowait = false },
["os"] = { "order_by_size", nowait = false },
["ot"] = { "order_by_type", nowait = false },
-- ['<key>'] = function(state) ... end,
},
fuzzy_finder_mappings = { -- define keymaps for filter popup window in fuzzy_finder_mode
["<down>"] = "move_cursor_down",
["<C-n>"] = "move_cursor_down",
["<up>"] = "move_cursor_up",
["<C-p>"] = "move_cursor_up",
["<esc>"] = "close",
["<S-CR>"] = "close_keep_filter",
["<C-CR>"] = "close_clear_filter",
["<C-w>"] = { "<C-S-w>", raw = true },
{
-- normal mode mappings
n = {
["j"] = "move_cursor_down",
["k"] = "move_cursor_up",
["<S-CR>"] = "close_keep_filter",
["<C-CR>"] = "close_clear_filter",
["<esc>"] = "close",
},
},
-- ["<esc>"] = "noop", -- if you want to use normal mode
-- ["key"] = function(state, scroll_padding) ... end,
},
},
commands = {}, -- Add a custom command or override a global one using the same function name
},
buffers = {
follow_current_file = {
enabled = true, -- This will find and focus the file in the active buffer every time
-- -- the current file is changed while the tree is open.
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
},
group_empty_dirs = true, -- when true, empty folders will be grouped together
show_unloaded = true,
window = {
mappings = {
["d"] = "buffer_delete",
["bd"] = "buffer_delete",
["<bs>"] = "navigate_up",
["."] = "set_root",
["o"] = {
"show_help",
nowait = false,
config = { title = "Order by", prefix_key = "o" },
},
["oc"] = { "order_by_created", nowait = false },
["od"] = { "order_by_diagnostics", nowait = false },
["om"] = { "order_by_modified", nowait = false },
["on"] = { "order_by_name", nowait = false },
["os"] = { "order_by_size", nowait = false },
["ot"] = { "order_by_type", nowait = false },
},
},
},
git_status = {
window = {
position = "float",
mappings = {
["A"] = "git_add_all",
["gu"] = "git_unstage_file",
["gU"] = "git_undo_last_commit",
["ga"] = "git_add_file",
["gr"] = "git_revert_file",
["gc"] = "git_commit",
["gp"] = "git_push",
["gg"] = "git_commit_and_push",
["o"] = {
"show_help",
nowait = false,
config = { title = "Order by", prefix_key = "o" },
},
["oc"] = { "order_by_created", nowait = false },
["od"] = { "order_by_diagnostics", nowait = false },
["om"] = { "order_by_modified", nowait = false },
["on"] = { "order_by_name", nowait = false },
["os"] = { "order_by_size", nowait = false },
["ot"] = { "order_by_type", nowait = false },
},
},
},
})
end,
}
+15
View File
@@ -0,0 +1,15 @@
return {
"preservim/nerdtree",
config = function()
function nerd_tree()
local file = vim.api.nvim_buf_get_name(0)
if file ~= "" and vim.loop.fs_stat(file) then
vim.cmd("NERDTree " .. vim.fn.fnameescape(file))
else
vim.cmd("NERDTree")
end
end
vim.keymap.set("n", "go", nerd_tree)
end,
}
+144
View File
@@ -0,0 +1,144 @@
return {
"jay-babu/mason-nvim-dap.nvim",
event = "VeryLazy",
dependencies = {
"williamboman/mason.nvim",
"mfussenegger/nvim-dap",
"nvim-neotest/nvim-nio",
"rcarriga/nvim-dap-ui",
"theHamsta/nvim-dap-virtual-text",
},
opts = {
handlers = {},
},
config = function()
local dap = require("dap")
local dapui = require("dapui")
dapui.setup()
-- dap.listeners.after.event_initialized["dapui_config"] = function()
-- dapui.open()
-- end
-- dap.listeners.after.event_terminated["dapui_config"] = function()
-- dapui.close()
-- end
-- dap.listeners.after.event_exited["dapui_config"] = function()
-- dapui.close()
-- end
function file_exists(name)
local f = io.open(name, "r")
return f ~= nil and io.close(f)
end
local dap = require("dap")
dap.adapters.codelldb = {
type = "executable",
command = "codelldb", -- or if not in $PATH: "/absolute/path/to/codelldb"
}
dap.configurations.cpp = {
{
name = "Launch file",
type = "codelldb",
request = "launch",
program = function()
if file_exists(vim.fn.getcwd() .. "/a.out") then
return vim.fn.getcwd() .. "/a.out"
end
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
-- args = function()
-- if file_exists(vim.fn.getcwd() .. "/args") then
-- local f = io.open(vim.fn.getcwd() .. "/args")
-- local content = f:read("all")
-- f:close()
-- content = content:gsub("\n", " ")
-- return vim.split(content, " ")
-- end
-- local args_string = vim.fn.input("Arguments: ")
-- return vim.split(args_string, " ")
-- end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
},
}
vim.keymap.set("n", "<leader>db", "<cmd> DapToggleBreakpoint <CR>")
vim.keymap.set("n", "<leader>dr", "<cmd> DapContinue <CR>")
vim.keymap.set("n", "<leader>du", "<cmd> DapStepOut <CR>")
vim.keymap.set("n", "<leader>di", "<cmd> DapStepInto <CR>")
vim.keymap.set("n", "<leader>dn", "<cmd> DapStepOver <CR>")
vim.keymap.set("n", "<F5>", "<cmd> DapContinue <CR>")
vim.keymap.set("n", "<F6>", "<cmd> DapToggleBreakpoint <CR>")
vim.keymap.set("n", "<F8>", "<cmd> DapStepInto <CR>")
vim.keymap.set("n", "<F9>", "<cmd> DapStepOver <CR>")
-- stylua: ignore start
vim.keymap.set("n", "C-<F5>", function() require("dap").run_last() end)
vim.keymap.set("n", "C-<F5>", function() require("dap").up() end)
vim.keymap.set("n", "<leader>dd", function() require("dap").down() end)
vim.keymap.set("n", "<leader>du", function() require("dap").up() end)
vim.keymap.set("n", "<F5>", function() require("dap").continue() end)
vim.keymap.set("n", "<leader>do", dapui.open)
vim.keymap.set("n", "<leader>dc", dapui.close)
-- { lhs = '<F29>', rhs = function() require('dap').run_last() end, opts = { desc = 'Run last' } },
-- stylua: ignore start
-- require('session-keys').sessions.dap = {
-- n = { -- mode 'n'
-- { lhs = '<F5>', rhs = function() require('dap').continue() end, opts = { desc = 'Run, continue' } },
-- { lhs = '<F17>', rhs = function() require('dap').run_to_cursor() end, opts = { desc = 'Run to cursor' } },
-- { lhs = '<F9>', rhs = function() require('dap').toggle_breakpoint() end, opts = { desc = 'Toggle breakpoint' } },
-- { lhs = '<F10>', rhs = function() require('dap').step_over() end, opts = { desc = 'Step over' } },
-- { lhs = '<F11>', rhs = function() require('dap').step_into() end, opts = { desc = 'Step into' } },
-- { lhs = '<F23>', rhs = function() require('dap').step_out() end, opts = { desc = 'Step out' } },
--
-- { lhs = '<F8>', rhs = function() require('dap').terminate() end, opts = { desc = 'Terminate' } },
-- { lhs = '<F20>', rhs = function() require('dap').disconnect({ terminateDebuggee = false }) end, opts = { desc = 'Disconnect' } },
-- { lhs = '<F29>', rhs = function() require('dap').run_last() end, opts = { desc = 'Run last' } },
--
-- { lhs = '<F6>', rhs = function() require('dap').down() end, opts = { desc = 'Go down in current stacktrace without stepping' } },
-- { lhs = '<F18>', rhs = function() require('dap').up() end, opts = { desc = 'Go up in current stacktrace without stepping' } },
--
-- { lhs = '<F7>', rhs = function() require('dap').pause() end, opts = { desc = 'Pause thread' } },
--
-- { lhs = '<F41>', rhs = function() require('dap').reverse_continue() end, opts = { desc = 'Reverse continue' } },
-- { lhs = '<F22>', rhs = function() require('dap').step_back() end, opts = { desc = 'Step back' } }
-- }
-- stylua: ignore stop
-- }
--
require("nvim-dap-virtual-text").setup {
enabled = true, -- enable this plugin (the default)
enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination)
highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables)
show_stop_reason = true, -- show stop reason when stopped for exceptions
commented = false, -- prefix virtual text with comment string
only_first_definition = true, -- only show virtual text at first definition (if there are multiple)
all_references = false, -- show virtual text on all all references of the variable (not only definitions)
clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping)
--- A callback that determines how a variable is displayed or whether it should be omitted
--- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
--- @param buf number
--- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
--- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`)
--- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text
--- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed
display_callback = function(variable, buf, stackframe, node, options)
-- by default, strip out new line characters
if options.virt_text_pos == 'inline' then
return ' = ' .. variable.value:gsub("%s+", " ")
else
return variable.name .. ' = ' .. variable.value:gsub("%s+", " ")
end
end,
-- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line
virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol',
-- experimental features:
all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine.
virt_lines = false, -- show virtual lines instead of virtual text (will flicker!)
virt_text_win_col = nil -- position the virtual text at a fixed window column (starting from the first text column) ,
}
end,
}
+119
View File
@@ -0,0 +1,119 @@
return { -- Fuzzy Finder (files, lsp, etc)
"nvim-telescope/telescope.nvim",
event = "VimEnter",
dependencies = {
"nvim-lua/plenary.nvim",
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
"nvim-telescope/telescope-fzf-native.nvim",
-- `build` is used to run some command when the plugin is installed/updated.
-- This is only run then, not every time Neovim starts up.
build = "make",
-- `cond` is a condition used to determine whether this plugin should be
-- installed and loaded.
cond = function()
return vim.fn.executable("make") == 1
end,
},
{ "nvim-telescope/telescope-ui-select.nvim" },
-- Useful for getting pretty icons, but requires a Nerd Font.
{ "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font },
{ "BurntSushi/ripgrep" },
},
config = function()
-- Telescope is a fuzzy finder that comes with a lot of different things that
-- it can fuzzy find! It's more than just a "file finder", it can search
-- many different aspects of Neovim, your workspace, LSP, and more!
--
-- The easiest way to use Telescope, is to start by doing something like:
-- :Telescope help_tags
--
-- After running this command, a window will open up and you're able to
-- type in the prompt window. You'll see a list of `help_tags` options and
-- a corresponding preview of the help.
--
-- Two important keymaps to use while in Telescope are:
-- - Insert mode: <c-/>
-- - Normal mode: ?
--
-- This opens a window that shows you all of the keymaps for the current
-- Telescope picker. This is really useful to discover what Telescope can
-- do as well as how to actually do it!
-- [[ Configure Telescope ]]
-- See `:help telescope` and `:help telescope.setup()`
require("telescope").setup({
-- You can put your default mappings / updates / etc. in here
-- All the info you're looking for is in `:help telescope.setup()`
--
defaults = {
mappings = {
i = {
["<C-j>"] = require("telescope.actions").move_selection_next,
["<C-k>"] = require("telescope.actions").move_selection_previous,
["<C-l>"] = require("telescope.actions").select_default,
},
},
},
pickers = {
find_files = {
file_ignore_patterns = { ".git" },
hidden = true,
},
},
live_grep = {
file_ignore_patterns = { ".git" },
additionalargs = function(_)
return { "--hidden" }
end,
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown(),
},
},
})
-- Enable Telescope extensions if they are installed
pcall(require("telescope").load_extension, "fzf")
pcall(require("telescope").load_extension, "ui-select")
-- See `:help telescope.builtin`
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp" })
vim.keymap.set("n", "<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
vim.keymap.set("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
vim.keymap.set("n", "<leader>ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" })
vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
vim.keymap.set("n", "<leader>sr", builtin.resume, { desc = "[S]earch [R]esume" })
vim.keymap.set("n", "<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set("n", "<leader><leader>", builtin.buffers, { desc = "[ ] Find existing buffers" })
-- Slightly advanced example of overriding default behavior and theme
vim.keymap.set("n", "<leader>/", function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
winblend = 10,
previewer = false,
}))
end, { desc = "[/] Fuzzily search in current buffer" })
-- It's also possible to pass additional configuration options.
-- See `:help telescope.builtin.live_grep()` for information about particular keys
vim.keymap.set("n", "<leader>s/", function()
builtin.live_grep({
grep_open_files = true,
prompt_title = "Live Grep in Open Files",
})
end, { desc = "[S]earch [/] in Open Files" })
-- Shortcut for searching your Neovim configuration files
vim.keymap.set("n", "<leader>sn", function()
builtin.find_files({ cwd = vim.fn.stdpath("config") })
end, { desc = "[S]earch [N]eovim files" })
end,
}
+29
View File
@@ -0,0 +1,29 @@
return {
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
main = "nvim-treesitter.configs",
opts = {
ensure_installed = {
"bash",
"c",
"cpp",
"diff",
"html",
"lua",
"luadoc",
"markdown",
"markdown_inline",
"query",
"vim",
"vimdoc",
"json",
"yaml",
},
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = { "ruby" },
},
indent = { enable = false, disable = { "ruby" } },
},
}