This commit is contained in:
Oliver Ladner 2025-04-18 22:19:37 +02:00
commit 12c87776a5
35 changed files with 522 additions and 645 deletions

7
.luarc.json Normal file
View file

@ -0,0 +1,7 @@
{
"runtime.version": "LuaJIT",
"runtime.path": ["lua/?.lua", "lua/?/init.lua"],
"diagnostics.globals": ["vim"],
"workspace.checkThirdParty": false,
"workspace.library": ["$VIMRUNTIME"]
}

View file

@ -4,6 +4,7 @@
- `;` leader key
- `:checkhealth [<pluginname>]` check base or plugin status
- `:checkhealth vim.lsp` show details of LSP attached to buffer
- `:verbose set expandtab?` check where `expandtab` has been set last
- `:Lazy` show package manager UI
- `:Mason` show Mason UI
@ -49,6 +50,7 @@
- `Ctrl`+`l` accept selected suggestion
- `gd` go to definition
- `gr` show references of function
- `grn` renames all refs of the symbol under cursor
- `leader`+`q` toggle `trouble.nvim` quickfix list
- `leader`+`da` go to next diagnostic (any severity)
- `leader`+`dw` go to next diagnostic (_warning_ severity)

View file

@ -29,20 +29,16 @@ It's not too important. Still, I try to balance increasing startup time with
the usefullness of a plugin.
Output from lazy.nvim profiling (`:Lazy profile`) on a MacBook Pro M2 Max,
macOS 14 on Neovim 0.10.1.
macOS 15 on Neovim 0.11.0.
### Start and open init.lua
Around 10% of the plugins are lazy-loaded.
Around 15% of the plugins are lazy-loaded.
```bash
Startuptime: 96.76ms
Based on the actual CPU time of the Neovim process till UIEnter.
This is more accurate than `nvim --startuptime`.
LazyStart 13.3ms
LazyDone 41.06ms (+27.76ms)
UIEnter 96.76ms (+55.71ms)
LazyStart 18.67ms
LazyDone 43.52ms (+24.85ms)
UIEnter 110.71ms (+67.19ms)
```
### Starting with an empty file
@ -50,13 +46,9 @@ This is more accurate than `nvim --startuptime`.
Around 50% of the plugins are lazy-loaded.
```bash
Startuptime: 49.82ms
Based on the actual CPU time of the Neovim process till UIEnter.
This is more accurate than `nvim --startuptime`.
LazyStart 13.75ms
LazyDone 40.39ms (+26.64ms)
UIEnter 49.82ms (+9.43ms)
LazyStart 18.15ms
LazyDone 46.91ms (+28.76ms)
UIEnter 59.08ms (+12.17ms)
```
## Plugins
@ -70,26 +62,20 @@ This is more accurate than `nvim --startuptime`.
| **nvim-treesitter-context** | Shows current line context | <https://github.com/nvim-treesitter/nvim-treesitter-context> |
| **nvim-treesitter-textobjects** | ? | <https://github.com/nvim-treesitter/nvim-treesitter-textobjects> |
| **oil.nvim** | file explorer, (bulk file creation/rename) | <https://github.com/stevearc/oil.nvim> |
| **tokyonight.nvim** | Theme with treesitter/lsp support | <https://github.com/folke/tokyonight.nvim> |
| **rose-pine** | Theme | <https://github.com/rose-pine/neovim> |
| **lualine.nvim** | Status line | <https://github.com/nvim-lualine/lualine.nvim> |
| **gitsigns.nvim** | Git change indicator | <https://github.com/lewis6991/gitsigns.nvim> |
| **which-key.nvim** | Shows contextual key bindings | <https://github.com/folke/which-key.nvim> |
| **vim-illuminate** | Highlight similar words (w/ LSP, Treesitter, regex) | <https://github.com/RRethy/vim-illuminate> |
| **lsp-zero.nvim** | LSP for mere mortals | <https://github.com/VonHeikemen/lsp-zero.nvim> |
| **nvim-lspconfig** | Component of lsp-zero.nvim | <https://github.com/neovim/nvim-lspconfig> |
| **cmp-nvim-lsp** | Dependency of lsp-zero.nvim | <https://github.com/hrsh7th/cmp-nvim-lsp> |
| **conform.nvim** | Formatter configuration, replacement for `null-ls` | <https://github.com/stevearc/conform.nvim> |
| **mason.nvim** | Install/manage LSP/DAP servers, linters and formatters | <https://github.com/williamboman/mason.nvim> |
| **mason-lspconfig.nvim** | Bridges mason.nvim with the lspconfig plugin | <https://github.com/williamboman/mason-lspconfig.nvim> |
| **zen-mode.nvim** | Distraction-free coding for Neovim | <https://github.com/folke/zen-mode.nvim> |
| **twilight.nvim** | Dims inactive portions of the code you're editing | <https://github.com/folke/twilight.nvim> |
| **todo-comments.nvim** | Highlights `NOTE:`, `FIXME:` etc. and makes them findable via Telescope | <https://github.com/folke/todo-comments.nvim> |
| **mini.nvim** | I use the icons | <https://github.com/echasnovski/mini.nvim> |
| **flash.nvim** | Navigation and Treesitter selection w/ search labels | <https://github.com/folke/flash.nvim> |
| **copilot.lua** | The better github.com/github/copilot.vim | <https://github.com/zbirenbaum/copilot.lua> |
| **copilot-cmp** | transforms zbirenbaum/copilot.lua into a cmp source. | <https://github.com/zbirenbaum/copilot-cmp> |
| **nvim-lint** | Narrow-scope linter plugin to use via Neovim diagnostic framework | <https://github.com/mfussenegger/nvim-lint> |
| **snipe.nvim** | Buffer navigation | <https://github.com/leath-dub/snipe.nvim> |
| **blink.cmp** | Fuzzy code completion | <https://github.com/Saghen/blink.cmp> |
| **diffview.nvim** | Git diff viewer/stager | <https://github.com/sindrets/diffview.nvim> |
## Looks

