Big neovim config refactor + adjustments

This commit is contained in:
2024-04-16 01:29:18 +02:00
parent 8031f3fe6a
commit 5574cc866a
42 changed files with 1001 additions and 875 deletions

View File

@@ -1,6 +1,6 @@
-- https://github.com/windwp/nvim-autopairs
return {
'windwp/nvim-autopairs',
event = "VeryLazy",
opts = {},
"windwp/nvim-autopairs",
event = "InsertEnter",
config = true,
}

View File

@@ -1,6 +0,0 @@
-- https://github.com/windwp/nvim-ts-autotag
return {
'windwp/nvim-ts-autotag',
event = "VeryLazy",
opts = {},
}

View File

@@ -1,35 +1,36 @@
-- https://github.com/akinsho/bufferline.nvim
local diagnostic = require("symbols.diagnostic")
local file = require("symbols.file")
return {
'akinsho/bufferline.nvim',
"akinsho/bufferline.nvim",
version = "v3.*",
dependencies = {
'ojroques/nvim-bufdel',
"ojroques/nvim-bufdel",
},
config = function()
-- Enable mousemoveevent if possible
vim.o.mousemoveevent = true;
vim.o.mousemoveevent = true
local bufferline = require('bufferline');
local bufferline = require("bufferline")
-- Setup keybinds to move between buffers
vim.keymap.set('n', '<tab>', function()
vim.keymap.set("n", "<tab>", function()
bufferline.cycle(1)
end, { silent = true, desc = 'Goto next buffer' })
vim.keymap.set('n', '<S-tab>', function()
end, { silent = true, desc = "Goto next buffer" })
vim.keymap.set("n", "<S-tab>", function()
bufferline.cycle(-1)
end, { silent = true, desc = 'Goto previous buffer' })
end, { silent = true, desc = "Goto previous buffer" })
-- Setup keybinds to move buffers around
vim.keymap.set('n', '<leader>b[', function()
vim.keymap.set("n", "<leader>b[", function()
bufferline.move(-1)
end, { silent = true, desc = '[B]uffer to the [ left' })
vim.keymap.set('n', '<leader>b]', function()
end, { silent = true, desc = "[B]uffer to the [ left" })
vim.keymap.set("n", "<leader>b]", function()
bufferline.move(1)
end, { silent = true, desc = '[B]uffer to the ] right' })
end, { silent = true, desc = "[B]uffer to the ] right" })
local symbols = require('constant.symbols');
bufferline.setup {
bufferline.setup({
options = {
show_buffer_icons = false,
show_buffer_close_icons = true,
@@ -37,25 +38,25 @@ return {
close_command = "BufDel %d",
right_mouse_command = "BufDel %d",
separator_style = "thick",
left_trunc_marker = '',
right_trunc_marker = '',
left_trunc_marker = "",
right_trunc_marker = "",
sort_by = "insert_at_end",
indicator = {
style = 'none',
style = "none",
},
modified_icon = symbols.file.modified,
modified_icon = file.modified,
---@diagnostic disable-next-line: unused-local
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local s = " "
for e, n in pairs(diagnostics_dict) do
local sym = e == "error" and symbols.diagnostic.error .. ' '
or (e == "warning" and symbols.diagnostic.warning .. ' ')
or (e == "info" and symbols.diagnostic.info .. ' ' or symbols.diagnostic.hint .. ' ')
local sym = e == "error" and diagnostic.error .. " "
or (e == "warning" and diagnostic.warn .. " ")
or (e == "info" and diagnostic.info .. " " or diagnostic.hint .. " ")
s = s .. n .. sym
end
return s
end
end,
},
}
end
})
end,
}

View File

@@ -0,0 +1,77 @@
-- https://github.com/hrsh7th/nvim-cmp
-- TODO: Go over this
return {
-- Autocompletion
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-path",
"onsails/lspkind-nvim",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
luasnip.config.setup({})
local border = require("symbols.window").border
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered({ border = border, winhighlight = "CursorLine:YankHighlight" }),
documentation = cmp.config.window.bordered({ border = border }),
},
-- Include the source of the cmp entry
formatting = {
format = lspkind.cmp_format({
mode = "text",
menu = {
nvim_lsp = "LSP",
luasnip = "LuaSnip",
path = "Path",
},
}),
},
mapping = cmp.mapping.preset.insert({
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete({}),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = {
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "path" },
},
})
end,
}

