add config folder
This commit is contained in:
10
.config/nvim/after/plugin/colors.lua
Normal file
10
.config/nvim/after/plugin/colors.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
function ColorMyNVim(color)
|
||||
color = color or "gruvbox"
|
||||
vim.cmd.colorscheme(color)
|
||||
|
||||
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||||
|
||||
end
|
||||
|
||||
ColorMyNVim()
|
||||
8
.config/nvim/after/plugin/comment.lua
Normal file
8
.config/nvim/after/plugin/comment.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
require("ts_context_commentstring").setup({
|
||||
enable_autocmd = false,
|
||||
})
|
||||
require('Comment').setup({
|
||||
ignore = '^$', -- Ignore empty lines
|
||||
pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(),
|
||||
})
|
||||
|
||||
1
.config/nvim/after/plugin/fugitive.lua
Normal file
1
.config/nvim/after/plugin/fugitive.lua
Normal file
@@ -0,0 +1 @@
|
||||
vim.keymap.set("n", "<leader>gs", vim.cmd.Git)
|
||||
3
.config/nvim/after/plugin/gitgutter.lua
Normal file
3
.config/nvim/after/plugin/gitgutter.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
vim.keymap.set("n", "<leader>hs", "<cmd>GitGutterStageHunk<cr>")
|
||||
vim.keymap.set("n", "<leader>hu", "<cmd>GitGutterUndoHunk<cr>")
|
||||
vim.keymap.set("n", "<leader>hp", "<cmd>GitGutterPreviewHunk<cr>")
|
||||
10
.config/nvim/after/plugin/harpoon.lua
Normal file
10
.config/nvim/after/plugin/harpoon.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
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", "<C-a>", function() ui.nav_file(1) end)
|
||||
vim.keymap.set("n", "<C-z>", function() ui.nav_file(2) end)
|
||||
vim.keymap.set("n", "<C-q>", function() ui.nav_file(3) end)
|
||||
vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end)
|
||||
14
.config/nvim/after/plugin/indent-blankline.lua
Normal file
14
.config/nvim/after/plugin/indent-blankline.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
vim.api.nvim_set_hl(0, "IndentBlanklineContextChar", { fg = "#d79921", bg = "none"})
|
||||
|
||||
require("ibl").setup({
|
||||
indent = { char = " "},
|
||||
whitespace = { },
|
||||
scope = { char = "▎",
|
||||
highlight = "IndentBlanklineContextChar",
|
||||
show_start = false,
|
||||
show_end = false,
|
||||
include = { node_type = { python = { "if_statement",
|
||||
"for_statement",
|
||||
"with_statement", } } },
|
||||
},
|
||||
})
|
||||
156
.config/nvim/after/plugin/lsp.lua
Normal file
156
.config/nvim/after/plugin/lsp.lua
Normal file
@@ -0,0 +1,156 @@
|
||||
local map_lsp_keybinds = require('config.remap').map_lsp_keybinds -- Has to load keymaps before pluginslsp
|
||||
|
||||
-- Use neodev to configure lua_ls in nvim directories - must load before lspconfig
|
||||
require("neodev").setup()
|
||||
|
||||
require("fidget").setup({
|
||||
notification = {
|
||||
redirect = -- Conditionally redirect notifications to another backend
|
||||
function(msg, level, opts)
|
||||
if opts and opts.on_open then
|
||||
return require("fidget.integration.nvim-notify").delegate(msg, level, opts)
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = {'bashls', 'clangd', 'fortls', 'julials', 'marksman', 'pylsp', 'rust_analyzer', 'texlab'},
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
||||
|
||||
local servers = {
|
||||
bashls = {},
|
||||
clangd = {},
|
||||
fortls = {},
|
||||
julials = {},
|
||||
marksman = {},
|
||||
pylsp = {
|
||||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
pycodestyle = {
|
||||
ignore = {},
|
||||
maxLineLength = 160,
|
||||
},
|
||||
ruff = {
|
||||
enabled = true, -- Enable the plugin
|
||||
executable = "<path-to-ruff-bin>", -- Custom path to ruff
|
||||
config = "<path_to_custom_ruff_toml>", -- Custom config for ruff to use
|
||||
extendSelect = { "I" }, -- Rules that are additionally used by ruff
|
||||
extendIgnore = { "C90" }, -- Rules that are additionally ignored by ruff
|
||||
format = { "I" }, -- Rules that are marked as fixable by ruff that should be fixed when running textDocument/formatting
|
||||
severities = { ["D212"] = "I" }, -- Optional table of rules where a custom severity is desired
|
||||
unsafeFixes = false, -- Whether or not to offer unsafe fixes as code actions. Ignored with the "Fix All" action
|
||||
|
||||
-- Rules that are ignored when a pyproject.toml or ruff.toml is present:
|
||||
lineLength = 80, -- Line length to pass to ruff checking and formatting
|
||||
exclude = { "__about__.py" }, -- Files to be excluded by ruff checking
|
||||
select = { "F" }, -- Rules to be enabled by ruff
|
||||
ignore = { "D210" }, -- Rules to be ignored by ruff
|
||||
perFileIgnores = { ["__init__.py"] = "CPY001" }, -- Rules that should be ignored for specific files
|
||||
preview = false, -- Whether to enable the preview style linting and formatting.
|
||||
targetVersion = "py310", -- The minimum python version to target (applies for both linting and formatting).
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
rust_analyzer = {},
|
||||
texlab = {},
|
||||
}
|
||||
|
||||
-- Default handlers for LSP
|
||||
local default_handlers = {
|
||||
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }),
|
||||
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" }),
|
||||
}
|
||||
|
||||
-- this is the function that loads the extra snippets to luasnip
|
||||
-- from rafamadriz/friendly-snippets
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
|
||||
cmp.setup({
|
||||
-- No preselection
|
||||
preselect = 'None',
|
||||
|
||||
sources = {
|
||||
{name = 'nvim_lsp'}, -- lsp
|
||||
{name = 'buffer', max_item_count = 5}, -- Text within current buffer
|
||||
{name = 'luasnip', max_item_count = 3}, -- Snippets
|
||||
{name = 'path', max_item_count = 3}, -- File system paths
|
||||
},
|
||||
|
||||
formatting = {
|
||||
expandable_indicator = true,
|
||||
},
|
||||
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
}),
|
||||
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
local ls = require("luasnip")
|
||||
if not ls then
|
||||
return
|
||||
end
|
||||
ls.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
-- nvim-cmp supports additional completion capabilities
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
local default_capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||
|
||||
local on_attach = function(_client, buffer_number)
|
||||
-- Pass the current buffer to map lsp keybinds
|
||||
map_lsp_keybinds(buffer_number)
|
||||
|
||||
-- Create a command `:Format` local to the LSP buffer
|
||||
vim.api.nvim_buf_create_user_command(buffer_number, "Format", function(_)
|
||||
vim.lsp.buf.format({
|
||||
filter = function(format_client)
|
||||
-- Use Prettier to format TS/JS if it's available
|
||||
return format_client.name ~= "tsserver" or not null_ls.is_registered("prettier")
|
||||
end,
|
||||
})
|
||||
end, { desc = "LSP: Format current buffer with LSP" })
|
||||
end
|
||||
|
||||
-- Iterate over our servers and set them up
|
||||
for name, config in pairs(servers) do
|
||||
require("lspconfig")[name].setup({
|
||||
capabilities = default_capabilities,
|
||||
filetypes = config.filetypes,
|
||||
handlers = vim.tbl_deep_extend("force", {}, default_handlers, config.handlers or {}),
|
||||
on_attach = on_attach,
|
||||
settings = config.settings,
|
||||
})
|
||||
end
|
||||
|
||||
vim.diagnostic.config({
|
||||
-- update_in_insert = true,
|
||||
virtual_text = true,
|
||||
underline = false,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
6
.config/nvim/after/plugin/telescope.lua
Normal file
6
.config/nvim/after/plugin/telescope.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local builtin = require('telescope.builtin')
|
||||
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
|
||||
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
|
||||
vim.keymap.set('n', '<leader>ps', function()
|
||||
builtin.grep_string({ search = vim.fn.input("Grep > ") });
|
||||
end)
|
||||
56
.config/nvim/after/plugin/treesitter.lua
Normal file
56
.config/nvim/after/plugin/treesitter.lua
Normal file
@@ -0,0 +1,56 @@
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the five listed parsers should always be installed)
|
||||
ensure_installed = { "bash", "c", "cpp", "cuda", "latex", "lua", "markdown", "rust", "vim", "vimdoc" },
|
||||
|
||||
-- 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,
|
||||
|
||||
---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
|
||||
-- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
||||
-- 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 = false,
|
||||
},
|
||||
}
|
||||
local vim = vim
|
||||
local opt = vim.opt
|
||||
local api = vim.api
|
||||
local M = {}
|
||||
|
||||
opt.foldmethod = "expr"
|
||||
opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
|
||||
-- function to create a list of commands and convert them to autocommands
|
||||
-------- This function is taken from https://github.com/norcalli/nvim_utils
|
||||
function M.nvim_create_augroups(definitions)
|
||||
for group_name, definition in pairs(definitions) do
|
||||
api.nvim_command('augroup '..group_name)
|
||||
api.nvim_command('autocmd!')
|
||||
for _, def in ipairs(definition) do
|
||||
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
|
||||
api.nvim_command(command)
|
||||
end
|
||||
api.nvim_command('augroup END')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local autoCommands = {
|
||||
-- other autocommands
|
||||
open_folds = {
|
||||
{"BufReadPost,FileReadPost", "*", "normal zR"}
|
||||
}
|
||||
}
|
||||
|
||||
M.nvim_create_augroups(autoCommands)
|
||||
|
||||
1
.config/nvim/after/plugin/undotree.lua
Normal file
1
.config/nvim/after/plugin/undotree.lua
Normal file
@@ -0,0 +1 @@
|
||||
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||
2
.config/nvim/init.lua
Normal file
2
.config/nvim/init.lua
Normal file
@@ -0,0 +1,2 @@
|
||||
require("config")
|
||||
vim.cmd('source $HOME/.config/nvim/old_init.vim')
|
||||
25
.config/nvim/lua/config/gruvbox.lua
Normal file
25
.config/nvim/lua/config/gruvbox.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
-- setup must be called before loading the colorscheme
|
||||
-- Default options:
|
||||
require("gruvbox").setup({
|
||||
undercurl = true,
|
||||
underline = true,
|
||||
bold = true,
|
||||
italic = {
|
||||
strings = false,
|
||||
comments = true,
|
||||
operators = false,
|
||||
folds = true,
|
||||
},
|
||||
strikethrough = true,
|
||||
invert_selection = false,
|
||||
invert_signs = false,
|
||||
invert_tabline = false,
|
||||
invert_intend_guides = false,
|
||||
inverse = true, -- invert background for search, diffs, statuslines and errors
|
||||
contrast = "", -- can be "hard", "soft" or empty string
|
||||
palette_overrides = {},
|
||||
overrides = {},
|
||||
dim_inactive = false,
|
||||
transparent_mode = true,
|
||||
})
|
||||
vim.cmd.colorscheme("gruvbox")
|
||||
4
.config/nvim/lua/config/init.lua
Normal file
4
.config/nvim/lua/config/init.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
require("config.remap")
|
||||
require("config.options")
|
||||
require("config.gruvbox")
|
||||
|
||||
85
.config/nvim/lua/config/options.lua
Normal file
85
.config/nvim/lua/config/options.lua
Normal file
@@ -0,0 +1,85 @@
|
||||
-- Square cursor
|
||||
vim.opt.guicursor = ""
|
||||
|
||||
-- Enable relative line number
|
||||
vim.opt.nu = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
-- Set tabs to 4 spaces
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.expandtab = true
|
||||
|
||||
-- Enable auto indent and set it to 4 spaces
|
||||
vim.opt.smartindent = true
|
||||
vim.opt.shiftwidth = 4
|
||||
|
||||
-- Disable text wrap
|
||||
vim.opt.wrap = true
|
||||
|
||||
-- Enable persistent undo history
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.config/nvim/undodir"
|
||||
vim.opt.undofile = true
|
||||
|
||||
-- Set better splitting
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
|
||||
-- Better search options
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.incsearch = true
|
||||
|
||||
-- Enable 24-bit color
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
-- Always keep 8 lines above/below cursor unless at start/end of file
|
||||
vim.opt.scrolloff = 8
|
||||
|
||||
-- Decrease uptade time
|
||||
vim.opt.updatetime = 50
|
||||
|
||||
-- Remove trailing white spaces
|
||||
vim.api.nvim_create_autocmd({"BufWritePre"}, {
|
||||
group = vim.api.nvim_create_augroup("remove_trailing_spaces", { clear = true }),
|
||||
pattern = "*",
|
||||
desc = "Remove trailing white spaces",
|
||||
command = [[%s/\s\+$//e]],
|
||||
})
|
||||
|
||||
-- Restore cursor position
|
||||
vim.api.nvim_create_autocmd({"BufReadPost"}, {
|
||||
group = vim.api.nvim_create_augroup("restore_cursor_pos", { clear = true}),
|
||||
pattern = "*",
|
||||
desc = "Restore cursor position",
|
||||
callback = function()
|
||||
vim.cmd('silent! normal! g`"zv')
|
||||
end,
|
||||
})
|
||||
|
||||
-- Open help panel in a vsplit to the left
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = vim.api.nvim_create_augroup("vertical_help", { clear = true }),
|
||||
pattern = "help",
|
||||
callback = function()
|
||||
vim.bo.bufhidden = "unload"
|
||||
vim.cmd.wincmd("L")
|
||||
vim.cmd.wincmd("=")
|
||||
end,
|
||||
})
|
||||
|
||||
-- Highlight yankzone
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
group = vim.api.nvim_create_augroup("highlight_yank", { clear = true}),
|
||||
pattern = '*',
|
||||
desc = "Highlight selection on yank",
|
||||
callback = function()
|
||||
vim.highlight.on_yank({
|
||||
higroup = 'IncSearch',
|
||||
timeout = 200,
|
||||
visual = true,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
59
.config/nvim/lua/config/packer.lua
Normal file
59
.config/nvim/lua/config/packer.lua
Normal file
@@ -0,0 +1,59 @@
|
||||
return require('packer').startup(function(use)
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
use {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
tag = '0.1.1',
|
||||
-- or branch = '0.1.x',
|
||||
requires = { {'nvim-lua/plenary.nvim'} }
|
||||
}
|
||||
use "ellisonleao/gruvbox.nvim"
|
||||
|
||||
use {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = function()
|
||||
local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
|
||||
ts_update()
|
||||
end,
|
||||
}
|
||||
use 'nvim-treesitter/playground'
|
||||
use {
|
||||
'ThePrimeagen/harpoon',
|
||||
requires = { {'nvim-lua/plenary.nvim'} }
|
||||
}
|
||||
use 'mbbill/undotree'
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'airblade/vim-gitgutter'
|
||||
|
||||
use 'lukas-reineke/indent-blankline.nvim'
|
||||
|
||||
use 'JoosepAlviste/nvim-ts-context-commentstring'
|
||||
use 'numToStr/Comment.nvim'
|
||||
|
||||
use 'lervag/vimtex'
|
||||
|
||||
use {
|
||||
'neovim/nvim-lspconfig',
|
||||
requires = {
|
||||
-- LSP Support
|
||||
{'williamboman/mason.nvim'},
|
||||
{'williamboman/mason-lspconfig.nvim'},
|
||||
-- Autocompletion
|
||||
{'hrsh7th/nvim-cmp'},
|
||||
{'hrsh7th/cmp-nvim-lsp'},
|
||||
{'hrsh7th/cmp-buffer'},
|
||||
{'hrsh7th/cmp-path'},
|
||||
{'hrsh7th/cmp-cmdline'},
|
||||
-- Snippets
|
||||
{'L3MON4D3/LuaSnip'},
|
||||
{'saadparwaiz1/cmp_luasnip'},
|
||||
{'rafamadriz/friendly-snippets'},
|
||||
{'onsails/lspkind.nvim'},
|
||||
-- Utils
|
||||
{'j-hui/fidget.nvim'},
|
||||
{'folke/neodev.nvim'}
|
||||
}
|
||||
}
|
||||
|
||||
end)
|
||||
133
.config/nvim/lua/config/remap.lua
Normal file
133
.config/nvim/lua/config/remap.lua
Normal file
@@ -0,0 +1,133 @@
|
||||
local nnoremap = require("config.remap_utils").nnoremap
|
||||
local vnoremap = require("config.remap_utils").vnoremap
|
||||
local inoremap = require("config.remap_utils").inoremap
|
||||
local tnoremap = require("config.remap_utils").tnoremap
|
||||
local xnoremap = require("config.remap_utils").xnoremap
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Set leader key to space
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- Set Explorer keybind to leader-"e"
|
||||
vim.keymap.set("n","<leader>e", vim.cmd.Ex)
|
||||
|
||||
-- Disable Space bar since it'll be used as the leader key
|
||||
nnoremap("<space>", "<nop>")
|
||||
vnoremap("<space>", "<nop>")
|
||||
|
||||
-- Remap <C-c> to esc to avoid weird interaction
|
||||
inoremap("<C-c>", "<Esc>")
|
||||
|
||||
-- <leader>s for quick find/replace for the word under the cursor
|
||||
nnoremap("<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
|
||||
-- Paste without deleting what's in the yank
|
||||
xnoremap("<leader>p", [["_dP]])
|
||||
|
||||
-- <leader>f to format
|
||||
nnoremap("<leader>f", ":Format<cr>")
|
||||
|
||||
-- Characters/Words/Lines count
|
||||
nnoremap("<leader>cc", "<cmd>!wc -m %<cr>")
|
||||
nnoremap("<leader>cw", "<cmd>!wc -w %<cr>")
|
||||
nnoremap("<leader>cl", "<cmd>!wc -l %<cr>")
|
||||
|
||||
-- LSP Keybinds (exports a function to be used in ../../after/plugin/lsp.lua b/c we need a reference to the current buffer) --
|
||||
M.map_lsp_keybinds = function(buffer_number)
|
||||
-- Rename variable
|
||||
nnoremap("<leader>rn", vim.lsp.buf.rename, { desc = "LSP: [R]e[n]ame", buffer = buffer_number })
|
||||
|
||||
-- LSP code action
|
||||
nnoremap("<leader>ca", vim.lsp.buf.code_action, { desc = "LSP: [C]ode [A]ction", buffer = buffer_number })
|
||||
|
||||
-- Goto definition
|
||||
nnoremap("gd", vim.lsp.buf.definition, { desc = "LSP: [G]oto [D]efinition", buffer = buffer_number })
|
||||
|
||||
-- Telescope LSP keybinds --
|
||||
-- Goto reference
|
||||
nnoremap(
|
||||
"gr",
|
||||
require("telescope.builtin").lsp_references,
|
||||
{ desc = "LSP: [G]oto [R]eferences", buffer = buffer_number }
|
||||
)
|
||||
|
||||
-- Goto implementation
|
||||
nnoremap(
|
||||
"gi",
|
||||
require("telescope.builtin").lsp_implementations,
|
||||
{ desc = "LSP: [G]oto [I]mplementation", buffer = buffer_number }
|
||||
)
|
||||
|
||||
-- List of symbols in the current buffer
|
||||
nnoremap(
|
||||
"<leader>bs",
|
||||
require("telescope.builtin").lsp_document_symbols,
|
||||
{ desc = "LSP: [B]uffer [S]ymbols", buffer = buffer_number }
|
||||
)
|
||||
|
||||
-- List of symbols in the workspace
|
||||
nnoremap(
|
||||
"<leader>ps",
|
||||
require("telescope.builtin").lsp_workspace_symbols,
|
||||
{ desc = "LSP: [P]roject [S]ymbols", buffer = buffer_number }
|
||||
)
|
||||
|
||||
-- Hover documentation
|
||||
nnoremap("K", vim.lsp.buf.hover, { desc = "LSP: Hover Documentation", buffer = buffer_number })
|
||||
|
||||
-- Signature documentation
|
||||
nnoremap("<leader>k", vim.lsp.buf.signature_help, { desc = "LSP: Signature Documentation", buffer = buffer_number })
|
||||
inoremap("<C-k>", vim.lsp.buf.signature_help, { desc = "LSP: Signature Documentation", buffer = buffer_number })
|
||||
|
||||
-- Goto declaration
|
||||
nnoremap("gD", vim.lsp.buf.declaration, { desc = "LSP: [G]oto [D]eclaration", buffer = buffer_number })
|
||||
|
||||
-- Type definition
|
||||
nnoremap("td", vim.lsp.buf.type_definition, { desc = "LSP: [T]ype [D]efinition", buffer = buffer_number })
|
||||
end
|
||||
|
||||
-- Goto next diagnostic of any severity
|
||||
nnoremap("]d", function()
|
||||
vim.diagnostic.goto_next({})
|
||||
vim.api.nvim_feedkeys("zz", "n", false)
|
||||
end)
|
||||
|
||||
-- Goto prev diagnostic of any severity
|
||||
nnoremap("[d", function()
|
||||
vim.diagnostic.goto_prev({})
|
||||
vim.api.nvim_feedkeys("zz", "n", false)
|
||||
end)
|
||||
|
||||
-- Goto next error diagnostic
|
||||
nnoremap("]e", function()
|
||||
vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR })
|
||||
vim.api.nvim_feedkeys("zz", "n", false)
|
||||
end)
|
||||
|
||||
-- Goto previous error diagnostic
|
||||
nnoremap("[e", function()
|
||||
vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR })
|
||||
vim.api.nvim_feedkeys("zz", "n", false)
|
||||
end)
|
||||
|
||||
-- Goto next warning diagnostic
|
||||
nnoremap("]w", function()
|
||||
vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.WARN })
|
||||
vim.api.nvim_feedkeys("zz", "n", false)
|
||||
end)
|
||||
|
||||
-- Goto previous warning diagnostic
|
||||
nnoremap("[w", function()
|
||||
vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.WARN })
|
||||
vim.api.nvim_feedkeys("zz", "n", false)
|
||||
end)
|
||||
|
||||
-- Open diagnostic window
|
||||
nnoremap("<leader>d", function()
|
||||
vim.diagnostic.open_float({
|
||||
border = "rounded",
|
||||
})
|
||||
end)
|
||||
|
||||
return M
|
||||
21
.config/nvim/lua/config/remap_utils.lua
Normal file
21
.config/nvim/lua/config/remap_utils.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
local M = {}
|
||||
|
||||
-- Remap bindkey functions
|
||||
local function bind(op, outer_opts)
|
||||
outer_opts = vim.tbl_extend("force", { noremap = true, silent = true }, outer_opts or {})
|
||||
|
||||
return function(lhs, rhs, opts)
|
||||
opts = vim.tbl_extend("force", outer_opts, opts or {})
|
||||
vim.keymap.set(op, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
M.map = bind("")
|
||||
M.nmap = bind("n", { noremap = false })
|
||||
M.nnoremap = bind("n")
|
||||
M.vnoremap = bind("v")
|
||||
M.xnoremap = bind("x")
|
||||
M.inoremap = bind("i")
|
||||
M.tnoremap = bind("t")
|
||||
|
||||
return M
|
||||
62
.config/nvim/old_init.vim
Normal file
62
.config/nvim/old_init.vim
Normal file
@@ -0,0 +1,62 @@
|
||||
" Replace all is aliased to S.
|
||||
nnoremap S :%s//g<Left><Left>
|
||||
|
||||
" Compile document, be it groff/LaTeX/markdown/etc.
|
||||
map <leader>c :w! \| !compiler "%:p"<CR>
|
||||
|
||||
" Open corresponding .pdf/.html or preview
|
||||
map <leader>p :!opout "%:p"<CR>
|
||||
|
||||
" Runs a script that cleans out tex build files whenever I close out of a .tex file.
|
||||
autocmd VimLeave *.tex !texclear %
|
||||
|
||||
" Ensure files are read as what I want:
|
||||
let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
|
||||
map <leader>v :VimwikiIndex<CR>
|
||||
let g:vimwiki_list = [{'path': '~/.local/share/nvim/vimwiki', 'syntax': 'markdown', 'ext': '.md'}]
|
||||
autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown
|
||||
autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff
|
||||
autocmd BufRead,BufNewFile *.tex set filetype=tex
|
||||
|
||||
" Save file as sudo on files that require root permission
|
||||
cabbrev w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
|
||||
|
||||
" Automatically deletes all trailing whitespace and newlines at end of file on save. & reset cursor position
|
||||
autocmd BufWritePre * let currPos = getpos(".")
|
||||
autocmd BufWritePre * %s/\s\+$//e
|
||||
autocmd BufWritePre * %s/\n\+\%$//e
|
||||
autocmd BufWritePre *.[ch] %s/\%$/\r/e " add trailing newline for ANSI C standard
|
||||
autocmd BufWritePre *neomutt* %s/^--$/-- /e " dash-dash-space signature delimiter in emails
|
||||
autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
|
||||
|
||||
" When shortcut files are updated, renew bash and ranger configs with new material:
|
||||
autocmd BufWritePost bm-files,bm-dirs !shortcuts
|
||||
" Run xrdb whenever Xdefaults or Xresources are updated.
|
||||
autocmd BufRead,BufNewFile Xresources,Xdefaults,xresources,xdefaults set filetype=xdefaults
|
||||
autocmd BufWritePost Xresources,Xdefaults,xresources,xdefaults !xrdb %
|
||||
" Recompile dwmblocks on config edit.
|
||||
autocmd BufWritePost ~/.local/src/dwmblocks/config.h !cd ~/.local/src/dwmblocks/; sudo make install && { killall -q dwmblocks;setsid -f dwmblocks }
|
||||
|
||||
" Turns off highlighting on the bits of code that are changed, so the line that is changed is highlighted but the actual text that has changed stands out on the line and is readable.
|
||||
if &diff
|
||||
highlight! link DiffText MatchParen
|
||||
endif
|
||||
|
||||
" Function for toggling the bottom statusbar:
|
||||
let s:hidden_all = 0
|
||||
function! ToggleHiddenAll()
|
||||
if s:hidden_all == 0
|
||||
let s:hidden_all = 1
|
||||
set noshowmode
|
||||
set noruler
|
||||
set laststatus=0
|
||||
set noshowcmd
|
||||
else
|
||||
let s:hidden_all = 0
|
||||
set showmode
|
||||
set ruler
|
||||
set laststatus=2
|
||||
set showcmd
|
||||
endif
|
||||
endfunction
|
||||
nnoremap <leader>h :call ToggleHiddenAll()<CR>
|
||||
Reference in New Issue
Block a user