View file

@ -1,5 +0,0 @@
-- Disable column width indicators in quickfix/Trouble windows
-- vim.opt.colorcolumn = ""
vim.opt.colorcolumn = ""
vim.opt_local.colorcolumn = ""
vim.wo.colorcolumn = "0"

View file

@ -1,5 +0,0 @@
-- Disable column width indicators in quickfix/Trouble windows
-- vim.opt.colorcolumn = ""
vim.opt.colorcolumn = ""
vim.opt_local.colorcolumn = ""
vim.wo.colorcolumn = "0"

View file

@ -1,12 +1,17 @@
--[[
My simple(TM) Neovim configuration. Made from scratch, inspired by
https://www.youtube.com/watch?v=w7i4amO_zaE
Later on, switched to native LSP setup with the help of
https://gpanders.com/blog/whats-new-in-neovim-0-11/
NOTE: EXTERNAL DEPENDENCIES MACOS
- ripgrep (https://github.com/BurntSushi/ripgrep, used by telescope)
- fd (https://github.com/sharkdp/fd, used by telescope)
- A Nerd font (https://www.nerdfonts.com/, used by various plugins)
NOTE: EXTERNAL DEPENDENCIES FREEBSD
- cmake, ripgrep (pkg install <pkgname>)
NOTE: EXTERNAL DEPENDENCIES WINDOWS
See https://blog.nikfp.com/how-to-install-and-set-up-neovim-on-windows
- ripgrep (https://github.com/BurntSushi/ripgrep, used by telescope)
@ -20,5 +25,5 @@ Then run "make" in your users telescope-fzf-native plugin directory:
C:\Users\foobar\AppData\Local\nvim-data\lazy\telescope-fzf-native.nvim
--]]
-- Include customized configuration
-- Include my custom configuration
require("weeheavy")

View file

@ -1,39 +1,30 @@
{
"LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" },
"auto-dark-mode.nvim": { "branch": "master", "commit": "02ef9553e2a1d6e861bc6955d58ce5883d28a6ad" },
"cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
"conform.nvim": { "branch": "master", "commit": "80b57f662b5e13ae8c2c7c38639966084625fa5e" },
"copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" },
"copilot.lua": { "branch": "master", "commit": "886ee73b6d464b2b3e3e6a7ff55ce87feac423a9" },
"blink.cmp": { "branch": "main", "commit": "49f211fe5d729df53df4c042d7c3464cf47d199e" },
"ccc.nvim": { "branch": "main", "commit": "9abb22d5d47460852a935129b4feff39fd8033e3" },
"conform.nvim": { "branch": "master", "commit": "a6f5bdb78caa305496357d17e962bbc4c0b392e2" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"flash.nvim": { "branch": "main", "commit": "f899265876ecdcf7352dbc9f0adf87068cedefbb" },
"gitsigns.nvim": { "branch": "main", "commit": "9772ce68a9a6d156f3f2166bfd0a17a09ab37eba" },
"lazy.nvim": { "branch": "main", "commit": "f15a93907ddad3d9139aea465ae18336d87f5ce6" },
"lsp-zero.nvim": { "branch": "v4.x", "commit": "baff1ca10ecad7efe04f02f06d2647dd2ae90074" },
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" },
"mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" },
"mini.nvim": { "branch": "main", "commit": "87fc38a8a2b8d498cecb021d057a38ea2e9f5a79" },
"flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" },
"friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" },
"gitsigns.nvim": { "branch": "main", "commit": "3c76f7fabac723aa682365ef782f88a83ccdb4ac" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lualine.nvim": { "branch": "master", "commit": "1517caa8fff05e4b4999857319d3b0609a7f57fa" },
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
"mini.nvim": { "branch": "main", "commit": "687fa868d869078194c02065628712982d971fd6" },
"newpaper.nvim": { "branch": "main", "commit": "d8f2a29001f795a59e4f28713427c200c15449ea" },
"nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
"nvim-lint": { "branch": "master", "commit": "789b7ada1b4f00e08d026dffde410dcfa6a0ba87" },
"nvim-lspconfig": { "branch": "master", "commit": "00dae9f5f4ad215d4561f2fd2f26478c48b0ca7f" },
"nvim-treesitter": { "branch": "master", "commit": "cced713b4993ddbfba8f82e9e60fcab7cbee8101" },
"nvim-treesitter-context": { "branch": "master", "commit": "9a49f43a2ec9bf77aecfb0fcbc43af43338375c0" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" },
"nvim-web-devicons": { "branch": "master", "commit": "402377242b04be3f4f0f3720bd952df86e946c30" },
"oil.nvim": { "branch": "master", "commit": "add50252b5e9147c0a09d36480d418c7e2737472" },
"plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" },
"rose-pine": { "branch": "main", "commit": "20c7940da844aa4f162a64e552ae3c7e9fdc3b93" },
"smear-cursor.nvim": { "branch": "main", "commit": "110f7d8771fff9dde6b2aa7e20c29bae8bb4d834" },
"snipe.nvim": { "branch": "main", "commit": "0d0a482ac713370196e4fc0025d5aaac5030104d" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" },
"nvim-lint": { "branch": "master", "commit": "81e8ba7655cc4395b1092ef4e1b6e83f54cd54ad" },
"nvim-treesitter": { "branch": "master", "commit": "997288c55253e27f782d991099490f80205d65bf" },
"nvim-treesitter-context": { "branch": "master", "commit": "93b29a32d5f4be10e39226c6b796f28d68a8b483" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "9937e5e356e5b227ec56d83d0a9d0a0f6bc9cad4" },
"nvim-web-devicons": { "branch": "master", "commit": "4c3a5848ee0b09ecdea73adcd2a689190aeb728c" },
"oil.nvim": { "branch": "master", "commit": "302bbaceeafc690e6419e0c8296e804d60cb9446" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"rose-pine": { "branch": "main", "commit": "96ff3993a67356ee85d1cdab9be652cdc1c5d1ac" },
"snipe.nvim": { "branch": "main", "commit": "f43a1f0090de03d48ce5c55df630c1aa4d0b4291" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
"tokyonight.nvim": { "branch": "main", "commit": "b262293ef481b0d1f7a14c708ea7ca649672e200" },
"trouble.nvim": { "branch": "main", "commit": "6f380b8826fb819c752c8fd7daaee9ef96d4c689" },
"twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" },
"vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
"which-key.nvim": { "branch": "main", "commit": "0e76a87ac51772569aec678dc74baa8e2a86100c" },
"zen-mode.nvim": { "branch": "main", "commit": "863f150ca321b3dd8aa1a2b69b5f411a220e144f" }
"trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" },
"vim-illuminate": { "branch": "master", "commit": "19cb21f513fc2b02f0c66be70107741e837516a1" },
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
}

28
lsp/ansible.lua Normal file
View file

@ -0,0 +1,28 @@
---@type vim.lsp.Config
--- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/ansiblels.lua
--- https://github.com/neovim/nvim-lspconfig/pull/3659/files#diff-5ecad9b03732db4dfd97f3aa9874fa465b88ee4e121bf152e670f46e4f19cc6e
return {
cmd = { "ansible-language-server", "--stdio" },
settings = {
ansible = {
python = {
interpreterPath = "python",
},
ansible = {
path = "ansible",
},
executionEnvironment = {
enabled = false,
},
validation = {
enabled = true,
lint = {
enabled = true,
path = "ansible-lint",
},
},
},
},
filetypes = { "yaml.ansible" },
root_markers = { "ansible.cfg", ".ansible-lint" },
}

6
lsp/go.lua Normal file
View file

@ -0,0 +1,6 @@
---@type vim.lsp.Config
return {
cmd = { "gopls" },
root_markers = { "go.work", "go.mod", ".git" },
filetypes = { "go", "gomod", "gowork", "gotmpl" },
}

14
lsp/lua.lua Normal file
View file

@ -0,0 +1,14 @@
---@type vim.lsp.Config
return {
cmd = { "lua-language-server" },
filetypes = { "lua" },
root_markers = { ".luarc.json", ".luarc.jsonc" },
telemetry = { enabled = false },
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
},
},
}

