Added LaTeX templates and more

This commit is contained in:
Kristofers Solo
2023-09-01 01:01:16 +03:00
parent 5f9133e67d
commit 39d3cbc3cf
53 changed files with 3175 additions and 611 deletions

1
after/ftplugin/lua.lua Normal file
View File

@@ -0,0 +1 @@
vim.opt_local.expandtab = false

View File

@@ -0,0 +1,2 @@
vim.opt_local.wrap = true
vim.opt_local.spell = true

3
after/ftplugin/sql.lua Normal file
View File

@@ -0,0 +1,3 @@
vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2
vim.opt_local.softtabstop = 2

2
after/ftplugin/tex.lua Normal file
View File

@@ -0,0 +1,2 @@
vim.opt_local.wrap = true
vim.opt_local.spell = true

View File

@@ -0,0 +1,5 @@
vim.opt_local.wrap = true
vim.opt_local.spell = true
vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2
vim.opt_local.softtabstop = 2

View File

@@ -5,34 +5,6 @@ end
local dap = require("dap")
local dapui = require("dapui")
vim.keymap.set("n", "<leader>dd", function()
dap.toggle_breakpoint()
end)
vim.keymap.set("n", "<leader>dc", function()
dap.continue()
end)
vim.keymap.set("n", "<leader>di", function()
dap.step_into()
end)
vim.keymap.set("n", "<leader>dp", function()
dap.step_over()
end)
vim.keymap.set("n", "<leader>dO", function()
dap.step_out()
end)
vim.keymap.set("n", "<leader>dI", function()
dap.repl.open()
end)
vim.keymap.set("n", "<leader>dk", function()
dap.terminate()
end)
vim.keymap.set("n", "<leader>dl", function()
dap.run_last()
end)
vim.keymap.set("n", "<leader>du", function()
dapui.toggle()
end)
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DiagnosticSignError", linehl = "", numhl = "" })
dap.listeners.after.event_initialized["dapui_config"] = function()
@@ -47,40 +19,39 @@ dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
local mason_registry = require("mason-registry")
vim.keymap.set("n", "<F5>", dap.continue)
vim.keymap.set("n", "<F10>", dap.step_over)
vim.keymap.set("n", "<F11>", dap.step_into)
vim.keymap.set("n", "<F12>", dap.step_out)
dapui.setup()
require("nvim-dap-virtual-text").setup({})
-- Python
dap.adapters.python = {
type = "executable",
command = vim.fn.stdpath("data") .. "/mason/bin/debugpy-adapter",
}
dap.configurations.python = {
{
-- The first three options are required by nvim-dap
type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python`
request = "launch",
name = "Launch file",
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
local debugpy = mason_registry.get_package("debugpy")
local debugpy_path = debugpy:get_install_path() .. "/venv/bin/python"
require("dap-python").setup(debugpy_path)
program = "${file}", -- This configuration will launch the current file if used.
pythonPath = function()
-- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
-- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
-- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
return cwd .. "/venv/bin/python"
elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
return cwd .. "/.venv/bin/python"
else
return "/usr/bin/python"
end
end,
local codelldb = mason_registry.get_package("codelldb")
local codelldb_path = codelldb:get_install_path() .. "/codelldb"
local liblldb_path = codelldb:get_install_path() .. "/extension/lldb/lib/liblldb.so"
-- Rust
require("rust-tools").setup({
dap = {
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
},
}
})
-- C/C++/Rust
-- dap.configurations.rust = {}
-- C/C++
-- FIX: not working
dap.adapters.lldb = {
type = "executable",
command = vim.fn.stdpath("data") .. "/mason/packages/codelldb/codelldb", -- adjust as needed, must be absolute path
command = codelldb_path,
name = "lldb",
}
dap.configurations.cpp = {
@@ -112,61 +83,3 @@ dap.configurations.cpp = {
-- If you want to use this for Rust and C, add something like this:
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
-- JavaScript
dap.adapters.firefox = {
type = "executable",
command = "node",
args = { vim.fn.stdpath("data") .. "/mason/packages/firefox-debug-adapter/dist/adapter.bundle.js" },
}
dap.configurations.typescript = {
{
name = "Debug with Librewolf",
type = "firefox",
request = "launch",
reAttach = true,
url = "http://localhost:3000",
webRoot = "${workspaceFolder}",
firefoxExecutable = "/usr/bin/librewolf",
},
}
dap.configurations.javascript = {
{
name = "Debug with Librewolf",
type = "firefox",
request = "launch",
reAttach = true,
url = "http://localhost:3000",
webRoot = "${workspaceFolder}",
firefoxExecutable = "/usr/bin/librewolf",
},
}
-- Bash
dap.adapters.bashdb = {
type = "executable",
command = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/bash-debug-adapter",
name = "bashdb",
}
dap.configurations.sh = {
{
type = "bashdb",
request = "launch",
name = "Launch file",
showDebugOutput = true,
pathBashdb = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb",
pathBashdbLib = vim.fn.stdpath("data") .. "/mason/packages/bash-debug-adapter/extension/bashdb_dir",
trace = true,
file = "${file}",
program = "${file}",
cwd = "${workspaceFolder}",
pathCat = "bat",
pathBash = "/bin/zash",
pathMkfifo = "mkfifo",
pathPkill = "pkill",
args = {},
env = {},
terminalKind = "integrated",
},
}

View File

@@ -1,15 +1,10 @@
vim.keymap.set("n", "<leader>wc", function()
require("telescope").extensions.git_worktree.git_worktrees()
end)
if not pcall(require, "git-worktree") then
return
end
vim.keymap.set("n", "<leader>wn", function()
require("telescope").extensions.git_worktree.create_git_worktree()
end)
local Worktree = require("git-worktree")
Worktree.on_tree_change(function(op, metadata)
if op == Worktree.Operations.Switch then
local worktree = require("git-worktree")
worktree.on_tree_change(function(op, metadata)
if op == worktree.Operations.Switch then
print("Switched from " .. metadata.prev_path .. " to " .. metadata.path)
end
end)

View File

@@ -2,10 +2,6 @@ if not pcall(require, "gitsigns") then
return
end
vim.keymap.set("n", "<leader>gb", function()
vim.cmd.Gitsigns("blame_line")
end)
require("gitsigns").setup({
signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },

View File

@@ -2,10 +2,7 @@ if not pcall(require, "harpoon") then
return
end
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<F1>", function()
ui.nav_file(1)

View File

@@ -49,6 +49,9 @@ require("illuminate").configure({
-- min_count_to_highlight: minimum number of matches required to perform highlighting
min_count_to_highlight = 1,
})
local bind = vim.keymap.set
bind("n", "<A-n>", "<cmd>lua require('illuminate').goto_next_reference(wrap)<cr>", { noremap = true })
bind("n", "<A-p>", "<cmd>lua require('illuminate').goto_prev_reference(wrap)<cr>", { noremap = true })
vim.keymap.set("n", "<A-n>", function()
require("illuminate").goto_next_reference()
end, { noremap = true })
vim.keymap.set("n", "<A-p>", function()
require("illuminate").goto_prev_reference()
end, { noremap = true })

View File

@@ -1 +0,0 @@
vim.keymap.set("n", "<leader>gg", vim.cmd.LazyGit)

View File

@@ -9,7 +9,7 @@ local lsp = require("lsp-zero").preset({
setup_servers_on_start = true,
set_lsp_keymaps = {
preserve_mappings = false,
omit = { "<F2>", "<F3>", "<F4>" },
omit = { "<F1>", "<F2>", "<F3>", "<F4>", "<F5>" },
},
manage_nvim_cmp = {
set_sources = "recommended",
@@ -21,27 +21,25 @@ local lsp = require("lsp-zero").preset({
},
})
lsp.on_attach(function(client, bufnr)
lsp.on_attach(function(_, bufnr)
-- see :help lsp-zero-keybindings
-- to learn the available actions
lsp.default_keymaps({ buffer = bufnr })
local opts = { buffer = bufnr }
vim.keymap.set("n", "gd", function()
vim.lsp.buf.definition()
end, opts)
vim.keymap.set("n", "gD", function()
vim.lsp.buf.declaration()
end, opts)
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover()
end, opts)
vim.keymap.set("n", "gi", function()
vim.lsp.buf.implementation()
end, opts)
vim.keymap.set("n", "gr", "<cmd>lua require('telescope.builtin').lsp_references()<cr>", opts)
vim.keymap.set("n", "gl", function()
vim.diagnostic.open_float()
end, opts)
-- lsp.default_keymaps({ buffer = bufnr })
local nmap = function(keys, func, desc)
if desc then
desc = "LSP: " .. desc
end
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end
nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
nmap("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation")
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
end)
lsp.ensure_installed({
@@ -54,7 +52,6 @@ lsp.ensure_installed({
"jedi_language_server",
"jsonls",
"lua_ls",
"ruff_lsp",
"sqlls",
"tailwindcss",
"taplo",
@@ -122,6 +119,7 @@ lsp.configure("texlab", {
},
})
require("neodev").setup()
require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls({
settings = {
Lua = {
@@ -187,7 +185,9 @@ null_ls.setup({
"strict",
},
}),
-- formatting.remark.with({ extra_filetypes = { "vimwiki" } }), -- FIX: indentation level
formatting.markdownlint.with({
extra_filetypes = { "vimwiki" },
}),
formatting.markdown_toc.with({ extra_filetypes = { "vimwiki" } }),
-- formatting.shellharden.with({ extra_filetypes = { "bash", "csh", "ksh", "zsh" } }),
-- formatting.shfmt.with({ extra_filetypes = { "bash", "csh", "ksh", "zsh" } }),
@@ -198,24 +198,21 @@ null_ls.setup({
-- https://github.com/jay-babu/mason-null-ls.nvim#setup
require("mason-null-ls").setup({
ensure_installed = {
"cmake_lint",
"codespell",
"cpplint",
"luacheck",
"misspell",
"mypy",
"black",
"cbfmt",
"clang_format",
"cmake_format",
"cmake_lint",
"cpplint",
"djlint",
"google_java_format",
"phpcbf",
"prettier",
"remark",
"luacheck",
"markdown_toc",
"mypy",
"stylua",
"usort",
"yamlfmt",
"rustywind",
},
automatic_installation = true,
handlers = {

View File

@@ -4,25 +4,9 @@ end
require("lualine").setup({
options = {
icons_enabled = true,
theme = "auto",
component_separators = { left = "|", right = "|" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = { "dashboard" },
winbar = {},
},
ignore_focus = {},
always_divide_middle = false,
globalstatus = true,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
--[[ Available components
`branch` (git branch)
`buffers` (shows currently available buffers)
`diagnostics` (diagnostics count from your preferred source)
@@ -48,14 +32,4 @@ require("lualine").setup({
lualine_y = { "progress" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
extensions = {},
})

View File

@@ -17,11 +17,11 @@ require("obsidian").setup({
["gf"] = require("obsidian.mapping").gf_passthrough(),
},
templates = {
subdir = "university/templates",
date_format = "%Y.%m.%d",
time_format = "%H:%M:%S",
},
-- templates = {
-- subdir = "university/templates",
-- date_format = "%Y.%m.%d",
-- time_format = "%H:%M:%S",
-- },
backlinks = {
height = 10,

View File

@@ -4,12 +4,6 @@ end
require("rust-tools").setup({
tools = {
-- how to execute terminal commands
-- options right now: termopen / quickfix
-- executor = require("rust-tools.executors").termopen,
-- callback to execute once rust-analyzer is done initializing the workspace
-- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error"
on_initialized = function()
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave", "BufWritePost" }, {
group = vim.api.nvim_create_augroup("InitializeRustAnalyzer", { clear = true }),
@@ -19,152 +13,18 @@ require("rust-tools").setup({
end,
})
end,
-- automatically call RustReloadWorkspace when writing to a Cargo.toml file.
reload_workspace_from_cargo_toml = true,
-- These apply to the default RustSetInlayHints command
inlay_hints = {
-- automatically set inlay hints (type hints)
-- default: true
auto = true,
-- Only show inlay hints for the current line
only_current_line = false,
-- whether to show parameter hints with the inlay hints or not
-- default: true
show_parameter_hints = true,
-- prefix for parameter hints
-- default: "<-"
parameter_hints_prefix = " <- ",
-- prefix for all the other hints (type, chaining)
-- default: "=>"
other_hints_prefix = " => ",
-- whether to align to the length of the longest line in the file
max_len_align = false,
-- padding from the left if max_len_align is true
max_len_align_padding = 1,
-- whether to align to the extreme right or not
right_align = false,
-- padding from the right if right_align is true
right_align_padding = 7,
-- The color of the hints
highlight = "Comment",
},
-- options same as lsp hover / vim.lsp.util.open_floating_preview()
hover_actions = {
-- the border that is used for the hover window
-- see vim.api.nvim_open_win()
border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
},
-- Maximal width of the hover window. Nil means no max.
max_width = nil,
-- Maximal height of the hover window. Nil means no max.
max_height = nil,
-- whether the hover action window gets automatically focused
-- default: false
auto_focus = false,
},
-- settings for showing the crate graph based on graphviz and the dot
-- command
crate_graph = {
-- Backend used for displaying the graph
-- see: https://graphviz.org/docs/outputs/
-- default: x11
backend = "x11",
-- where to store the output, nil for no output stored (relative
-- path from pwd)
-- default: nil
output = nil,
-- true for all crates.io and external crates, false only the local
-- crates
-- default: true
full = true,
-- List of backends found on: https://graphviz.org/docs/outputs/
-- Is used for input validation and autocompletion
-- Last updated: 2021-08-26
enabled_graphviz_backends = {
"bmp",
"cgimage",
"canon",
"dot",
"gv",
"xdot",
"xdot1.2",
"xdot1.4",
"eps",
"exr",
"fig",
"gd",
"gd2",
"gif",
"gtk",
"ico",
"cmap",
"ismap",
"imap",
"cmapx",
"imap_np",
"cmapx_np",
"jpg",
"jpeg",
"jpe",
"jp2",
"json",
"json0",
"dot_json",
"xdot_json",
"pdf",
"pic",
"pct",
"pict",
"plain",
"plain-ext",
"png",
"pov",
"ps",
"ps2",
"psd",
"sgi",
"svg",
"svgz",
"tga",
"tiff",
"tif",
"tk",
"vml",
"vmlz",
"wbmp",
"webp",
"xlib",
"x11",
},
},
-- all the opts to send to nvim-lspconfig
-- these override the defaults set by rust-tools.nvim
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
server = {
-- standalone file support
-- setting it to false may improve startup time
standalone = true,
}, -- rust-analyzer options
-- debugging stuff
dap = {
adapter = {
type = "executable",
command = "codelldb",
name = "rt_lldb",
},
},
},
})

View File

@@ -1 +0,0 @@
vim.keymap.set("n", "<leader>t", vim.cmd.TagbarToggle)

View File

@@ -3,15 +3,8 @@ if not pcall(require, "telescope") then
end
local builtin = require("telescope.builtin")
local themes = require("telescope.themes")
vim.keymap.set("n", "<leader>f", function()
builtin.find_files(themes.get_dropdown({ previewer = false }))
end, {})
vim.keymap.set("n", "<C-p>", builtin.git_files, {})
vim.keymap.set("n", "<leader>t", "<cmd>Telescope live_grep<cr>")
vim.keymap.set("n", "<leader>qf", "<cmd>Telescope quickfix<cr>")
vim.keymap.set("n", "<leader>d", "<cmd>Telescope diagnostics<cr>")
local telescope = require("telescope")
local actions = require("telescope.actions")
@@ -91,10 +84,11 @@ telescope.setup({
},
},
})
telescope.load_extension("fzf")
telescope.load_extension("media_files")
telescope.load_extension("emoji")
telescope.load_extension("ui-select")
telescope.load_extension("color_names")
telescope.load_extension("git_worktree")
telescope.load_extension("lazygit")
pcall(telescope.load_extension, "fzf")
pcall(telescope.load_extension, "media_files")
pcall(telescope.load_extension, "emoji")
pcall(telescope.load_extension, "ui-select")
pcall(telescope.load_extension, "color_names")
pcall(telescope.load_extension, "git_worktree")
pcall(telescope.load_extension, "lazygit")
pcall(telescope.load_extension, "dap")

View File

@@ -1,26 +1,45 @@
if not pcall(require, "nvim-treesitter") then
return
end
vim.keymap.set("n", "[d", function()
vim.diagnostic.goto_next()
vim.cmd("norm zz")
end, { desc = "Goto next diagnostic" })
vim.keymap.set("n", "]d", function()
vim.diagnostic.goto_prev()
vim.cmd("norm zz")
end, { desc = "Goto prev diagnostic" })
require("nvim-treesitter.configs").setup({
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "cpp", "lua", "rust", "python", "markdown", "markdown_inline" }, -- one of "all" or a list of languages
ensure_installed = { "cpp", "lua", "rust", "python", "markdown" }, -- one of "all" or a list of languages
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
-- List of parsers to ignore installing (for "all")
-- ignore_install = { "" },
ignore_install = { "latex" },
modules = {},
highlight = {
enable = true,
disable = {},
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = { "markdown" },
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
},
indent = {
enable = true,
},
autopairs = {
enable = true,
@@ -47,7 +66,15 @@ require("nvim-treesitter.configs").setup({
"hbs",
},
},
indent = { enable = true, disable = { "" } },
-- incremenral_selection = {
-- enable = true,
-- keymaps = {
-- init_selection = "<C-space>",
-- node_selection = "<C-space>",
-- scope_selection = "<C-space>",
-- node_deselection = "<C-backspace>",
-- },
-- },
rainbow = {
enable = true,
-- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for

View File

@@ -1 +0,0 @@
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)

321
after/plugin/whichkey.lua Normal file
View File

@@ -0,0 +1,321 @@
if not pcall(require, "which-key") then
return
end
local which_key = require("which-key")
local builtin = require("telescope.builtin")
local setup = {
plugins = {
marks = true, -- shows a list of your marks on " and `
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
spelling = {
enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions
suggestions = 20, -- how many suggestions should be shown in the list?
},
-- the presets plugin, adds help for a bunch of default keybindings in Neovim
-- No actual key bindings are created
presets = {
operators = false, -- adds help for operators like d, y, ... and registers them for motion / text object completion
motions = true, -- adds help for motions
text_objects = true, -- help for text objects triggered after entering an operator
windows = true, -- default bindings on <c-w>
nav = true, -- misc bindings to work with windows
z = true, -- bindings for folds, spelling and others prefixed with z
g = true, -- bindings for prefixed with g
},
},
-- add operators that will trigger motion and text object completion
-- to enable all native operators, set the preset / operators plugin above
-- operators = { gc = "Comments" },
key_labels = {
-- override the label used to display some keys. It doesn"t effect WK in any other way.
-- For example:
-- ["<space>"] = "SPC",
-- ["<cr>"] = "RET",
-- ["<tab>"] = "TAB",
},
icons = {
breadcrumb = "»", -- symbol used in the command line area that shows your active key combo
separator = "", -- symbol used between a key and it"s label
group = "+", -- symbol prepended to a group
},
popup_mappings = {
scroll_down = "<c-d>", -- binding to scroll down inside the popup
scroll_up = "<c-u>", -- binding to scroll up inside the popup
},
window = {
border = "rounded", -- none, single, double, shadow
position = "bottom", -- bottom, top
margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]
padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left]
winblend = 0,
},
layout = {
height = { min = 4, max = 25 }, -- min and max height of the columns
width = { min = 20, max = 50 }, -- min and max width of the columns
spacing = 3, -- spacing between columns
align = "left", -- align columns left, center or right
},
ignore_missing = true, -- enable this to hide mappings for which you didn"t specify a label
hidden = { "<silent>", "<cmd>", "<Cmd>", "<cr>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
show_help = true, -- show help message on the command line when the popup is visible
triggers = "auto", -- automatically setup triggers
-- triggers = {"<leader>"} -- or specify a list manually
triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey
-- this is mostly relevant for key maps that start with a native binding
-- most people should not need to change this
i = { "j", "k" },
v = { "j", "k" },
},
}
local opts = {
mode = "n", -- NORMAL mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = true, -- use `nowait` when creating keymaps
}
local vopts = {
mode = "v", -- VISUAL mode
prefix = "<leader>",
buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings
silent = true, -- use `silent` when creating keymaps
noremap = true, -- use `noremap` when creating keymaps
nowait = true, -- use `nowait` when creating keymaps
}
-- NOTE: Prefer using : over <cmd> as the latter avoids going back in normal-mode.
-- see https://neovim.io/doc/user/map.html#:map-cmd
local vmappings = {}
local mappings = {
c = { vim.cmd.bdelete, "[C]lose Buffer" },
x = { "<cmd>!chmod +x %<cr>", "chmod & run" },
mr = { "<cmd>CellularAutomaton make_it_rain<cr>", "[M]ake it [R]ain" },
u = { vim.cmd.UndotreeToggle, "Toggle [U]ndoTree" },
b = { vim.cmd.TagbarToggle, "Toggle Tag[B]ar" },
e = { vim.cmd.Ex, "Open [E]xplorer" },
["/"] = {
function()
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ previewer = false }))
end,
"Current Buffer Fuzzy",
},
f = {
name = "[F]ind",
f = {
function()
builtin.find_files(require("telescope.themes").get_dropdown({ previewer = false }))
end,
"[F]iles",
},
t = { builtin.live_grep, "[T]ext" },
b = { builtin.buffers, "[B]uffers" },
},
h = {
name = "[H]arpoon",
a = { require("harpoon.mark").add_file, "[A]dd File" },
m = { require("harpoon.ui").toggle_quick_menu, "[M]enu" },
},
t = {
name = "[T]elescope",
d = { builtin.diagnostic, "[D]iagnostics" },
b = { builtin.git_branches, "Checkout [B]ranch" },
h = { builtin.help_tags, "Find [H]elp" },
H = { builtin.highlights, "Find [H]ighlight Groups" },
M = { builtin.man_pages, "[M]an Pages" },
r = { builtin.oldfiles, "Open [R]ecent Files" },
R = { builtin.registers, "[R]egisters" },
g = { builtin.live_grep, "Live [G]rep" },
k = { builtin.keymaps, "[K]eymaps" },
C = { builtin.commands, "[C]ommands" },
t = { vim.cmd.TodoTelescope, "[T]odo" },
m = { require("telescope").extensions.media_files.media_files, "[M]edia" },
c = {
function()
builtin.colorscheme({ enable_preview = true })
end,
"[C]olorscheme with Preview",
},
},
g = {
name = "[G]it",
g = { vim.cmd.LazyGit, "Lazygit" },
b = {
function()
vim.cmd.Gitsigns("blame_line")
end,
"[B]lame",
},
c = { require("telescope").extensions.git_worktree.git_worktrees, "[C]hange Worktree" },
n = { require("telescope").extensions.git_worktree.create_git_worktree, "Create [N]ew Worktree" },
},
l = {
name = "[L]SP",
ca = { vim.lsp.buf.code_action, "[C]ode [A]ction" },
D = { vim.lsp.buf.type_definition, "Type [D]efinitions" },
f = {
function()
vim.lsp.buf.format({ async = true })
end,
"[F]ormat",
},
o = { vim.diagnostic.open_float, "[O]pen Float" },
s = { vim.diagnostic.setloclist, "[S]etloclist" },
j = {
function()
vim.diagnostic.goto_next()
vim.cmd("norm zz")
end,
"Next Diagnostic",
},
k = {
function()
vim.diagnostic.goto_prev()
vim.cmd("norm zz")
end,
"Prev Diagnostic",
},
r = { vim.lsp.buf.rename, "[R]ename" },
ds = { builtin.lsp_document_symbols, "[D]ocument [S]ymbols" },
w = {
d = { builtin.diagnostics, "[W]orkspace [D]iagnostics" },
s = { builtin.lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols" },
a = { vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder" },
r = { vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder" },
l = {
function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end,
"[W]orkspace [L]ist Folder",
},
},
q = { builtin.quickfix, "Telescope [Q]uickfix" },
},
r = {
name = "[R]ust",
e = { vim.cmd.RustExpandMacro, "[E]xpand macro" },
c = { vim.cmd.RustOpenCargo, "Open [C]argo.toml" },
p = { vim.cmd.RustParentModule, "[P]arent module" },
h = { vim.cmd.RustHoverActions, "[H]over actions" },
g = { vim.cmd.RustViewCrateGraph, "View Create [G]raph" },
d = { vim.cmd.RustOpenExternalDocs, "Open External [D]ocs" },
r = { vim.cmd.RustRunnables, "Open [R]unnables" },
ca = { vim.cmd.RustCodeAction, "[C]ode [A]ction Groups" },
},
L = {
name = "[L]anguage settings",
c = { "<cmd>setlocal formatoptions-=cro<cr>", "Disable autocomment" },
C = { "<cmd>setlocal formatoptions=cro<cr>", "Enable autocomment" },
s = { "<cmd>setlocal spell!<cr>", "Toggle spellchecker" },
e = { "<cmd>setlocal spell spelllang=en_us<cr>", "Enable English spellchecker" },
l = { "<cmd>setlocal spell spelllang=lv_LV<cr>", "Enable Lavian spellchecker" },
I = { "<cmd>setlocal autoindent<cr>", "Enable autoindent" },
i = { "<cmd>setlocal noautoindent<cr>", "Disable autoindent" },
},
d = {
name = "[D]AP",
d = { require("dap").toggle_breakpoint, "Set breakpoint" },
D = {
function()
require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))
end,
"Set Breakpoint with Condition",
},
p = {
name = "[P]ython",
m = { require("dap-python").test_method, "Test [M]ethod" },
c = { require("dap-python").test_class, "Test [C]lass" },
s = { require("dap-python").debug_selection, "Debug [S]election" },
},
r = {
name = "[R]ust",
d = { vim.cmd.RustDebuggables, "[D]ebug" },
},
t = { require("dapui").toggle, "[T]oggle DAP-UI" },
c = { require("dap").continue, "Launch Debug Sessions and Resume Execution" },
i = { require("dap").step_into, "Step [I]nto Code" },
o = { require("dap").step_over, "Step [O]ver Code" },
O = { require("dap").step_out, "Step [O]ut of Code" },
T = { require("dap").terminate, "[T]erminate" },
l = { require("dap").run_last, "Run [L]ast" },
h = { require("dap.ui.widgets").hover, "[H]over" },
P = { require("dap.ui.widgets").preview, "[P]review" },
f = {
function()
local widgets = require("dap.ui.widgets")
widgets.centered_float(widgets.frames)
end,
"[F]rames",
},
s = {
function()
local widgets = require("dap.ui.widgets")
widgets.centered_float(widgets.scopes)
end,
"[S]copes",
},
},
w = {
name = "Vim[W]iki",
w = { vim.cmd.VimwikiIndex, "Open index file" },
t = { vim.cmd.VimwikiTabIndex, "Open Index File in New [T]ab" },
s = { vim.cmd.VimwikiUISelect, "Display List of Wikis" },
i = { vim.cmd.VimwikiDiaryIndex, "Open Diary Index" },
h = { vim.cmd.Vimwiki2HTML, "Convert File to HTML" },
H = { vim.cmd.Vimwiki2HTMLBrowse, "Convert File to HTML and open in Browser" },
n = { vim.cmd.VimwikiGoto, "Goto link provided by an argument" },
d = { vim.cmd.VimwikiDeleteFile, "Rename file" },
r = { vim.cmd.VimwikiRenameFile, "Delete file" },
},
v = {
name = "[V]imTex",
b = { vim.cmd.VimtexCompile, "[B]uild" },
v = { vim.cmd.VimtexView, "[V]iew" },
w = { vim.cmd.VimtexCountWords, "[W]ord Count" },
t = { vim.cmd.VimtexTocToggle, "[T]able of Contents" },
c = { vim.cmd.VimtexClean, "[C]lean aux" },
e = { vim.cmd.VimtexErrors, "Report [E]rrors" },
i = { vim.cmd.VimtexInfo, "[I]nfo" },
},
T = {
name = "[T]emplates",
p = {
"<cmd>read ~/.config/nvim/templates/PhilPaper.tex<cr>",
"PhilPaper.tex",
},
l = {
"<cmd>read ~/.config/nvim/templates/Letter.tex<cr>",
"Letter.tex",
},
g = {
"<cmd>read ~/.config/nvim/templates/Glossary.tex<cr>",
"Glossary.tex",
},
h = {
"<cmd>read ~/.config/nvim/templates/HandOut.tex<cr>",
"HandOut.tex",
},
b = {
"<cmd>read ~/.config/nvim/templates/PhilBeamer.tex<cr>",
"PhilBeamer.tex",
},
s = {
"<cmd>read ~/.config/nvim/templates/SubFile.tex<cr>",
"SubFile.tex",
},
r = {
"<cmd>read ~/.config/nvim/templates/Root.tex<cr>",
"Root.tex",
},
m = {
"<cmd>read ~/.config/nvim/templates/MultipleAnswer.tex<cr>",
"MultipleAnswer.tex",
},
},
}
which_key.setup(setup)
which_key.register(mappings, opts, vopts, vmappings)