View File

@@ -1,7 +1,11 @@
-- https://github.com/stevearc/conform.nvim
local slow_format_filetypes = {}
return {
"stevearc/conform.nvim",
dependencies = {
"williamboman/mason.nvim",
},
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
@@ -16,26 +20,7 @@ return {
},
},
opts = {
-- TODO: Automate installing these using e.g. mason
formatters_by_ft = {
c = { "clang-format" },
cpp = { "clang-format" },
go = { "goimports", "gofmt" },
python = { "ruff_format" },
rust = { "rustfmt" },
javascript = { { "prettierd", "prettier" } },
typescript = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" } },
css = { { "prettierd", "prettier" } },
markdown = { { "prettierd", "prettier" } },
lua = { "stylua" },
json = { "jq" },
yaml = { { "prettierd", "prettier" } },
toml = { "taplo" },
cmake = { "cmake_format" },
-- ["*"] = { "codespell" },
["_"] = { "trim_whitespace", "trim_newlines" },
},
formatters_by_ft = require("tools").formatters,
format_on_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
@@ -59,7 +44,7 @@ return {
end
return { lsp_fallback = true }
end,
notify_on_error = true,
-- log_level = vim.log.levels.DEBUG,
},
init = function()
vim.api.nvim_create_user_command("FormatDisable", function(args)

View File

@@ -0,0 +1,12 @@
return {
"j-hui/fidget.nvim",
opts = {
notification = {
window = {
border = require("symbols.window").border,
y_padding = 1,
x_padding = 2,
},
},
},
}

View File

@@ -0,0 +1,45 @@
return {
-- Adds git related signs to the gutter, as well as utilities for managing changes
"lewis6991/gitsigns.nvim",
opts = {
signs = {
add = { text = "+" },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
},
},
init = function()
vim.keymap.set("n", "<leader>gs", require("gitsigns.actions").stage_hunk, { desc = "[G]it [S]tage hunk" })
vim.keymap.set("v", "<leader>gs", function()
require("gitsigns.actions").stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { desc = "[G]it [S]tage selection" })
vim.keymap.set(
"n",
"<leader>gS",
require("gitsigns.actions").undo_stage_hunk,
{ desc = "[G]it undo [S]tage hunk" }
)
vim.keymap.set(
"n",
"<leader>gd",
require("gitsigns.actions").preview_hunk_inline,
{ desc = "[G]it [D]iff hunk" }
)
vim.keymap.set("n", "<leader>gr", require("gitsigns.actions").reset_hunk, { desc = "[G]it [R]eset hunk" })
vim.keymap.set("v", "<leader>gr", function()
require("gitsigns.actions").reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { desc = "[G]it [R]eset selection" })
vim.keymap.set("n", "]g", function()
require("gitsigns.actions").nav_hunk("next")
end, { desc = "Go to next hunk" })
vim.keymap.set("n", "[g", function()
require("gitsigns.actions").nav_hunk("prev")
end, { desc = "Go to previous hunk" })
end,
}

View File

@@ -0,0 +1,7 @@
-- https://github.com/smjonas/inc-rename.nvim
return {
"smjonas/inc-rename.nvim",
opts = {
preview_empty_name = true,
},
}

View File

@@ -0,0 +1,14 @@
-- https://github.com/lukas-reineke/indent-blankline.nvim
return {
-- Add indentation guides even on blank lines
"lukas-reineke/indent-blankline.nvim",
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help indent_blankline.txt`
main = "ibl",
opts = {
indent = {
char = "¦",
},
scope = { enabled = true },
},
}

View File

@@ -0,0 +1,104 @@
return {
-- LSP Configuration & Plugins
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
-- Some of the lsp keybindings rely on telescope
"nvim-telescope/telescope.nvim",
-- Set capabilities from cmp
"hrsh7th/cmp-nvim-lsp",
-- Additional lua configuration, makes nvim stuff amazing!
{ "folke/neodev.nvim", opts = {} },
-- Add document color
"mrshmllow/document-color.nvim",
"b0o/schemastore.nvim",
-- Rename with immediate visual feedback
},
config = function()
local border = require("symbols.window").border
-- Set borders
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border })
vim.lsp.handlers["textDocument/signatureHelp"] =
vim.lsp.with(vim.lsp.handlers.signature_help, { border = border })
require("lspconfig.ui.windows").default_options = {
border = border,
}
-- Create the signs for diagnostic symbols
local diagnostic = require("symbols.diagnostic")
local signs = {
Error = diagnostic.error,
Warn = diagnostic.warning,
Hint = diagnostic.hint,
Info = diagnostic.info,
}
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("dx-lsp-attach", { clear = true }),
callback = function(event)
local map = function(keys, func, desc)
vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP:" .. desc })
end
map("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
map("<leader>D", vim.lsp.buf.type_definition, "Type [D]efinition")
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]symbols")
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]symbols")
vim.keymap.set("n", "<leader>rn", function()
return ":IncRename " .. vim.fn.expand("<cword>")
end, { buffer = event.buf, expr = true, desc = "LSP: [R]e[N]ame" })
-- Also works in visual mode
-- TODO: Is that something we even need?
vim.keymap.set(
{ "v", "n" },
"<leader>ca",
vim.lsp.buf.code_action,
{ buffer = event.buf, desc = "LSP: [C]ode [A]ction", remap = true }
)
-- Signature help
map("K", vim.lsp.buf.hover, "Hover Documentation")
map("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
end,
})
local capabilities = vim.lsp.protocol.make_client_capabilities()
-- TODO: Only do this is cmp_nvim_lsp is enabled
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
-- TODO: Check if this is still up to date
capabilities.textDocument.colorProvider = {
dynamicRegistration = true,
}
require("mason-lspconfig").setup({
handlers = {
function(server_name)
local server = require("tools").servers[server_name] or {}
server.capabilities = vim.tbl_deep_extend("force", capabilities, server.capabilities or {})
require("lspconfig")[server_name].setup(server)
end,
},
})
end,
}

View File

@@ -0,0 +1,14 @@
-- https://github.com/ray-x/lsp_signature.nvim
return {
"ray-x/lsp_signature.nvim",
event = "VeryLazy",
dependencies = {
"neovim/nvim-lspconfig",
},
opts = {
hint_enable = false,
handler_opts = {
border = require("symbols.window").border,
},
},
}

View File

@@ -0,0 +1,39 @@
-- https://github.com/nvim-lualine/lualine.nvim
return {
"nvim-lualine/lualine.nvim",
opts = {
options = {
icons_enabled = true,
theme = "gruvbox",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
},
sections = {
lualine_b = {
"branch",
"diff",
{
"diagnostics",
symbols = require("symbols.diagnostic"),
},
},
lualine_c = {
{
"filename",
path = 1,
symbols = require("symbols.file"),
},
},
lualine_x = {
"encoding",
{ "fileformat", icons_enabled = false },
"filetype",
},
},
inactive_sections = {
lualine_c = {
{ "filename", path = 1 },
},
},
},
}

View File

@@ -1,8 +0,0 @@
-- https://github.com/zapling/mason-conform.nvim
return {
"zapling/mason-conform.nvim",
dependencies = {
"williamboman/mason.nvim",
},
opts = {},
}

View File

@@ -0,0 +1,28 @@
return {
{
"williamboman/mason.nvim",
opts = {
ui = {
border = require("symbols.window").border,
height = 0.8,
},
},
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
dependencies = {
"williamboman/mason.nvim",
},
config = function()
local tools = require("tools")
local ensure_installed = vim.tbl_keys(tools.servers)
ensure_installed =
vim.list_extend(ensure_installed, require("util.mason").process_formatters(tools.formatters))
ensure_installed = vim.list_extend(ensure_installed, tools.extra)
require("mason-tool-installer").setup({
ensure_installed = ensure_installed,
})
end,
},
}

View File

@@ -1,20 +1,22 @@
-- https://github.com/nvim-neo-tree/neo-tree.nvim
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
local fold = require("symbols.fold")
local file = require("symbols.file")
return {
'nvim-neo-tree/neo-tree.nvim',
"nvim-neo-tree/neo-tree.nvim",
version = "v2.x",
dependencies = {
'nvim-lua/plenary.nvim',
'MunifTanjim/nui.nvim',
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
},
cmd = { 'Neotree' },
cmd = { "Neotree" },
keys = {
{ '<F2>', '<cmd>Neotree toggle reveal filesystem float<cr>', desc = 'Open floating Neo-tree window' },
{ "<F2>", "<cmd>Neotree toggle reveal filesystem float<cr>", desc = "Open floating Neo-tree window" },
},
config = function()
local symbols = require('constant.symbols');
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])
require('neo-tree').setup {
require("neo-tree").setup({
close_if_last_window = true,
enable_diagnostics = true,
source_selector = {
@@ -22,27 +24,27 @@ return {
},
default_component_configs = {
icon = {
folder_closed = symbols.fold.closed,
folder_open = symbols.fold.open,
folder_empty = symbols.fold.empty,
default = symbols.file.icon,
folder_closed = fold.closed,
folder_open = fold.open,
folder_empty = fold.empty,
default = file.icon,
},
modified = {
symbol = symbols.file.modified,
symbol = file.modified,
},
name = {
use_git_status_colors = false,
},
git_status = {
symbols = symbols.git,
}
symbols = require("symbols.git"),
},
},
filesystem = {
filtered_items = {
hide_dotfiles = false,
hide_by_name = {
".git"
}
".git",
},
},
use_libuv_file_watcher = true,
},
@@ -60,6 +62,6 @@ return {
},
},
},
}
})
end,
}

View File

@@ -1,17 +0,0 @@
return {
enabled = false,
'jose-elias-alvarez/null-ls.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
},
event = "VeryLazy",
config = function()
local null_ls = require('null-ls')
null_ls.setup {
sources = {
null_ls.builtins.code_actions.gitsigns,
}
}
end,
}

View File

@@ -1,34 +1,30 @@
-- https://github.com/toppair/peek.nvim
return {
'toppair/peek.nvim',
build = 'deno task --quiet build:fast',
"toppair/peek.nvim",
build = "deno task --quiet build:fast",
cond = function()
return vim.fn.executable 'deno' == 1
return vim.fn.executable("deno") == 1
end,
lazy = true,
cmds = { "PeekOpen", "PeekClose" },
init = function()
vim.api.nvim_create_user_command('PeekOpen', function() require('peek').open() end, {})
vim.api.nvim_create_user_command('PeekClose', function() require('peek').close() end, {})
vim.api.nvim_create_user_command("PeekOpen", function()
require("peek").open()
end, {})
vim.api.nvim_create_user_command("PeekClose", function()
require("peek").close()
end, {})
local augroup = vim.api.nvim_create_augroup('Peek', { clear = true })
-- Automatically open a markdown preview window
vim.api.nvim_create_autocmd({ "FileType" }, {
callback = function()
require('peek').open()
end,
group = augroup,
pattern = "markdown",
})
-- local augroup = vim.api.nvim_create_augroup('Peek', { clear = true })
--
-- -- Automatically open a markdown preview window
-- vim.api.nvim_create_autocmd({ "FileType" }, {
-- callback = function()
-- require('peek').open()
-- end,
-- group = augroup,
-- pattern = "markdown",
-- })
end,
opts = {},
-- config = function()
-- local peek = require('peek');
--
--
-- peek.setup {
--
-- }
-- end
}

View File

@@ -1,7 +1,6 @@
-- https://github.com/kylechui/nvim-surround
return {
'kylechui/nvim-surround',
version = '*', -- Use for stability; omit to use `main` branch for the latest features
event = 'VeryLazy',
"kylechui/nvim-surround",
event = "VeryLazy",
config = true,
}

View File

@@ -1,13 +1,14 @@
-- https://github.com/simrat39/symbols-outline.nvim
return {
'simrat39/symbols-outline.nvim',
enabled = false,
"simrat39/symbols-outline.nvim",
keys = {
{
'<F5>',
"<F5>",
function()
require('symbols-outline').toggle_outline()
require("symbols-outline").toggle_outline()
end,
desc = 'Toggle symbols outline'
desc = "Toggle symbols outline",
},
},
opts = {},

View File

@@ -0,0 +1,92 @@
-- https://github.com/nvim-telescope/telescope.nvim
-- TODO: Ensure installed ripgrep
return {
"nvim-telescope/telescope.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope-ui-select.nvim",
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
cond = function()
return vim.fn.executable("make") == 1
end,
},
},
config = function()
require("telescope").setup({
pickers = {
find_files = {
hidden = true,
},
},
defaults = {
file_ignore_patterns = {
".git/",
},
mappings = {
n = {
["<S-Tab>"] = "move_selection_next",
["<Tab>"] = "move_selection_previous",
},
i = {
["<S-Tab>"] = "move_selection_next",
["<Tab>"] = "move_selection_previous",
},
},
borderchars = require("symbols.window").borderchars,
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown(),
},
},
})
require("telescope").load_extension("fzf")
require("telescope").load_extension("ui-select")
vim.keymap.set(
"n",
"<leader>.",
require("telescope.builtin").oldfiles,
{ desc = "[.] Find recently opened files" }
)
vim.keymap.set(
"n",
"<leader><space>",
require("telescope.builtin").buffers,
{ desc = "[ ] Find existing buffers" }
)
vim.keymap.set("n", "<leader>/", function()
require("telescope.builtin").current_buffer_fuzzy_find({
-- Show matches in the order they appear in the document
sorting_strategy = "ascending",
})
end, { desc = "[/] Fuzzily search in current buffer" })
vim.keymap.set("n", "<leader>s/", function()
require("telescope.builtin").live_grep({
grep_open_files = true,
prompt_title = "Live Grep in Open Files",
})
end, { desc = "[S]earch [/] in Open Files" })
vim.keymap.set("n", "<leader>sf", require("telescope.builtin").find_files, { desc = "[S]earch [F]iles" })
vim.keymap.set("n", "<leader>sh", require("telescope.builtin").help_tags, { desc = "[S]earch [H]elp" })
vim.keymap.set("n", "<leader>sw", function()
require("telescope.builtin").grep_string({
-- Show matches in the order they appear in the document
sorting_strategy = "ascending",
})
end, { desc = "[S]earch current [W]ord" })
vim.keymap.set("n", "<leader>sg", require("telescope.builtin").live_grep, { desc = "[S]earch by [G]rep" })
vim.keymap.set("n", "<leader>sd", require("telescope.builtin").diagnostics, { desc = "[S]earch [D]iagnostics" })
vim.keymap.set("n", "<leader>sr", require("telescope.builtin").resume, { desc = "[S]earch [R]esume" })
vim.keymap.set("n", "<leader>sk", require("telescope.builtin").keymaps, { desc = "[S]earch [K]eymaps" })
vim.keymap.set("n", "<leader>sn", function()
require("telescope.builtin").find_files({ cwd = vim.fn.stdpath("config") })
end, { desc = "[S]earch [N]eovim files" })
end,
}

View File

@@ -1,14 +1,14 @@
-- https://github.com/folke/todo-comments.nvim
local diagnostic = require("symbols.diagnostic")
return {
-- NOTE: Using a fork for the time being upstream does not support authors
-- 'folke/todo-comments.nvim',
'doongjohn/todo-comments.nvim',
"doongjohn/todo-comments.nvim",
dependencies = {
'nvim-lua/plenary.nvim',
"nvim-lua/plenary.nvim",
},
config = function()
local symbols = require('constant.symbols')
vim.keymap.set("n", "]t", function()
require("todo-comments").jump_next()
end, { desc = "Next todo comment" })
@@ -23,18 +23,18 @@ return {
vim.keymap.set("n", "<F4>", "<cmd>TroubleToggle todo<cr>", { desc = "Next todo comment" })
end
if pcall(require, "telescope") then
vim.keymap.set('n', '<leader>st', '<cmd>TodoTelescope<cr>', { desc = '[S]earch [T]odo' })
vim.keymap.set("n", "<leader>st", "<cmd>TodoTelescope<cr>", { desc = "[S]earch [T]odo" })
end
require('todo-comments').setup {
require("todo-comments").setup({
keywords = {
FIX = { icon = symbols.diagnostic.bug },
TODO = { icon = symbols.diagnostic.todo },
HACK = { icon = symbols.diagnostic.hack },
WARN = { icon = symbols.diagnostic.warning },
PERF = { icon = symbols.diagnostic.performance },
NOTE = { icon = symbols.diagnostic.note },
TEST = { icon = symbols.diagnostic.test },
FIX = { icon = diagnostic.bug },
TODO = { icon = diagnostic.todo },
HACK = { icon = diagnostic.hack },
WARN = { icon = diagnostic.warning },
PERF = { icon = diagnostic.performance },
NOTE = { icon = diagnostic.note },
TEST = { icon = diagnostic.test },
},
highlight = {
-- TODO: Have multiline, but end when %p (punctuation) is at the end of a line
@@ -43,7 +43,7 @@ return {
pattern = [[(KEYWORDS)\s*(\([^\)]*\))?:]],
},
search = {
pattern = [[\b(KEYWORDS)(\(.*\))?:]]
pattern = [[\b(KEYWORDS)(\(.*\))?:]],
},
colors = {
error = { "DiagnosticError", "ErrorMsg", "#DC2626" },
@@ -51,8 +51,8 @@ return {
info = { "Todo", "#2563EB" },
hint = { "DiagnosticHint", "#10B981" },
default = { "Identifier", "#7C3AED" },
test = { "Identifier", "#FF00FF" }
test = { "Identifier", "#FF00FF" },
},
}
})
end,
}

View File

@@ -0,0 +1,104 @@
return {
{
-- Highlight, edit, and navigate code
"nvim-treesitter/nvim-treesitter",
dependencies = {
"nvim-treesitter/nvim-treesitter-context",
"nvim-treesitter/nvim-treesitter-textobjects",
"windwp/nvim-ts-autotag",
},
opts = {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = {
"c",
"cpp",
"go",
"lua",
"python",
"rust",
"tsx",
"typescript",
"vimdoc",
"vim",
"markdown",
"markdown_inline",
"bash",
},
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<c-space>",
node_incremental = "<c-space>",
scope_incremental = "<c-s>",
node_decremental = "<M-space>",
},
},
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
-- ["ac"] = "@class.outer",
-- ["ic"] = "@class.inner",
},
},
move = {
enable = true,
set_jumps = true,
goto_next_start = {
["]a"] = "@parameter.inner",
["]f"] = "@function.outer",
["]c"] = "@class.outer",
},
goto_next_end = {
["]A"] = "@parameter.inner",
["]F"] = "@function.outer",
["]c"] = "@class.outer",
},
goto_previous_start = {
["[a"] = "@parameter.inner",
["[f"] = "@function.outer",
["[c"] = "@class.outer",
},
goto_previous_end = {
["[A"] = "@parameter.inner",
["[F"] = "@function.outer",
["[c"] = "@class.outer",
},
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
},
},
autotag = {
enable = true,
},
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
require("nvim-treesitter.install").update({ with_sync = true })
end,
},
{
"nvim-treesitter/nvim-treesitter-context",
opts = {
separator = require("symbols.window").borderchars[3],
},
},
}

View File

@@ -1,18 +0,0 @@
-- https://github.com/Wansmer/treesj
return {
enabled = false,
'Wansmer/treesj',
keys = {
{
'<space>m',
function()
require('treesj').toggle()
end,
desc = "Split or Join code block"
},
},
dependencies = { 'nvim-treesitter/nvim-treesitter' },
opts = {
use_default_keymaps = false,
}
}

View File

@@ -1,18 +1,19 @@
-- https://github.com/folke/trouble.nvim
local fold = require("symbols.fold")
return {
'folke/trouble.nvim',
cmd = { 'Trouble', 'TroubleToggle', },
"folke/trouble.nvim",
cmd = { "Trouble", "TroubleToggle" },
keys = {
{ '<F3>', '<cmd>TroubleToggle workspace_diagnostics<cr>', desc = 'Goto previous buffer' },
{ "<F3>", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Goto previous buffer" },
},
config = function()
local symbols = require('constant.symbols');
require('trouble').setup {
require("trouble").setup({
icons = false,
auto_close = true,
fold_open = symbols.fold.open, -- icon used for open folds
fold_closed = symbols.fold.close, -- icon used for closed folds
fold_open = fold.open, -- icon used for open folds
fold_closed = fold.close, -- icon used for closed folds
use_diagnostic_signs = true,
}
end
})
end,
}

View File

@@ -0,0 +1,23 @@
-- https://github.com/folke/which-key.nvim
return {
"folke/which-key.nvim",
opts = {
window = {
border = "single",
margin = { 1, 5, 2, 3 },
padding = { 0, 0, 0, 0 },
},
},
init = function()
-- TODO: Can we tie these to where the keymaps are registered?
require("which-key").register({
["<leader>g"] = { name = "[G]it", _ = "which_key_ignore" },
["<leader>b"] = { name = "[B]buffer", _ = "which_key_ignore" },
["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" },
["<leader>d"] = { name = "[D]ocument", _ = "which_key_ignore" },
["<leader>w"] = { name = "[W]orkspace", _ = "which_key_ignore" },
["<leader>r"] = { name = "[R]e[N]ame", _ = "which_key_ignore" },
})
end,
}

View File

@@ -1,18 +1,19 @@
return {
'johnfrankmorgan/whitespace.nvim',
enabled = false,
"johnfrankmorgan/whitespace.nvim",
config = function()
require('whitespace-nvim').setup({
require("whitespace-nvim").setup({
-- configuration options and their defaults
-- `highlight` configures which highlight is used to display
-- trailing whitespace
highlight = 'CursorLine',
highlight = "CursorLine",
-- `ignored_filetypes` configures which filetypes to ignore when
-- displaying trailing whitespace
ignored_filetypes = { 'TelescopePrompt', 'Trouble', 'help' },
ignored_filetypes = { "TelescopePrompt", "Trouble", "help" },
})
-- remove trailing whitespace with a keybinding
vim.keymap.set('n', '<Leader>t', require('whitespace-nvim').trim, { desc = "Remove trailing whitespace" })
end
vim.keymap.set("n", "<Leader>t", require("whitespace-nvim").trim, { desc = "Remove trailing whitespace" })
end,
}