6
lsp/marksman.lua Normal file
View file

@ -0,0 +1,6 @@
---@type vim.lsp.Config
return {
cmd = { "marksman" },
root_markers = { ".md" },
filetypes = { "markdown" },
}

34
lsp/tailwind.lua Normal file
View file

@ -0,0 +1,34 @@
---@type vim.lsp.Config
return {
cmd = { "tailwindcss-language-server", "--stdio" },
root_markers = { "tailwind.config.js" },
filetypes = { "javascript", "htmldjango", "css" },
settings = {
tailwindCSS = {
validate = true,
lint = {
cssConflict = "warning",
invalidApply = "error",
invalidScreen = "error",
invalidVariant = "error",
invalidConfigPath = "error",
invalidTailwindDirective = "error",
recommendedVariantOrder = "warning",
},
classAttributes = {
"class",
"className",
"class:list",
"classList",
"ngClass",
},
includeLanguages = {
eelixir = "html-eex",
eruby = "erb",
templ = "html",
htmlangular = "html",
htmldjango = "html",
},
},
},
}

6
lsp/terraform.lua Normal file
View file

@ -0,0 +1,6 @@
---@type vim.lsp.Config
return {
cmd = { "terraform-ls", "serve" },
root_markers = { ".terraform", ".terraform.lock.hcl", ".git" },
filetypes = { "terraform" },
}

5
lsp/yaml.lua Normal file
View file

@ -0,0 +1,5 @@
---@type vim.lsp.Config
return {
filetypes = { "yaml" },
cmd = { "yaml-language-server", "--stdio" },
}

View file

@ -1,23 +1,60 @@
-- Highlight yanked text on e.g. yy,yap etc.
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup("weeheavy-highlight-yank", { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
-- Native autocompletion
-- vim.api.nvim_create_autocmd("LspAttach", {
-- callback = function(ev)
-- local client = vim.lsp.get_client_by_id(ev.data.client_id)
-- if client:supports_method("textDocument/completion") then
-- vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
-- end
-- end,
-- })
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("my.lsp", {}),
callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
if client:supports_method("textDocument/implementation") then
-- Create a keymap for vim.lsp.buf.implementation ...
end
-- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y|
if client:supports_method("textDocument/completion") then
-- Optional: trigger autocompletion on EVERY keypress. May be slow!
-- local chars = {}
-- for i = 32, 126 do
-- table.insert(chars, string.char(i))
-- end
-- client.server_capabilities.completionProvider.triggerCharacters = chars
-- vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
end
-- Auto-format ("lint") on save.
-- Usually not needed if server supports "textDocument/willSaveWaitUntil".
if
not client:supports_method("textDocument/willSaveWaitUntil")
and client:supports_method("textDocument/formatting")
then
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("my.lsp", { clear = false }),
buffer = args.buf,
callback = function()
vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 })
end,
})
end
end,
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "trouble",
callback = function()
vim.opt.colorcolumn = ""
end,
-- Highlight yanked text on e.g. yy,yap etc.
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking (copying) text",
group = vim.api.nvim_create_augroup("weeheavy-highlight-yank", { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})
-- https://github.com/LazyVim/LazyVim/discussions/654
vim.api.nvim_create_autocmd("FileType", {
pattern = "terraform",
callback = function()
vim.bo.commentstring = "# %s"
end,
pattern = "terraform",
callback = function()
vim.bo.commentstring = "# %s"
end,
})

View file

