NeoVim & VIM

- Testing setup through neotest plugin
- Spellcheck enabled on markdown and text files
- Diagnosis summary through trouble plugin
- Code completion keybindings improved
- Auto-formatting through conform plugin
- Reactjs context aware commenting through nvim-ts-context-commentstring
- Auto HTML tag completion through nvim-ts-autotag
- CSS color highlight through nvim-highlight-colors
- Lualine: breadcrumbs, git status, single line
- Auto restore neovim sessions
- Better keyboard maps

Shell
- Aliases now load from .bashrc or .zshrc
- Bash & zsh shortcuts to easy open and create projects
- zoxide instead of cd when installed
- bootstrap.sh shellhardened
This commit is contained in:
Pratik Tripathy
2024-02-06 23:24:27 +05:30
parent 6b2d076cdc
commit b0efae3730
36 changed files with 1159 additions and 415 deletions

View File

@@ -1,4 +1,7 @@
return {
-- TODO: Figureout how to add custom snippets
{
-- Autocompletion
"hrsh7th/nvim-cmp",
@@ -10,17 +13,17 @@ return {
-- Adds LSP completion capabilities
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"hrsh7th/cmp-buffer",
-- Adds a number of user-friendly snippets
"rafamadriz/friendly-snippets",
-- Autocompletion for commands
"hrsh7th/cmp-cmdline",
},
config = function()
-- [[ Configure nvim-cmp ]]
-- See `:help cmp`
-- vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
local cmp = require("cmp")
local defaults = require("cmp.config.default")()
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
luasnip.config.setup({})
@@ -37,58 +40,64 @@ return {
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-u>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete({}),
["<C-x>"] = cmp.mapping.abort(),
-- Enter to perform the completion
["<CR>"] = cmp.mapping.confirm({
select = true,
}),
["<S-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_locally_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.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "path" },
{ { name = "buffer" } },
},
-- experimental = {
-- ghost_text = {
-- hl_group = "CmpGhostText",
-- },
-- },
sorting = defaults.sorting,
})
end,
},
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
}
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{
name = "cmdline",
option = {
ignore_cmds = { "Man", "!" }
}
}
})
})
end
{
"L4MON4D3/LuaSnip",
keys = {
{
"<tab>",
function()
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
end,
expr = true,
silent = true,
mode = "i",
},
{
"<tab>",
function()
require("luasnip").jump(1)
end,
mode = "s",
},
{
"<s-tab>",
function()
require("luasnip").jump(-1)
end,
mode = { "i", "s" },
},
},
},
}

View File