@ -1,22 +0,0 @@
-- https://github.com/f-person/auto-dark-mode.nvim
return {
"f-person/auto-dark-mode.nvim",
opts = {
-- in ms. needs to be larger than whatever time your system takes to
-- query dark mode. Otherwise you risk freezing neovim on shutdown
update_interval = 4000,
set_dark_mode = function()
vim.api.nvim_set_option_value("background", "dark", {})
vim.cmd("colorscheme rose-pine-moon")
end,
set_light_mode = function()
vim.api.nvim_set_option_value("background", "light", {})
vim.cmd("colorscheme rose-pine-dawn")
end,
fallback = "light",
},
-- config = function()
-- local darkmode = require("auto-dark-mode")
-- darkmode.setup({})
-- end,
}

View file

@ -0,0 +1,20 @@
-- File system operations for nerds
-- https://github.com/uga-rosa/ccc.nvim
return {
"uga-rosa/ccc.nvim",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
config = function()
local ccc = require("ccc")
local mapping = ccc.mapping
ccc.setup({
-- Your preferred settings
-- Example: enable highlighter
highlighter = {
auto_enable = true,
lsp = true,
},
})
end,
}

View file

@ -1,55 +0,0 @@
-- Fully featured & enhanced replacement for copilot.vim complete with API for
-- interacting with Github Copilot
-- https://github.com/zbirenbaum/copilot.lua
return {
"zbirenbaum/copilot.lua",
lazy = true,
enabled = false,
event = "InsertEnter",
config = function()
local copilot = require("copilot")
copilot.setup({
panel = {
enabled = false,
auto_refresh = false,
keymap = {
jump_prev = "[[",
jump_next = "]]",
accept = "<CR>",
refresh = "gr",
open = "<M-CR>",
},
layout = {
position = "bottom", -- | top | left | right
ratio = 0.4,
},
},
suggestion = {
enabled = false,
auto_trigger = false,
debounce = 75,
keymap = {
accept = "<M-l>",
accept_word = false,
accept_line = false,
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
filetypes = {
yaml = true,
markdown = false,
help = false,
gitcommit = false,
gitrebase = false,
hgcommit = false,
svn = false,
cvs = false,
["."] = false,
},
copilot_node_command = "node", -- Node.js version must be > 18.x
server_opts_overrides = {},
})
end,
}

View file

@ -1,43 +1,22 @@
-- Adds git related signs to the gutter, as well as utilities for managing changes
return {
"lewis6991/gitsigns.nvim",
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = "+" },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
},
on_attach = function(bufnr)
--vim.keymap.set(
-- "n",
-- "<leader>ggh",
-- require("gitsigns").preview_hunk,
-- { buffer = bufnr, desc = "Preview git hunk" }
--)
-- don't override the built-in and fugitive keymaps
local gs = package.loaded.gitsigns
vim.keymap.set({ "n", "v" }, "]c", function()
if vim.wo.diff then
return "]c"
end
vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" })
vim.keymap.set({ "n", "v" }, "[c", function()
if vim.wo.diff then
return "[c"
end
vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" })
end,
},
"lewis6991/gitsigns.nvim",
opts = {
-- See `:help gitsigns.txt`
signs = {
add = { text = "+" },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
},
on_attach = function(bufnr)
vim.keymap.set(
"n",
"<leader>gg",
require("gitsigns").preview_hunk,
{ buffer = bufnr, desc = "Preview git hunk" }
)
end,
},
}

View file

@ -1,17 +0,0 @@
return {
"lukas-reineke/indent-blankline.nvim",
enabled = false,
lazy = true,
event = { "BufReadPre", "BufNewFile" },
main = "ibl",
opts = {},
config = function()
local indent = require("ibl").setup({
-- disable scope highlighting as it requires some tuning
scope = { enabled = false },
indent = {
char = "",
},
})
end,
}

View file

@ -0,0 +1,61 @@
return {
"saghen/blink.cmp",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
-- optional: provides snippets for the snippet source
dependencies = { "rafamadriz/friendly-snippets" },
-- use a release tag to download pre-built binaries
version = "1.*",
-- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
-- build = 'cargo build --release',
-- If you use nix, you can build from source using latest nightly rust with:
-- build = 'nix run .#build-plugin',
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
-- 'default' (recommended) for mappings similar to built-in completions (C-y to accept)
-- 'super-tab' for mappings similar to vscode (tab to accept)
-- 'enter' for enter to accept
-- 'none' for no mappings
--
-- All presets have the following mappings:
-- C-space: Open menu or open docs if already open
-- C-n/C-p or Up/Down: Select next/previous item
-- C-e: Hide menu
-- C-k: Toggle signature help (if signature.enabled = true)
--
-- See :h blink-cmp-config-keymap for defining your own keymap
keymap = {
preset = "enter",
["<C-k>"] = { "select_prev", "fallback" },
["<C-j>"] = { "select_next", "fallback" },
["<Tab>"] = { "accept", "fallback" },
["<C-c>"] = { "cancel", "fallback" },
},
appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = "mono",
},
-- (Default) Only show the documentation popup when manually triggered
completion = { documentation = { auto_show = true } },
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = { "lsp", "path", "snippets", "buffer" },
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance
-- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation,
-- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"`
--
-- See the fuzzy documentation for more information
fuzzy = { implementation = "prefer_rust_with_warning" },
},
opts_extend = { "sources.default" },
}

View file

@ -1,13 +1,13 @@
-- Some things are from https://www.josean.com/posts/neovim-linting-and-formatting
return {
"stevearc/conform.nvim",
enabled = true,
tag = "stable",
opts = {},
config = function()
local conform = require("conform")
conform.setup({
-- formatters_by_ft = {
formatters = {
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
@ -22,6 +22,8 @@ return {
lua = { "stylua" },
python = { "isort", "black" },
sh = { "shfmt" },
terraform = { "tflint" },
hcl = { "hclfmt" },
},
stop_after_first = false,
format_on_save = {

View file

@ -1,10 +0,0 @@
-- transforms https://github.com/zbirenbaum/copilot.lua into a cmp source.
-- https://github.com/zbirenbaum/copilot-cmp
return {
"zbirenbaum/copilot-cmp",
lazy = false,
--event = "InsertEnter",
config = function()
require("copilot_cmp").setup()
end,
}

View file

@ -1,170 +0,0 @@
return {
{
"VonHeikemen/lsp-zero.nvim",
branch = "v4.x",
lazy = true,
config = false,
init = function()
-- Disable automatic setup, we are doing it manually
vim.g.lsp_zero_extend_cmp = 0
vim.g.lsp_zero_extend_lspconfig = 0
end,
},
{
"williamboman/mason.nvim",
tag = "stable",
lazy = false,
config = true,
},
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
{ "L3MON4D3/LuaSnip" },
},
config = function()
-- Here is where you configure the autocompletion settings.
local lsp_zero = require("lsp-zero")
lsp_zero.extend_cmp()
local cmp = require("cmp")
local cmp_action = lsp_zero.cmp_action()
local cmp_select = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
formatting = lsp_zero.cmp_format(),
sources = {
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "buffer" },
{ name = "copilot" },
{ name = "luasnip" },
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-l>"] = cmp.mapping.confirm({ select = true }), -- accept LSP autocompletion
["<C-k>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-j>"] = cmp.mapping.select_next_item(cmp_select),
["<C-f>"] = cmp_action.luasnip_jump_forward(),
["<C-b>"] = cmp_action.luasnip_jump_backward(),
}),
window = {
documentation = {
border = { "", "", "", "", "", "", "", "" },
},
completion = {
border = { "", "", "", "", "", "", "", "" },
},
},
})
end,
},
-- LSP
{
"neovim/nvim-lspconfig",
cmd = { "LspInfo", "LspInstall", "LspStart" },
event = { "BufReadPre", "BufNewFile" },
dependencies = {
{ "hrsh7th/cmp-nvim-lsp" },
{ "williamboman/mason-lspconfig.nvim", tag = "stable" },
},
config = function()
local signs = { Error = "󰅚 ", Warn = "󰀪 ", Hint = "󰌶 ", 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.diagnostic.config({
update_in_insert = true,
signs = true,
virtual_text = {
prefix = "", -- Could be '●', '▎', 'x'
source = "if_many",
},
float = {
source = "if_many",
},
})
-- This is where all the LSP shenanigans will live
local lsp_zero = require("lsp-zero")
-- Keybindings only active when a LS is active for the curr. file
-- lsp_zero.on_attach(function(client, bufnr)
local lsp_attach = function(client, bufnr)
-- see :help lsp-zero-keybindings to learn the available actions
-- or https://lsp-zero.netlify.app/docs/language-server-configuration.html#default-keymaps
-- https://www.reddit.com/r/neovim/comments/1ankiu1/lsp_zero_go_to_definition_stopped_working/
lsp_zero.default_keymaps({ buffer = bufnr, preserve_mappings = false })
end
lsp_zero.extend_lspconfig({
sign_text = true,
lsp_attach = lsp_attach,
capabilities = require("cmp_nvim_lsp").default_capabilities(),
})
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
})
require("mason-lspconfig").setup({
ensure_installed = {
"bashls",
"jsonls",
"lua_ls",
"vimls",
"yamlls",
},
handlers = {
-- names must align with Mason names
lsp_zero.default_setup,
lua_ls = function()
local lua_opts = lsp_zero.nvim_lua_ls()
require("lspconfig").lua_ls.setup(lua_opts)
require("lspconfig").gopls.setup({})
require("lspconfig").yamlls.setup({
settings = {
yaml = {
-- https://www.arthurkoziel.com/json-schemas-in-neovim/
schemaStore = {
enable = false,
url = "",
},
schemas = {
["https://raw.githubusercontent.com/awslabs/goformation/master/schema/cloudformation.schema.json"] = "cf-*{yml,yaml}",
-- ["https://json.schemastore.org/kustomization.json"] = "kustomization.{yml,yaml}",
-- ["https://raw.githubusercontent.com/docker/compose/master/compose/config/compose_spec.json"] = "docker-compose*.{yml,yaml}",
-- ["https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json"] = "argocd-application.yaml",
},
},
},
})
require("lspconfig").taplo.setup({
-- Taplo loads all schemas (not selectively)
settings = {
evenBetterToml = {
-- https://www.arthurkoziel.com/json-schemas-in-neovim/
schema = {
-- additional schemas
-- associations = {
-- ["alacritty\\.toml$"] = "https://raw.githubusercontent.com/distinction-dev/alacritty-schema/main/alacritty/reference.json",
-- },
},
},
},
})
end,
},
})
end,
},
}

View file

@ -0,0 +1,6 @@
return {
"williamboman/mason.nvim",
tag = "stable",
lazy = false,
config = true,
}

View file

@ -1,20 +1,21 @@
-- status line like vim-airline
-- Display attached LSP client
local function lsp_clients()
local clients = vim.lsp.get_active_clients()
local client_names = {}
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
local function lsp_client_name()
local bufnr = vim.api.nvim_get_current_buf()
-- local clients = vim.lsp.buf_get_clients(bufnr)
local clients = vim.lsp.get_clients({ bufnr = 0 })
if next(clients) == nil then
return "n/a"
end
if next(client_names) == nil then
return "no LS"
local c = {}
for _, client in pairs(clients) do
table.insert(c, client.name)
-- table.insert(c, string.sub(client.name, 0, 8) .. "...")
end
--return "[" .. table.concat(client_names, ", ") .. "]"
return "\u{f085} " .. table.concat(c, ",")
end
-- hide content on narrow windows
@ -69,8 +70,8 @@ return {
-- specify full list of elements when adding custom things
{ "encoding", cond = hide_in_width },
{ "fileformat" },
{ "filetype" },
{ lsp_clients, cond = hide_in_width },
{ "filetype", cond = hide_in_width },
{ lsp_client_name, cond = hide_in_width },
--{ clock, cond = hide_in_width },
},
},