@@ -1,10 +1,5 @@
-- debug.lua
--
-- Shows how to use the DAP plugin to debug your code.
--
-- Primarily focused on configuring the debugger for Go, but can
-- be extended to other languages as well. That's why it's called
-- kickstart.nvim and not kitchen-sink.nvim ;)
-- be extended to other languages as well.
return {
"mfussenegger/nvim-dap",
@@ -24,23 +19,20 @@ return {
local dapui = require("dapui")
require("mason-nvim-dap").setup({
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
-- Makes a best effort to setup the various debuggers with reasonable debug configurations
automatic_setup = true,
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {},
-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
-- You'll need to check that you have the required things installed online
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
"delve",
-- "delve",
-- TODO: Rust, C#, TS/JS, Python
},
})
-- Basic debugging keymaps, feel free to change to your liking!
vim.keymap.set("n", "<F5>", dap.continue, { desc = "Debug: Start/Continue" })
vim.keymap.set("n", "<F1>", dap.step_into, { desc = "Debug: Step Into" })
vim.keymap.set("n", "<F2>", dap.step_over, { desc = "Debug: Step Over" })
@@ -50,12 +42,9 @@ return {
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end, { desc = "Debug: Set Breakpoint" })
-- Dap UI setup
-- For more information, see |:help nvim-dap-ui|
dapui.setup({
-- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = "", collapsed = "", current_frame = "*" },
controls = {
icons = {
@@ -80,6 +69,7 @@ return {
dap.listeners.before.event_exited["dapui_config"] = dapui.close
-- Install golang specific config
require("dap-go").setup()
-- require("dap-go").setup()
-- TODO: Rust, C#, TS/JS, Python
end,
}

View File

@@ -1,70 +1,51 @@
-- autoformat.lua
return {
"neovim/nvim-lspconfig",
config = function()
-- Switch for controlling whether you want autoformatting.
-- Use :KickstartFormatToggle to toggle autoformatting on or off
local format_is_enabled = true
vim.api.nvim_create_user_command("KickstartFormatToggle", function()
format_is_enabled = not format_is_enabled
print("Setting autoformatting to: " .. tostring(format_is_enabled))
end, {})
{
"stevearc/conform.nvim",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
-- Create an augroup that is used for managing our formatting autocmds.
-- We need one augroup per client to make sure that multiple clients
-- can attach to the same buffer without interfering with each other.
local _augroups = {}
local get_augroup = function(client)
if not _augroups[client.id] then
local group_name = "kickstart-lsp-format-" .. client.name
local id = vim.api.nvim_create_augroup(group_name, { clear = true })
_augroups[client.id] = id
end
conform.setup({
formatters_by_ft = {
javascript = { { "prettierd", "prettier" } },
typescript = { { "prettierd", "prettier" } },
javascriptreact = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" } },
svelte = { { "prettierd", "prettier" } },
css = { { "prettierd", "prettier" } },
html = { { "prettierd", "prettier" } },
json = { { "prettierd", "prettier" } },
yaml = { { "prettierd", "prettier" } },
markdown = { { "prettierd", "prettier" } },
graphql = { { "prettierd", "prettier" } },
lua = { "stylua" },
python = { "black" },
sh = { "shfmt", "shellharden" },
bash = { "shfmt", "shellharden" },
zsh = { "shfmt", "shellharden" },
["*"] = { "codespell" },
["_"] = { "trim_whitespace" },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 1000,
},
formatters = {
shfmt = {
prepend_args = { "-i", "4" },
},
},
})
return _augroups[client.id]
end
-- Whenever an LSP attaches to a buffer, we will run this function.
--
-- See `:help LspAttach` for more information about this autocmd event.
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-attach-format", { clear = true }),
-- This is where we attach the autoformatting for reasonable clients
callback = function(args)
local client_id = args.data.client_id
local client = vim.lsp.get_client_by_id(client_id)
local bufnr = args.buf
-- Only attach to clients that support document formatting
if not client.server_capabilities.documentFormattingProvider then
return
end
-- Tsserver usually works poorly. Sorry you work with bad languages
-- You can remove this line if you know what you're doing :)
if client.name == "tsserver" then
return
end
-- Create an autocmd that will run *before* we save the buffer.
-- Run the formatting command for the LSP that has just attached.
vim.api.nvim_create_autocmd("BufWritePre", {
group = get_augroup(client),
buffer = bufnr,
callback = function()
if not format_is_enabled then
return
end
vim.lsp.buf.format({
async = false,
filter = function(c)
return c.id == client.id
end,
})
end,
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 1000,
})
end,
})
end,
end, { desc = "[C]ode [F]ormat (visual selection)" })
end,
},
}

View File

@@ -5,7 +5,16 @@ return {
{ "machakann/vim-highlightedyank" },
-- "gc" to comment visual regions/lines
{ "numToStr/Comment.nvim", opts = {} },
{
"numToStr/Comment.nvim",
config = function()
require("Comment").setup({
pre_hook = function()
return vim.bo.commentstring
end,
})
end,
},
-- auto pairs
{
@@ -18,13 +27,21 @@ return {
{
"lukas-reineke/indent-blankline.nvim",
opts = {
indent = { char = "", tab_char = "", },
indent = { char = "", tab_char = "" },
scope = { enabled = false },
exclude = {
filetypes = {
"help", "alpha", "dashboard", "neo-tree",
"Trouble", "trouble", "lazy", "mason",
"notify", "toggleterm", "lazyterm",
"help",
"alpha",
"dashboard",
"neo-tree",
"Trouble",
"trouble",
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
},
},
},
@@ -34,13 +51,18 @@ return {
-- Highlights the current level of indentation, and animates the highlighting.
{
"echasnovski/mini.indentscope",
opts = { symbol = "", options = { try_as_border = true }, },
opts = { symbol = "", options = { try_as_border = true } },
init = function()
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"help", "neo-tree", "Trouble", "trouble",
"lazy", "mason", "notify", "toggleterm",
"lazyterm",
"help",
"neo-tree",
"Trouble",
"trouble",
"lazy",
"mason",
"notify",
"toggleterm",
},
callback = function()
vim.b.miniindentscope_disable = true
@@ -61,14 +83,134 @@ return {
},
},
keys = {
{ "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" },
{ "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" },
{
"]t",
function()
require("todo-comments").jump_next()
end,
desc = "Next todo comment",
},
{
"[t",
function()
require("todo-comments").jump_prev()
end,
desc = "Previous todo comment",
},
-- TODO: Find better keymaps for below
-- { "<leader>xt", "<cmd>TodoTrouble<cr>", desc = "Todo (Trouble)" },
-- { "<leader>xT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme (Trouble)" },
-- { "<leader>st", "<cmd>TodoTelescope<cr>", desc = "Todo" },
-- { "<leader>sT", "<cmd>TodoTelescope keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme" },
{ "<leader>dt", "<cmd>TodoTrouble<cr>", desc = "Todo (Trouble)" },
{ "<leader>dT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme (Trouble)" },
-- TODO: Include hidden files
{ "<leader>lt", "<cmd>TodoTelescope<cr>", desc = "List Todo" },
{ "<leader>lT", "<cmd>TodoTelescope keywords=TODO,FIX,FIXME<cr>", desc = "List Todo/Fix/Fixme" },
},
},
-- better diagnostics list and others
{
"folke/trouble.nvim",
cmd = { "TroubleToggle", "Trouble" },
opts = { use_diagnostic_signs = true },
keys = {
{ "<leader>dx", "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" },
{ "<leader>dw", "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" },
{ "<leader>dl", "<cmd>TroubleToggle loclist<cr>", desc = "Location List (Trouble)" },
{ "<leader>dq", "<cmd>TroubleToggle quickfix<cr>", desc = "Quickfix List (Trouble)" },
{
"[q",
function()
if require("trouble").is_open() then
require("trouble").previous({ skip_groups = true, jump = true })
else
local ok, err = pcall(vim.cmd.cprev)
if not ok then
vim.notify(err, vim.log.levels.ERROR)
end
end
end,
desc = "Previous trouble/quickfix item",
},
{
"]q",
function()
if require("trouble").is_open() then
require("trouble").next({ skip_groups = true, jump = true })
else
local ok, err = pcall(vim.cmd.cnext)
if not ok then
vim.notify(err, vim.log.levels.ERROR)
end
end
end,
desc = "Next trouble/quickfix item",
},
},
},
-- Inlay hints
{
"lvimuser/lsp-inlayhints.nvim",
config = function()
require("lsp-inlayhints").setup()
-- Lazy load on LspAttach
vim.api.nvim_create_augroup("LspAttach_inlayhints", {})
vim.api.nvim_create_autocmd("LspAttach", {
group = "LspAttach_inlayhints",
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local bufnr = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, bufnr)
end,
})
end,
},
-- Lsp Breadcrumbs for lualine
{
"SmiteshP/nvim-navic",
lazy = true,
init = function()
vim.g.navic_silence = true
require("config.util").on_lsp_attach(function(client, buffer)
if client.supports_method("textDocument/documentSymbol") then
require("nvim-navic").attach(client, buffer)
end
end)
end,
opts = function()
return {
separator = " ",
highlight = true,
depth_limit = 5,
icons = require("config.util").icons.kinds,
lazy_update_context = true,
}
end,
},
{
"SmiteshP/nvim-navbuddy",
dependencies = {
"SmiteshP/nvim-navic",
"MunifTanjim/nui.nvim",
},
opts = {
lsp = { auto_attach = true },
icons = require("config.util").icons.kinds,
},
keys = {
{
"<leader>v",
function()
return require("nvim-navbuddy").open()
end,
desc = "N[v]igate through document symbols",
},
},
},
}

View File

@@ -1,6 +1,6 @@
return {
{ "tpope/vim-fugitive", },
{ "tpope/vim-fugitive" },
--{ "tpope/vim-rhubarb" }, --If fugitive.vim is the Git, rhubarb.vim is the Hub.
{
@@ -14,6 +14,7 @@ return {
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
@@ -52,6 +53,7 @@ return {
end, { desc = "reset git hunk" })
-- normal mode
map("n", "<leader>ghp", gs.preview_hunk, { desc = "preview git hunk" })
map("n", "<leader>gp", gs.preview_hunk, { desc = "preview git hunk" })
map("n", "<leader>ghr", gs.reset_hunk, { desc = "git reset hunk" })
map("n", "<leader>ghb", function()

View File

@@ -0,0 +1,61 @@
return {
{
"mfussenegger/nvim-lint",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
config = function()
local lint = require("lint")
-- Linters are only required for dynamically typed languages
lint.linters_by_ft = {
-- javascript = { "eslint_d" },
-- typescript = { "eslint_d" },
-- javascriptreact = { "eslint_d" },
-- typescriptreact = { "eslint_d" },
svelte = { "eslint_d" },
python = { "pylint" },
["*"] = { "codespell" },
}
-- Uncomment and use the below section in `package.json` to enable eslint_d
-- "eslintConfig": {
-- "root": true,
-- "extends": [
-- "eslint:recommended",
-- "plugin:@typescript-eslint/recommended"
-- ],
-- "parser": "@typescript-eslint/parser",
-- "parserOptions": {
-- "project": [
-- "./tsconfig.json"
-- ]
-- },
-- "plugins": [
-- "@typescript-eslint"
-- ],
-- "rules": {
-- "@typescript-eslint/strict-boolean-expressions": [
-- 2,
-- {
-- "allowString": false,
-- "allowNumber": false
-- }
-- ]
-- },
-- "ignorePatterns": [
-- "src/**/*.test.ts",
-- "src/frontend/generated/*"
-- ]
-- }
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
end,
},
}

View File

@@ -10,25 +10,15 @@ local on_attach = function(_, bufnr)
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end
nmap("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
nmap("<leader>cr", vim.lsp.buf.rename, "[R]e[n]ame")
nmap("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
nmap("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
nmap("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition")
nmap("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
nmap("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
-- See `:help K` for why this keymap
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
nmap("<leader>wl", function()
nmap("<leader>cws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
nmap("<leader>cwl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, "[W]orkspace [L]ist Folders")
@@ -44,62 +34,92 @@ return {
"neovim/nvim-lspconfig",
dependencies = {
-- Automatically install LSPs to stdpath for neovim
{ "williamboman/mason.nvim", config = true },
{ "williamboman/mason.nvim", config = true },
{ "williamboman/mason-lspconfig.nvim" },
-- Useful status updates for LSP
{ "j-hui/fidget.nvim", opts = {} },
{ "j-hui/fidget.nvim", opts = {} },
{ "folke/neodev.nvim" },
},
-- WARN: DO NOT do config here
-- That would override config from autoformat
-- WARN: DO NOT do `config` here it would override `config` from coding-formatting.lua
-- That's why we do the LSP config inside mason-lspconfig
},
{
"williamboman/mason-lspconfig.nvim",
config = function()
-- NOTE: We configure lsp here instead of in the lspconfig's config
-- Reason? read the warnings above
-- Configure LSP
-- mason-lspconfig requires that these setup functions are called in this order
-- before setting up the servers.
-- BEFORE setting up the servers.
require("mason").setup()
require("mason-lspconfig").setup()
local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup()
-- Enable the following language servers
-- Add any additional override configuration in the following tables. They will be passed to
-- the `settings` field of the server config. You must look up that documentation yourself.
--
-- If you want to override the default filetypes that your language server will attach to you can
-- define the property 'filetypes' to the map in question.
-- Add any additional override configuration in the following tables. They will be passed to the `settings` field of the server config
-- If you want to override the default filetypes that your language server will attach to you can define the property 'filetypes' to the map in question.
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
-- tsserver = {},
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
-- hint = { enable = true },
-- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } },
},
},
-- Markdown
marksman = {},
awk_ls = {},
bashls = {
filetypes = { "sh", "bash", "zsh" },
},
cssls = {},
dockerls = {},
docker_compose_language_service = {},
html = { filetypes = { 'html', 'twig', 'hbs' } },
jsonls = {},
pyright = {},
rust_analyzer = {},
tsserver = {
typescript = {
inlayHints = {
-- includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
},
javascript = {
inlayHints = {
-- includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = false,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
}
},
}
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
-- Ensure the servers above are installed
local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup({
ensure_installed = vim.tbl_keys(servers),
})
@@ -120,22 +140,19 @@ return {
{
"j-hui/fidget.nvim",
opts = {
-- Options related to LSP progress subsystem
progress = {
poll_rate = 1, -- How and when to poll for progress messages
suppress_on_insert = true, -- Suppress new messages while in insert mode
ignore_done_already = true, -- Ignore new tasks that are already complete
poll_rate = 1, -- How and when to poll for progress messages
suppress_on_insert = true, -- Suppress new messages while in insert mode
ignore_done_already = true, -- Ignore new tasks that are already complete
ignore_empty_message = true, -- Ignore new tasks that don't contain a message
ignore = {}, -- List of LSP servers to ignore
ignore = {}, -- List of LSP servers to ignore
-- Options related to how LSP progress messages are displayed as notifications
display = {
render_limit = 1, -- How many LSP messages to show at once
render_limit = 1, -- How many LSP messages to show at once
skip_history = true, -- Whether progress notifications should be omitted from history
},
},
-- Options related to notification subsystem
notification = {
filter = vim.log.levels.WARN, -- Minimum notifications level
},

View File

@@ -0,0 +1,33 @@
return {
-- Automatically add closing tags for HTML and JSX
{
"windwp/nvim-ts-autotag",
config = function()
require("nvim-ts-autotag").setup()
end,
},
-- Intelligent commenting on JSX
{
"JoosepAlviste/nvim-ts-context-commentstring",
opts = {
options = {
enable_autocmd = false,
},
},
config = function()
vim.g.skip_ts_context_commentstring_module = true
end,
},
-- Highlight colors
{
"brenoprata10/nvim-highlight-colors",
setup = {
enable_tailwind = true,
},
config = function()
require("nvim-highlight-colors").setup()
end,
},
}

View File

@@ -0,0 +1,120 @@
return {
-- Test runner integration
-- Taken from LazyVim
{
"nvim-neotest/neotest",
dependencies = {
"nvim-lua/plenary.nvim",
"antoinemadec/FixCursorHold.nvim",
"nvim-treesitter/nvim-treesitter",
"marilari88/neotest-vitest"
},
opts = {
-- Do NOT add adapters here
-- Add it to opts.adapters inside config function
adapters = {},
status = { virtual_text = true },
output = { open_on_run = true },
quickfix = {
open = function()
if require("lazy.core.config").spec.plugins["trouble.nvim"] ~= nil then
require("trouble").open({ mode = "quickfix", focus = false })
else
vim.cmd("copen")
end
end,
},
},
config = function(_, opts)
local neotest_ns = vim.api.nvim_create_namespace("neotest")
vim.diagnostic.config({
virtual_text = {
format = function(diagnostic)
-- Replace newline and tab characters with space for more compact diagnostics
local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+",
"")
return message
end,
},
}, neotest_ns)
-- WARN: Change the following code if we change lazy.nvim
if require("lazy.core.config").spec.plugins["trouble.nvim"] ~= nil then
opts.consumers = opts.consumers or {}
-- Refresh and auto close trouble after running tests
---@type neotest.Consumer
opts.consumers.trouble = function(client)
client.listeners.results = function(adapter_id, results, partial)
if partial then
return
end
local tree = assert(client:get_position(nil, { adapter = adapter_id }))
local failed = 0
for pos_id, result in pairs(results) do
if result.status == "failed" and tree:get_key(pos_id) then
failed = failed + 1
end
end
vim.schedule(function()
local trouble = require("trouble")
if trouble.is_open() then
trouble.refresh()
if failed == 0 then
trouble.close()
end
end
end)
return {}
end
end
end
-- TIP: Add adapters here
table.insert(opts.adapters, require("neotest-vitest"))
if opts.adapters then
local adapters = {}
for name, config in pairs(opts.adapters or {}) do
if type(name) == "number" then
if type(config) == "string" then
config = require(config)
end
adapters[#adapters + 1] = config
elseif config ~= false then
local adapter = require(name)
if type(config) == "table" and not vim.tbl_isempty(config) then
local meta = getmetatable(adapter)
if adapter.setup then
adapter.setup(config)
elseif meta and meta.__call then
adapter(config)
else
error("Adapter " .. name .. " does not support setup")
end
end
adapters[#adapters + 1] = adapter
end
end
opts.adapters = adapters
end
require("neotest").setup(opts)
end,
-- stylua: ignore
keys = {
-- TIP: Shortcuts in test summary window:
-- r: Run the selected test
-- a: Attaches to the test result (output)
-- i: Jumps to the code of the test
{ "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Test: Run File" },
{ "<leader>tT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Test: Run All Test Files" },
{ "<leader>tr", function() require("neotest").run.run() end, desc = "Test: Run Nearest" },
{ "<leader>tl", function() require("neotest").run.run_last() end, desc = "Test: Run Last" },
{ "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Test: Toggle Summary" },
{ "<leader>to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Test: Show Output" },
{ "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Test: Toggle Output Panel" },
{ "<leader>tS", function() require("neotest").run.stop() end, desc = "Test: Stop" },
},
},
}

View File

@@ -20,16 +20,27 @@ return {
function()
require("neo-tree.command").execute({ source = "buffers", toggle = true })
end,
desc = "NeoTree: Open [B]uffer [E]xplorer",
desc = "NeoTree: Open [B]buffer [E]xplorer",
},
},
deactivate = function()
vim.cmd([[Neotree close]])
end,
init = function()
if vim.fn.argc(-1) == 1 then
local stat = vim.loop.fs_stat(vim.fn.argv(0))
if stat and stat.type == "directory" then
require("neo-tree")
end
end
end,
opts = {
enable_git_status = true,
filesystem = {
bind_to_cwd = true,
follow_current_file = {
enabled = true, -- Highlight the current buffer
leave_dirs_open = true,
leave_dirs_open = false,
},
use_libuv_file_watcher = true, -- Sync file system changes
filtered_items = {
@@ -41,25 +52,65 @@ return {
},
window = {
position = "left",
width = 30, -- Saner window size
width = 30, -- Saner window size
mappings = {
["s"] = "open_split", -- Default vim keymap for horizontal split
["v"] = "open_vsplit", -- Default vim keymap for vertical split
["s"] = "open_split", -- horizontal split
["v"] = "open_vsplit", -- vertical split
["Y"] = function(state)
local node = state.tree:get_node()
local path = node:get_id()
vim.fn.setreg("+", path, "c")
end,
},
},
default_component_configs = {
indent = {
indent_size = 2, -- Compact tree display
with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
expander_collapsed = "",
expander_expanded = "",
expander_highlight = "NeoTreeExpander",
},
},
sources = { "filesystem", "buffers", "git_status", "document_symbols" },
open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
},
config = function(_, opts)
local config = require("config.util")
local function on_move(data)
config.on_rename(data.source, data.destination)
end
local events = require("neo-tree.events")
opts.event_handlers = opts.event_handlers or {}
vim.list_extend(opts.event_handlers, {
{ event = events.FILE_MOVED, handler = on_move },
{ event = events.FILE_RENAMED, handler = on_move },
})
require("neo-tree").setup(opts)
vim.api.nvim_create_autocmd("TermClose", {
pattern = "*lazygit",
callback = function()
if package.loaded["neo-tree.sources.git_status"] then
require("neo-tree.sources.git_status").refresh()
end
end,
})
end,
},
-- Automatically highlights other instances of the word under cursor
{
"RRethy/vim-illuminate",
lazy = false,
opts = {
delay = 200,
large_file_cutoff = 2000,
large_file_override = {
providers = { "lsp" },
},
},
config = function(_, opts)
-- Copied from LazyNvim
require("illuminate").configure(opts)
@@ -104,13 +155,17 @@ return {
},
event = "VeryLazy",
keys = {
{ "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle buffer-pin" },
{ "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle buffer-pin" },
{ "<leader>xo", "<Cmd>BufferLineCloseOthers<CR>", desc = "Delete other buffers" },
},
opts = {
options = {
close_command = function(n) require("mini.bufremove").delete(n, false) end,
right_mouse_command = function(n) require("mini.bufremove").delete(n, false) end,
close_command = function(n)
require("mini.bufremove").delete(n, false)
end,
right_mouse_command = function(n)
require("mini.bufremove").delete(n, false)
end,
diagnostics = "nvim_lsp",
always_show_bufferline = false,
offsets = {
@@ -121,6 +176,9 @@ return {
text_align = "left",
},
},
numbers = function(opts)
return string.format("%s", opts.raise(opts.id))
end,
},
},
config = function(_, opts)
@@ -161,7 +219,7 @@ return {
},
opts = {
render = "wrapped-compact", -- Smaller popups
timeout = 3000,
timeout = 2500,
max_height = function()
return math.floor(vim.o.lines * 0.25)
end,
@@ -184,11 +242,17 @@ return {
},
opts = {
lsp = {
progress = {
throttle = 1000 / 100,
},
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
hover = {
silent = true,
},
},
routes = {
{
@@ -214,11 +278,15 @@ return {
{ find = "yanked" },
{ find = "fewer lines" },
{ find = "more lines" },
{ find = "EasyMotion" }, -- This can be completely discarded
{ find = "EasyMotion" },
{ find = "Target key" },
{ find = "search hit BOTTOM" },
{ find = "lines to indent" },
{ find = "lines indented" },
{ find = "lines changed" },
{ find = ">ed" },
{ find = "<ed" },
{ find = "The only match" },
},
},
},
@@ -233,15 +301,6 @@ return {
},
keys = {
{ "<leader>nx", "<cmd>NoiceDismiss<CR>", desc = "Dismiss all [N]oice notifications" },
-- TODO: Find better keymaps
-- { "<S-Enter>", function() require("noice").redirect(vim.fn.getcmdline()) end, mode = "c", desc = "Redirect Cmdline" },
-- { "<leader>snl", function() require("noice").cmd("last") end, desc = "Noice Last Message" },
-- { "<leader>snh", function() require("noice").cmd("history") end, desc = "Noice History" },
-- { "<leader>sna", function() require("noice").cmd("all") end, desc = "Noice All" },
-- { "<leader>snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" },
-- { "<leader>snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" },
-- { "<c-f>", function() if not require("noice.lsp").scroll(4) then return "<c-f>" end end, silent = true, expr = true, desc = "Scroll forward", mode = { "i", "n", "s" } },
-- { "<c-b>", function() if not require("noice.lsp").scroll(-4) then return "<c-b>" end end, silent = true, expr = true, desc = "Scroll backward", mode = { "i", "n", "s" } },
},
},
@@ -249,16 +308,123 @@ return {
{
"nvim-lualine/lualine.nvim",
-- See `:help lualine.txt`
opts = {
-- TODO: Need the following:
-- - Remove encoding & OS
-- - Add Breadcrumb
-- - Show command that was typed
options = {
icons_enabled = false,
component_separators = "|",
section_separators = "",
},
},
--
init = function()
vim.g.lualine_laststatus = vim.o.laststatus
if vim.fn.argc(-1) > 0 then
-- set an empty statusline till lualine loads
vim.o.statusline = " "
else
-- hide the statusline on the starter page
vim.o.laststatus = 0
end
end,
opts = function()
local lualine_require = require("lualine_require")
lualine_require.require = require
vim.o.laststatus = vim.g.lualine_laststatus
local config = require("config.util")
return {
options = {
theme = "auto",
icons_enabled = true,
globalstatus = true,
component_separators = "|",
section_separators = "",
},
extensions = { "neo-tree", "lazy" },
sections = {
lualine_a = { "mode" },
lualine_b = { "branch" },
lualine_c = {
{
"diagnostics",
symbols = {
error = config.icons.diagnostics.Error,
warn = config.icons.diagnostics.Warn,
info = config.icons.diagnostics.Info,
hint = config.icons.diagnostics.Hint,
},
},
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{
"filename",
file_status = true,
path = 1,
},
-- Breadcrumbs from "nvim-navic" plugin
{
function()
return require("nvim-navic").get_location()
end,
cond = function()
return package.loaded["nvim-navic"] and require("nvim-navic").is_available()
end,
},
},
lualine_x = {
{
function()
return require("noice").api.status.command.get()
end,
cond = function()
return package.loaded["noice"] and require("noice").api.status.command.has()
end,
color = config.fg("Statement"),
},
{
function()
return require("noice").api.status.mode.get()
end,
cond = function()
return package.loaded["noice"] and require("noice").api.status.mode.has()
end,
color = config.fg("Constant"),
},
{
function()
return "" .. require("dap").status()
end,
cond = function()
return package.loaded["dap"] and require("dap").status() ~= ""
end,
color = config.fg("Debug"),
},
{
"diff",
symbols = {
added = config.icons.git.added,
modified = config.icons.git.modified,
removed = config.icons.git.removed,
},
source = function()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end,
},
},
lualine_y = {
{ "progress", separator = " ", padding = { left = 1, right = 0 } },
{ "location", padding = { left = 0, right = 1 } },
},
lualine_z = {
function()
return "" .. os.date("%R")
end,
},
},
}
end,
},
}

View File

@@ -52,14 +52,10 @@ return {
-- Load some required Telescope extensions
pcall(require("telescope").load_extension, "fzf")
pcall(require("telescope").load_extension, "noice")
pcall(require("telescope").load_extension, "undo")
-- Special Things: [T]elescope
vim.keymap.set("n", "<leader>tr", require("telescope.builtin").resume,
{ desc = "[T]elescope [R]esume Last Search" })
vim.keymap.set("n", "<leader>tc", require("telescope.builtin").colorscheme,
{ desc = "List Colorschemes (with preview)" })
vim.keymap.set("n", "<leader>nc", require("telescope.builtin").colorscheme,
{ desc = "List [N]eovim [C]olorschemes (with preview)" })
-- Grep things -> [S]earch
vim.keymap.set("n", "<leader>sb", function()
@@ -83,8 +79,7 @@ return {
{ desc = "[L]ist & Search NeoVIM [H]elp" })
vim.keymap.set("n", "<leader>lk", require("telescope.builtin").keymaps,
{ desc = "[L]ist & Search NeoVIM [K]eymaps" })
vim.keymap.set("n", "<leader>lm", require("telescope.builtin").marks, { desc = "[L]ist [M]arks" })
vim.keymap.set("n", "<leader>ln", require("telescope.builtin").man_pages,
vim.keymap.set("n", "<leader>lm", require("telescope.builtin").man_pages,
{ desc = "[L]ist & Search System Ma[n] Pages" })
vim.keymap.set("n", "<leader>lq", require("telescope.builtin").quickfixhistory,
{ desc = "[L]ist [Q]uickfix History" })
@@ -106,14 +101,24 @@ return {
require("telescope.builtin").lsp_implementations,
{ desc = "[C]ode: Goto [I]mplementation of the word under cursor" }
)
vim.keymap.set("n", "<leader>cr", require("telescope.builtin").lsp_references,
vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references,
{ desc = "[C]ode: List [R]eferences for word under cursor" })
vim.keymap.set(
"n",
"<leader>ct",
"<leader>cgt",
require("telescope.builtin").lsp_type_definitions,
{ desc = "[C]ode: Goto definition of the [T]ype under cursor" }
)
vim.keymap.set("n", "gd", require("telescope.builtin").lsp_definitions, { desc = "[G]oto [D]efinition" })
vim.keymap.set("n", "<leader>cgd", require("telescope.builtin").lsp_type_definitions,
{ desc = "Type [D]efinition" })
vim.keymap.set("n", "<leader>cR", require("telescope.builtin").lsp_references,
{ desc = "[G]oto [R]eferences" })
vim.keymap.set("n", "<leader>cI", require("telescope.builtin").lsp_implementations,
{ desc = "[G]oto [I]mplementation" })
vim.keymap.set("n", "<leader>cs", require("telescope.builtin").lsp_document_symbols,
{ desc = "[D]ocument [S]ymbols" })
-- vim.keymap.set("n", "<leader>cgD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" })
end,
},
}

View File

@@ -53,6 +53,7 @@ return {
ensure_installed = {
-- These 2 are required for cmdline
"regex",
"markdown",
"markdown_inline",
},
@@ -117,8 +118,8 @@ return {
floating_preview_opts = {},
peek_definition_code = {
-- TIP: Press the shortcut 2 times to enter the floating window
["<leader>df"] = { query = "@function.outer", desc = "Peek function definition on a popup" },
["<leader>dF"] = { query = "@class.outer", desc = "Peek class definition on a popup" },
["<leader>cd"] = { query = "@function.outer", desc = "Peek function definition on a popup" },
["<leader>cD"] = { query = "@class.outer", desc = "Peek class definition on a popup" },
},
},
},

View File

@@ -2,13 +2,19 @@ return {
-- Navigate between NVIM & Tmux splits seamlessly
{ "christoomey/vim-tmux-navigator" },
-- Navigate between NVIM & kitty splits seamlessly
{
"knubie/vim-kitty-navigator",
build = "cp ./*.py ~/.config/kitty/",
},
-- Open Kitty terminal scrollback as buffer
{
"mikesmithgh/kitty-scrollback.nvim",
lazy = true,
cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" },
event = { "User KittyScrollbackLaunch" },
version = "^3.0.0",
version = "^4.0.0",
opts = {
status_window = {
icons = { nvim = "" },
@@ -26,13 +32,9 @@ return {
require("which-key").register({
["<leader>e"] = { name = "[E]xplorer", _ = "which_key_ignore" },
["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" },
["<leader>d"] = { name = "[D]ocument", _ = "which_key_ignore" },
["<leader>g"] = { name = "[G]it", _ = "which_key_ignore" },
["<leader>h"] = { name = "Git [H]unk", _ = "which_key_ignore" },
["<leader>r"] = { name = "[R]ename", _ = "which_key_ignore" },
["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
["<leader>t"] = { name = "[T]oggle", _ = "which_key_ignore" },
["<leader>w"] = { name = "[W]orkspace", _ = "which_key_ignore" },
})
-- register which-key VISUAL mode
-- required for visual <leader>hs (hunk stage) to work
@@ -43,20 +45,46 @@ return {
end,
},
-- Session management. This saves your session in the background,
-- keeping track of open buffers, window arrangement, and more.
-- You can restore sessions when returning through the dashboard.
-- Session management. Saves your session in the background
{
-- TODO:
-- 1. Find out where they are stored exactly.
-- 2. Add them to source control
-- 3. Need a startup dashboard with options for loading last session
"folke/persistence.nvim",
event = "BufReadPre",
opts = { options = vim.opt.sessionoptions:get() },
opts = {
-- Session files stored at: ~/.config/nvim/sessions/
dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"),
options = vim.opt.sessionoptions:get()
-- NOTE: autocmd to autoload sessions at: ../config/autocmd.lua
},
keys = {
{ "<leader>sr", function() require("persistence").load() end, desc = "[R]estore [S]ession" },
{ "<leader>sl", function() require("persistence").load({ last = true }) end, desc = "[R]estore [L]ast Session" },
-- Since we are auto-restoring sessions, keymaps aren't required
-- { "<leader>sr", function() require("persistence").load() end, desc = "[R]estore [S]ession" },
-- { "<leader>sl", function() require("persistence").load({ last = true }) end, desc = "[R]estore [L]ast Session" },
},
},
-- Speedup loading large files by disabling some plugins
{
"LunarVim/bigfile.nvim",
lazy = true,
opts = {
filesize = 2, --2MiB
pattern = "*",
features = {
"indent_blankline",
"lsp",
"syntax",
"treesitter",
},
},
},
-- Provides tldr on vertical split
-- `:Tldr [command]`
{
"wlemuel/vim-tldr",
lazy = true,
dependencies = {
"nvim-telescope/telescope.nvim"
},
},
}