View file

@ -1,23 +0,0 @@
return {
"sphamba/smear-cursor.nvim",
opts = {
-- Smear cursor when switching buffers or windows.
smear_between_buffers = true,
-- Smear cursor when moving within line or to neighbor lines.
-- Use `min_horizontal_distance_smear` and `min_vertical_distance_smear` for finer control
smear_between_neighbor_lines = true,
-- Draw the smear in buffer space instead of screen space when scrolling
scroll_buffer_space = true,
-- Set to `true` if your font supports legacy computing symbols (block unicode symbols).
-- Smears will blend better on all backgrounds.
legacy_computing_symbols_support = false,
-- Smear cursor in insert mode.
-- See also `vertical_bar_cursor_insert_mode` and `distance_stop_animating_vertical_bar`.
smear_insert_mode = true,
},
}

View file

@ -22,13 +22,18 @@ return {
},
ui = {
position = "topright",
-- position = "cursor",
open_win_override = {
-- title = "i can haz file?",
border = "rounded",
},
preselect_current = true,
},
navigate = {
cancel_snipe = "q",
-- Close the buffer under the cursor
-- PR not merged yet: https://github.com/leath-dub/snipe.nvim/pull/13
-- NOTE: Make sure you don't use the character below on your dictionary
close_buffer = "d",
open_vsplit = "V",
open_split = "X",
},
})
end,

View file

@ -1,9 +1,20 @@
return {
"rose-pine/neovim",
name = "rose-pine",
branch = "main",
lazy = false,
enabled = true,
priority = 1000,
opts = {},
"rose-pine/neovim",
name = "rose-pine",
branch = "main",
lazy = false,
enabled = true,
priority = 1000,
opts = {
styles = {
-- transparency = true,
},
config = function()
local rose = require("rose-pine")
rose.setup({
variant = "auto", -- auto, main, moon, or dawn
dark_variant = "moon", -- main, moon, or dawn
})
end,
},
}

View file

@ -1,65 +1,65 @@
return {
"folke/tokyonight.nvim",
tag = "stable",
lazy = false,
enabled = true,
priority = 1000,
opts = {},
config = function()
local tokyonight = require("tokyonight")
local util = require("tokyonight.util")
tokyonight.setup({
styles = {
-- See :help nvim_set_hl
comments = { italic = true },
--functions = { underdotted = true },
},
on_colors = function(colors)
-- Brighten up comments a bit
colors.comment = "#888fac"
-- Better visible visual selection background color
--colors.bg_visual = "#e82a86"
--colors.bg_visual = colors.teal
end,
on_highlights = function(hl, c)
-- Brighter line numbers
hl.LineNr = {
fg = util.darken(c.dark5, 0.6),
}
--hl.ColorColumn = {
-- bg = c.purple,
--}
"folke/tokyonight.nvim",
tag = "stable",
lazy = false,
enabled = false,
priority = 1000,
opts = {},
config = function()
local tokyonight = require("tokyonight")
local util = require("tokyonight.util")
tokyonight.setup({
styles = {
-- See :help nvim_set_hl
comments = { italic = true },
--functions = { underdotted = true },
},
on_colors = function(colors)
-- Brighten up comments a bit
colors.comment = "#888fac"
-- Better visible visual selection background color
--colors.bg_visual = "#e82a86"
--colors.bg_visual = colors.teal
end,
on_highlights = function(hl, c)
-- Brighter line numbers
hl.LineNr = {
fg = util.darken(c.dark5, 0.6),
}
--hl.ColorColumn = {
-- bg = c.purple,
--}
-- Remove borders from Telescope windows
local prompt = "#2d3149"
hl.TelescopeNormal = {
bg = c.bg_dark,
fg = c.fg_dark,
}
hl.TelescopeBorder = {
bg = c.bg_dark,
fg = c.bg_dark,
}
hl.TelescopePromptNormal = {
bg = prompt,
}
hl.TelescopePromptBorder = {
bg = prompt,
fg = prompt,
}
hl.TelescopePromptTitle = {
bg = prompt,
fg = prompt,
}
hl.TelescopePreviewTitle = {
bg = c.bg_dark,
fg = c.bg_dark,
}
hl.TelescopeResultsTitle = {
bg = c.bg_dark,
fg = c.bg_dark,
}
end,
})
end,
-- Remove borders from Telescope windows
local prompt = "#2d3149"
hl.TelescopeNormal = {
bg = c.bg_dark,
fg = c.fg_dark,
}
hl.TelescopeBorder = {
bg = c.bg_dark,
fg = c.bg_dark,
}
hl.TelescopePromptNormal = {
bg = prompt,
}
hl.TelescopePromptBorder = {
bg = prompt,
fg = prompt,
}
hl.TelescopePromptTitle = {
bg = prompt,
fg = prompt,
}
hl.TelescopePreviewTitle = {
bg = c.bg_dark,
fg = c.bg_dark,
}
hl.TelescopeResultsTitle = {
bg = c.bg_dark,
fg = c.bg_dark,
}
end,
})
end,
}

View file

@ -48,6 +48,9 @@ return {
"editorconfig",
"http",
"make",
"toml",
"latex",
"sql",
},
incremental_selection = {
enable = true,

View file

@ -12,5 +12,9 @@ return {
desc = "Diagnostics (Trouble)",
},
},
opts = {},
opts = {
open_no_results = true,
auto_close = true,
indent_guides = false,
},
}

View file

@ -1,57 +0,0 @@
-- Distraction-free coding when you need it
-- https://github.com/folke/zen-mode.nvim
return {
"folke/zen-mode.nvim",
dependencies = {
"folke/twilight.nvim",
opts = {
treesitter = true,
context = 2,
},
},
event = { "BufReadPre", "BufNewFile" },
opts = {
window = {
backdrop = 0.95, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
width = 0.75, -- width of the Zen window
height = 1, -- height of the Zen window
-- by default, no options are changed for the Zen window
-- uncomment any of the options below, or add other vim.wo options you want to apply
options = {
signcolumn = "no", -- disable signcolumn
number = false, -- disable number column
relativenumber = false, -- disable relative numbers
cursorline = false, -- disable cursorline
cursorcolumn = false, -- disable cursor column
foldcolumn = "0", -- disable fold column
list = false, -- disable whitespace characters
colorcolumn = "0", -- disable line width indicator
},
},
plugins = {
-- disable some global vim options (vim.o...)
-- comment the lines to not apply the options
options = {
enabled = true,
ruler = false, -- disables the ruler text in the cmd line area
showcmd = false, -- disables the command in the last line of the screen
-- you may turn on/off statusline in zen mode by setting 'laststatus'
-- statusline will be shown only if 'laststatus' == 3
laststatus = 0, -- turn off the statusline in zen mode
},
twilight = { enabled = true }, -- enable to start Twilight when zen mode opens
gitsigns = { enabled = false }, -- disables git signs
-- this will change the font size on alacritty when in zen mode
-- requires Alacritty Version 0.10.0 or higher
-- uses `alacritty msg` subcommand to change font size
alacritty = {
enabled = true,
font = "20", -- font size
},
},
-- callback where you can add custom code when the Zen window opens
on_open = function(win) end,
-- callback where you can add custom code when the Zen window closes
on_close = function() end,
},
}

View file

@ -1,3 +1,14 @@
-- LSP activation (references lsp/<filename>
vim.lsp.enable({
"lua",
"go",
"terraform",
"yaml",
"ansible",
"marksman",
"tailwind",
})
-- Set highlight on search
vim.opt.hlsearch = true
@ -48,15 +59,14 @@ vim.opt.cursorline = true
vim.opt.wrap = false
vim.opt.termguicolors = true
vim.opt.background = "dark" -- light, dark
-- vim.opt.background = "dark" -- light, dark
-- Themes:
-- tokyonight-night
-- tokyonight-storm
-- tokyonight-day
-- tokyonight-moon
-- vim.cmd.colorscheme("tokyonight-storm")
vim.cmd.colorscheme("rose-pine-dawn")
-- vim.cmd.colorscheme("newpaper")
vim.cmd.colorscheme("rose-pine")
-- Decrease update time
vim.opt.updatetime = 250
@ -77,12 +87,38 @@ vim.opt.showmode = false
-- Hobo way to to force ansiblels being used for Ansible files
vim.filetype.add({
pattern = {
[".*/.*playbook.*.ya?ml"] = "yaml.ansible",
[".*/.*tasks.*/.*ya?ml"] = "yaml.ansible",
[".*/.*group_vars.*/.*ya?ml"] = "yaml.ansible",
[".*/.*host_vars.*/.*ya?ml"] = "yaml.ansible",
[".*/local.ya?ml"] = "yaml.ansible",
[".*-ansible/.*ya?ml"] = "yaml.ansible",
},
pattern = {
[".*/.*playbook.*.ya?ml"] = "yaml.ansible",
[".*/.*tasks.*/.*ya?ml"] = "yaml.ansible",
[".*/.*group_vars.*/.*ya?ml"] = "yaml.ansible",
[".*/.*host_vars.*/.*ya?ml"] = "yaml.ansible",
[".*/local.ya?ml"] = "yaml.ansible",
[".*-ansible/.*ya?ml"] = "yaml.ansible",
},
})
-- rounded borders
vim.opt.winborder = "rounded"
-- Inline hints
vim.diagnostic.config({
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "󰅚",
[vim.diagnostic.severity.WARN] = "󰀪",
[vim.diagnostic.severity.HINT] = "󰌶",
[vim.diagnostic.severity.INFO] = "",
},
-- linehl = {
-- [vim.diagnostic.severity.ERROR] = "Error",
-- [vim.diagnostic.severity.WARN] = "Warn",
-- [vim.diagnostic.severity.INFO] = "Info",
-- [vim.diagnostic.severity.HINT] = "Hint",
-- },
},
virtual_text = true,
virtual_lines = false,
-- virtual_lines = {
-- current_line = true,
-- },
})

View file

@ -1,11 +1,8 @@
-- keyboard shortcuts
-- Leader key set to space, base for any key combo
-- vim.g.mapleader = " "
-- Leader key. Base for any key combo
vim.g.mapleader = ";"
--vim.keymap.set("n", "<leader>r", vim.cmd.Ex, { noremap = true, desc = "netrw File Browser" }) -- netrw file explorer
--vim.keymap.set("n", "<leader>e", "<cmd>lua require('oil').toggle_float('.')<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<leader>e", ":Oil --float<CR>", { desc = "Oil" })
-- List recently opened files
@ -13,56 +10,45 @@ vim.keymap.set("n", "<leader>fo", ":Telescope oldfiles<CR>", { noremap = true, d
-- Find files
vim.keymap.set(
"n",
"<leader>ff",
":Telescope find_files hidden=true no_ignore=false<CR>",
{ noremap = true, desc = "File search" }
"n",
"<leader>ff",
":Telescope find_files hidden=true no_ignore=false<CR>",
{ noremap = true, desc = "File search" }
)
-- Live find string (using ripgrep)
vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<CR>", { noremap = true, desc = "Search string" })
vim.keymap.set("n", "<leader>fg", ":Telescope live_grep<CR>", { noremap = true, desc = "String search" })
-- Find string under cursor (using ripgrep)
vim.keymap.set(
"n",
"<leader>fs",
":Telescope grep_string<CR>",
{ noremap = true, desc = "Search text under cursor in cwd/grep search string" }
"n",
"<leader>fs",
":Telescope grep_string<CR>",
{ noremap = true, desc = "Search text under cursor in cwd/grep search string" }
)
-- Find string under cursor
--vim.keymap.set(
-- "n",
-- "<leader>fs",
-- [[<cmd>lua require('telescope.builtin').grep_string()<cr>]],
-- { silent = true, noremap = true }
--)
vim.keymap.set("n", "<leader><leader>", ":Telescope buffers<CR>", { noremap = true, desc = "Show open buffers" })
-- todo-comments.nvim
vim.keymap.set("n", "<leader>ft", ":TodoTelescope<CR>", { noremap = true, desc = "Find TODOs" })
--vim.keymap.set("n", "<leader>gs", ":Telescope git_status<CR>", { noremap = true, desc = "Git status" })
vim.keymap.set(
"n",
"<leader>gla",
":Telescope git_commits<CR>",
{ noremap = true, desc = "Git log (across all files)" }
"n",
"<leader>gla",
":Telescope git_commits<CR>",
{ noremap = true, desc = "Git log (across all files)" }
)
vim.keymap.set("n", "<leader>glf", ":Telescope git_bcommits<CR>", { noremap = true, desc = "Git log (this file)" })
--vim.keymap.set("n", "<leader>gdp", ":Gitsigns diffthis<CR>", { noremap = true, desc = "Git diff previous (this file)" })
--vim.keymap.set("n", "<leader>gd", ":Gitsigns diffthis<CR>", { noremap = true, desc = "Git diff previous (this file)" })
vim.keymap.set("n", "<leader>gd", function()
if next(require("diffview.lib").views) == nil then
vim.cmd("DiffviewOpen")
else
vim.cmd("DiffviewClose")
end
--end, { noremap = true, desc = "Diff this shit" })
if next(require("diffview.lib").views) == nil then
vim.cmd("DiffviewOpen")
else
vim.cmd("DiffviewClose")
end
end, { noremap = true, desc = "Toggle diff/stage UI " })
vim.keymap.set(
"n",
"<leader>gb",
":Gitsigns toggle_current_line_blame<CR>",
{ noremap = true, desc = "Toggle git blame" }
"n",
"<leader>gb",
":Gitsigns toggle_current_line_blame<CR>",
{ noremap = true, desc = "Toggle git blame" }
)
-- Remapping of existing Vim key binds
@ -72,59 +58,59 @@ vim.keymap.set("n", "b", "B") -- skip punctuation when moving to end of previous
--vim.keymap.set("n", "<leader>i", "gg=G``", { noremap = true, desc = "Re-indent whole file" }) -- '``' makes it stay at current line+column position
-- Thank you @ThePrimeagen for those
-- https://github.com/ThePrimeagen/init.lua/blob/master/lua/theprimeagen/remap.lua
-- Thanks https://github.com/ThePrimeagen/init.lua/blob/master/lua/theprimeagen/remap.lua
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") -- move whole lines/blocks down in visual mode
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv") -- move whole lines/blocks up in visual mode
vim.keymap.set("n", "<C-d>", "<C-d>zz") -- eye-friendly down scrolling
vim.keymap.set("n", "<C-u>", "<C-u>zz") -- eye-friendly up scrolling
vim.keymap.set("n", "J", "mzJ`z") -- when merging lines, keep cursor at current position
vim.keymap.set("n", "<C-d>", "<C-d>zz") -- eye-friendly down scrolling
vim.keymap.set("n", "<C-u>", "<C-u>zz") -- eye-friendly up scrolling
vim.keymap.set("n", "J", "mzJ`z") -- when merging lines, keep cursor at current position
vim.keymap.set(
"n",
"<leader>s",
[[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
{ noremap = true, desc = "Replace word below cursor" }
"n",
"<leader>s",
[[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
{ noremap = true, desc = "Replace word below cursor" }
)
-- Apply conform.nvim formatting on keypress (same as on save)
vim.keymap.set({ "n", "v" }, "<leader>o", function()
local conform = require("conform")
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 500,
})
local conform = require("conform")
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 500,
})
end, { desc = "Format file or range (in visual mode)" })
-- Toggle zen-mode.nvim
vim.keymap.set("n", "<leader>z", ":ZenMode<CR>")
-- Go to next diagnostic item (any severity)
vim.keymap.set({ "n", "v" }, "<leader>da", function()
vim.diagnostic.goto_next({})
vim.api.nvim_feedkeys("zz", "n", false)
vim.diagnostic.get_next({})
vim.api.nvim_feedkeys("zz", "n", false)
end, { desc = "Go to next diagnostic" })
-- Go to next diagnostic item (error severity)
vim.keymap.set({ "n", "v" }, "<leader>de", function()
vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR })
vim.api.nvim_feedkeys("zz", "n", false)
vim.diagnostic.get_next({ severity = vim.diagnostic.severity.ERROR })
vim.api.nvim_feedkeys("zz", "n", false)
end, { desc = "Go to next error diagnostic" })
-- Go to next diagnostic item (warning severity)
vim.keymap.set({ "n", "v" }, "<leader>dw", function()
vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.WARN })
vim.api.nvim_feedkeys("zz", "n", false)
vim.diagnostic.get_next({ severity = vim.diagnostic.severity.WARN })
vim.api.nvim_feedkeys("zz", "n", false)
end, { desc = "Go to next warning diagnostic" })
-- Toggle LSP diagnostics
vim.keymap.set({ "n", "v" }, "<leader>dd", function()
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
end, { desc = "Turn diagnostics on/off" })
-- Toggle trouble (for document)
--vim.keymap.set("n", "<leader>qq", ":TroubleToggle<CR>")
--vim.keymap.set("n", "<leader>qq", "<cmd>Trouble diagnostics toggle<cr>")
-- By default, show virtual_text and hide virtual_lines.
-- This keymap allows to do the opposite. Can be useful when there are multiple
-- severities on the same line
vim.keymap.set("n", "<leader>tdd", function()
vim.diagnostic.config({
virtual_lines = not vim.diagnostic.config().virtual_lines,
virtual_text = not vim.diagnostic.config().virtual_text,
})
end, { desc = "Toggle diagnostic virtual lines and virtual text" })