refactor: restructure init.lua to use lazy plugin manager and add lsp configurations

This commit is contained in:
sankalp committed 2025-09-12 16:05:40 +05:45
1 parent d685e0e553
commit 84f2be62ae
119 files changed
+2201 -18000

No files matched your search

+90 -98
View File
@@ -1,137 +1,129 @@
local function augroup(name)
return vim.api.nvim_create_augroup('keycodex' .. name, { clear = true })
return vim.api.nvim_create_augroup("nvim" .. name, { clear = true })
end
-- Strip trailing spaces before write
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
group = augroup('strip_space'),
pattern = { '*' },
callback = function()
vim.cmd([[ %s/\s\+$//e ]])
end,
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
group = augroup("strip_space"),
pattern = { "*" },
callback = function()
vim.cmd([[ %s/\s\+$//e ]])
end,
})
-- Check if we need to reload the file when it changed
vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, {
group = augroup('checktime'),
command = 'checktime',
vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, {
group = augroup("checktime"),
command = "checktime",
})
-- Highlight on yank
vim.api.nvim_create_autocmd('TextYankPost', {
group = augroup('highlight_yank'),
callback = function()
vim.highlight.on_yank()
end,
vim.api.nvim_create_autocmd("TextYankPost", {
group = augroup("highlight_yank"),
callback = function()
vim.highlight.on_yank()
end,
})
-- resize splits if window got resized
vim.api.nvim_create_autocmd({ 'VimResized' }, {
group = augroup('resize_splits'),
callback = function()
vim.cmd('tabdo wincmd =')
end,
vim.api.nvim_create_autocmd({ "VimResized" }, {
group = augroup("resize_splits"),
callback = function()
vim.cmd("tabdo wincmd =")
end,
})
-- go to last loc when opening a buffer
vim.api.nvim_create_autocmd('BufReadPost', {
group = augroup('last_loc'),
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
vim.api.nvim_create_autocmd("BufReadPost", {
group = augroup("last_loc"),
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- close some filetypes with <q>
vim.api.nvim_create_autocmd('FileType', {
group = augroup('close_with_q'),
pattern = {
'Jaq',
'PlenaryTestPopup',
'Avante',
'AvanteInput',
'AvanteSelectedFiles',
'fugitive',
'git',
'help',
'lir',
'lspinfo',
'man',
'netrw',
'notify',
'qf',
'spectre_panel',
'startuptime',
'tsplayground',
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set('n', 'q', '<cmd>close<cr>', { buffer = event.buf, silent = true })
end,
vim.api.nvim_create_autocmd("FileType", {
group = augroup("close_with_q"),
pattern = {
"Jaq",
"PlenaryTestPopup",
"Avante",
"AvanteInput",
"AvanteSelectedFiles",
"fugitive",
"git",
"help",
"lir",
"lspinfo",
"man",
"netrw",
"notify",
"qf",
"spectre_panel",
"startuptime",
"tsplayground",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})
-- wrap and check for spell in text filetypes
vim.api.nvim_create_autocmd('FileType', {
group = augroup('wrap_spell'),
pattern = { 'gitcommit', 'markdown' },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
vim.api.nvim_create_autocmd("FileType", {
group = augroup("wrap_spell"),
pattern = { "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
-- Auto create dir when saving a file, in case some intermediate directory does not exist
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
group = augroup('auto_create_dir'),
callback = function(event)
local file = vim.loop.fs_realpath(event.match) or event.match
vim.fn.mkdir(vim.fn.fnamemodify(file, ':p:h'), 'p')
end,
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
group = augroup("auto_create_dir"),
callback = function(event)
local file = vim.loop.fs_realpath(event.match) or event.match
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end,
})
-- Set arb filetype
vim.api.nvim_create_autocmd({ 'BufEnter' }, {
group = augroup('set_file_type'),
pattern = { '*.arb' },
command = require('lib.util').get_file_type_cmd('arb'),
vim.api.nvim_create_autocmd({ "BufEnter" }, {
group = augroup("set_file_type"),
pattern = { "*.arb" },
command = "setfiletype arb",
})
-- Disable format options
vim.api.nvim_create_autocmd('FileType', {
group = augroup('disable_formatoptions'),
pattern = '*',
callback = function()
vim.opt_local.formatoptions:remove({ 'c', 'r', 'o' })
end,
vim.api.nvim_create_autocmd("FileType", {
group = augroup("disable_formatoptions"),
pattern = "*",
callback = function()
vim.opt_local.formatoptions:remove({ "c", "r", "o" })
end,
})
local function enable_autoformat()
vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
group = augroup('autoformat'),
pattern = { '*' },
callback = function()
vim.lsp.buf.format()
end,
})
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
group = augroup("autoformat"),
pattern = { "*" },
callback = function()
vim.lsp.buf.format()
end,
})
end
enable_autoformat()
vim.api.nvim_create_user_command('WriteNoFormat', function()
-- Temporarily disable the autoformat autocmd
vim.api.nvim_del_augroup_by_name('keycodex_autoformat')
vim.cmd('write')
-- Re-enable the autoformat autocmd
enable_autoformat()
vim.api.nvim_create_user_command("WriteNoFormat", function()
-- Temporarily disable the autoformat autocmd
vim.api.nvim_del_augroup_by_name("keycodex_autoformat")
vim.cmd("write")
-- Re-enable the autoformat autocmd
enable_autoformat()
end, {})
local autocmd = vim.api.nvim_create_autocmd
autocmd('Signal', {
pattern = 'SIGUSR1',
callback = function()
require('nvchad.utils').reload()
end,
})
+17 -4
View File
@@ -46,10 +46,23 @@ end, {})
-- Switch to git root or file parent dir
vim.api.nvim_create_user_command('RootDir', function()
local root = require('lib.util').get_root_dir()
if root == '' then
local bufname = vim.fn.expand('%:p')
if vim.fn.filereadable(bufname) == 0 then
return
end
vim.cmd('lcd ' .. root)
local parent = vim.fn.fnamemodify(bufname, ':h')
local git_root = vim.fn.systemlist('git -C ' .. vim.fn.fnameescape(parent) .. ' rev-parse --show-toplevel')
local root = ''
if #git_root > 0 and git_root[1] ~= '' then
root = git_root[1]
else
root = parent
end
if root ~= '' then
vim.cmd('lcd ' .. vim.fn.fnameescape(root))
vim.notify('Changed directory to ' .. root, vim.log.levels.INFO)
end
end, {})
+71 -129
View File
@@ -1,160 +1,102 @@
local function map(mode, lhs, rhs, opts)
opts = opts or {}
opts.silent = opts.silent ~= false
vim.keymap.set(mode, lhs, rhs, opts)
opts = opts or {}
opts.silent = opts.silent ~= false
vim.keymap.set(mode, lhs, rhs, opts)
end
local opts = { noremap = true, silent = true }
-- Space as leader
map('n', '<Space>', '', opts)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
map("n", "<Space>", "", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Modes
-- normal_mode = "n", insert_mode = "i", visual_mode = "v",
-- visual_block_mode = "x", term_mode = "t", command_mode = "c",
-- Clear search, diff update and redraw
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
-- Use jj as escape
map('i', 'jj', '<Esc>', opts)
map('i', 'jk', '<Esc>', opts)
map('i', 'kj', '<Esc>', opts)
map('t', 'JJ', '<C-\\><C-n>', opts)
map({ "i", "c" }, "<C-b>", "<Left>")
map({ "i", "c" }, "<C-f>", "<Right>")
-- Terminal Mappings
map('t', 'jk', '<C-\\><C-n>')
map('t', 'kj', '<C-\\><C-n>')
map('t', '<ESC>', '<C-\\><C-n>')
map("n", "<leader>r", vim.lsp.buf.rename)
map("n", "`", "'", { noremap = true }) -- better marks
map("n", "H", "^", { desc = "Jump to line start" })
map("n", "L", "$", { desc = "Jump to line end" })
-- Visual overwrite paste
map({ 'v', 'x' }, 'p', '"_dP', opts)
map({ "v", "x" }, "p", '"_dP', opts)
-- Do not copy on x
map({ 'v', 'x' }, 'x', '"_x', opts)
-- VSCode style shortcuts
-- File operations
map('n', '<C-s>', ':w<CR>', { desc = 'Save file' })
map('i', '<C-s>', '<Esc>:w<CR>a', { desc = 'Save file' })
map('n', '<C-q>', ':q<CR>', { desc = 'Quit' })
map('n', '<C-w>', ':bd<CR>', { desc = 'Close buffer' })
-- Undo/Redo
map('n', '<C-z>', 'u', { desc = 'Undo' })
map('i', '<C-z>', '<C-o>u', { desc = 'Undo' })
map('n', '<C-y>', '<C-r>', { desc = 'Redo' })
map('i', '<C-y>', '<C-o><C-r>', { desc = 'Redo' })
map({ "v", "x" }, "x", '"_x', opts)
map("n", "X", '"_D', opts)
map({ "v", "x" }, "X", '"_d', opts)
-- Select all
map('n', '<C-a>', 'ggVG', { desc = 'Select all' })
map('i', '<C-a>', '<Esc>ggVG', { desc = 'Select all' })
-- Copy/Cut
map('v', '<C-c>', 'y', { desc = 'Copy' })
map('v', '<C-x>', 'd', { desc = 'Cut' })
-- Line operations (VSCode style)
map('n', '<A-Up>', ':m .-2<CR>==', { desc = 'Move line up' })
map('n', '<A-Down>', ':m .+1<CR>==', { desc = 'Move line down' })
map('i', '<A-Up>', '<Esc>:m .-2<CR>==gi', { desc = 'Move line up' })
map('i', '<A-Down>', '<Esc>:m .+1<CR>==gi', { desc = 'Move line down' })
map('v', '<A-Up>', ":m '<-2<CR>gv=gv", { desc = 'Move selection up' })
map('v', '<A-Down>', ":m '>+1<CR>gv=gv", { desc = 'Move selection down' })
-- VSCode-style line operations
map('n', '<S-CR>', 'o<Esc>', { desc = 'Insert line below' })
map('i', '<S-CR>', '<C-o>o', { desc = 'Insert line below' })
-- Quick word operations
map('n', '<C-BS>', 'db', { desc = 'Delete word backward' })
map('i', '<C-BS>', '<C-w>', { desc = 'Delete word backward' })
map('n', '<C-Del>', 'dw', { desc = 'Delete word forward' })
map('i', '<C-Del>', '<C-o>dw', { desc = 'Delete word forward' })
-- Duplicate line
map('n', '<A-S-Up>', 'yykP', { desc = 'Duplicate line up' })
map('n', '<A-S-Down>', 'yyp', { desc = 'Duplicate line down' })
map('v', '<A-S-Up>', "y'<Pgv", { desc = 'Duplicate selection up' })
map('v', '<A-S-Down>', "y'>pgv", { desc = 'Duplicate selection down' })
-- Line manipulation
map('n', '<C-]>', '>>', { desc = 'Indent line' })
map('n', '<C-[>', '<<', { desc = 'Unindent line' })
map('i', '<C-]>', '<C-o>>>', { desc = 'Indent line' })
map('i', '<C-[>', '<C-o><<', { desc = 'Unindent line' })
-- Visual overwrite paste
map({ 'v', 'x' }, 'p', '"_dP', opts)
-- Do not copy on x
map({ 'v', 'x' }, 'x', '"_x', opts)
map('n', 'X', '"_D', opts)
map({ 'v', 'x' }, 'X', '"_d', opts)
-- Increment/decrement
map({ 'n', 'v', 'x' }, '-', '<C-x>', opts)
map({ 'n', 'v', 'x' }, '=', '<C-a>', opts)
-- Move to line beginning and end
map({ 'n', 'v', 'x' }, 'gl', '$', { desc = 'End of line' })
map({ 'n', 'v', 'x' }, 'gh', '^', { desc = 'Beginning of line' })
-- Center Cursors
map('n', 'J', 'mzJ`z', opts)
map('n', '<C-d>', '<C-d>zz', opts)
map('n', '<C-u>', '<C-u>zz', opts)
map('n', 'n', 'nzzzv', opts)
map('n', 'N', 'Nzzzv', opts)
-- Better up/down
map('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
map("n", "<C-a>", "ggVG", { desc = "Select all" })
map("i", "<C-a>", "<Esc>ggVG", { desc = "Select all" })
-- Move text up and down
map({ 'v', 'x' }, 'J', ":move '>+1<cr>gv-gv", opts)
map({ 'v', 'x' }, 'K', ":move '<-2<cr>gv-gv", opts)
map({ "v", "x" }, "K", ":move '<-2<cr>gv-gv", opts)
map({ "v", "x" }, "J", ":move '>+1<cr>gv-gv", opts)
-- Clear search, diff update and redraw
map({ 'i', 'n' }, '<esc>', '<cmd>noh<cr><esc>', { desc = 'Escape and clear hlsearch' })
-- Line operations
map("n", "<A-k>", ":m .-2<CR>==", { desc = "Move line up" })
map("n", "<A-j>", ":m .+1<CR>==", { desc = "Move line down" })
map("i", "<A-k>", "<Esc>:m .-2<CR>==gi", { desc = "Move line up" })
map("i", "<A-j>", "<Esc>:m .+1<CR>==gi", { desc = "Move line down" })
map("v", "<A-k>", ":m '<-2<CR>gv=gv", { desc = "Move selection up" })
map("v", "<A-j>", ":m '>+1<CR>gv=gv", { desc = "Move selection down" })
-- Consistent n/N search navigation
map('n', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' })
map('x', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' })
map('o', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' })
map('n', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' })
map('x', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' })
map('o', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' })
-- Line manipulation
map("n", "<C-]>", ">>", { desc = "Indent line" })
map("n", "<C-[>", "<<", { desc = "Unindent line" })
map("i", "<C-]>", "<C-o>>>", { desc = "Indent line" })
map("i", "<C-[>", "<C-o><<", { desc = "Unindent line" })
-- Better indenting
map('v', '<', '<gv')
map('v', '>', '>gv')
-- Quick word operations
map("n", "<C-BS>", "db", { desc = "Delete word backward" })
map("i", "<C-BS>", "<C-w>", { desc = "Delete word backward" })
map("n", "<C-Del>", "dw", { desc = "Delete word forward" })
map("i", "<C-Del>", "<C-o>dw", { desc = "Delete word forward" })
-- Add undo breakpoints
map('i', ',', ',<c-g>u')
map('i', '.', '.<c-g>u')
map('i', ';', ';<c-g>u')
map('n', 'd', '"_d', { desc = 'Delete without replacing clipboard' })
map('n', 'x', '"_x', { desc = 'Cut without replacing clipboard' })
map('n', 'c', '"_c', { desc = 'Change without replacing clipboard' })
map('v', 'p', '"_dP', { desc = 'Paste without replacing clipboard' })
-- Toggle relative numbers off or on (for code presentation)
map({ 'n', 'v' }, '<leader>tn', '<cmd>set rnu!<cr>', {})
map("n", "d", '"_d', { desc = "Delete without replacing clipboard" })
map("n", "x", '"_x', { desc = "Cut without replacing clipboard" })
map("n", "c", '"_c', { desc = "Change without replacing clipboard" })
map("v", "p", '"_dP', { desc = "Paste without replacing clipboard" })
--insert the following characters around the visual selection
map('v', '<leader>(', 's()<esc>Pll', { desc = 'wrap selection with parens' })
map('v', '<leader>[', 's[]<esc>Pll', { desc = 'wrap selection with square braces' })
map('v', '<leader>{', 's{}<esc>Pll', { desc = 'wrap selection with curly braces' })
map('v', "<leader>'", "s''<esc>Pll", { desc = 'wrap selection with single quotes' })
map('v', '<leader>"', 's""<esc>Pll', { desc = 'wrap selection with double quotes' })
map("v", "<leader>(", "s()<esc>Pll", { desc = "wrap selection with parens" })
map("v", "<leader>[", "s[]<esc>Pll", { desc = "wrap selection with square braces" })
map("v", "<leader>{", "s{}<esc>Pll", { desc = "wrap selection with curly braces" })
map("v", "<leader>'", "s''<esc>Pll", { desc = "wrap selection with single quotes" })
map("v", '<leader>"', 's""<esc>Pll', { desc = "wrap selection with double quotes" })
-- Insert mode cursor movement with Ctrl+hjkl
map('i', '<C-h>', '<Left>', { desc = 'Move cursor left' })
map('i', '<C-j>', '<Down>', { desc = 'Move cursor down' })
map('i', '<C-k>', '<Up>', { desc = 'Move cursor up' })
map('i', '<C-l>', '<Right>', { desc = 'Move cursor right' })
map("i", "<C-h>", "<Left>", { desc = "Move to end of previous line" })
map("i", "<C-j>", "<Down>", { desc = "Move cursor down" })
map("i", "<C-k>", "<Up>", { desc = "Move cursor up" })
map("i", "<C-l>", "<Right>", { desc = "Move cursor right" })
-- toggle inlay hints
vim.keymap.set("n", "<leader>th", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
end)
-- No arrow navigation
vim.api.nvim_set_keymap("n", "<Up>", "<Nop>", opts)
vim.api.nvim_set_keymap("n", "<Down>", "<Nop>", opts)
vim.api.nvim_set_keymap("n", "<Left>", "<Nop>", opts)
vim.api.nvim_set_keymap("n", "<Right>", "<Nop>", opts)
vim.api.nvim_set_keymap("v", "<Up>", "<Nop>", opts)
vim.api.nvim_set_keymap("v", "<Down>", "<Nop>", opts)
vim.api.nvim_set_keymap("v", "<Left>", "<Nop>", opts)
vim.api.nvim_set_keymap("v", "<Right>", "<Nop>", opts)
vim.api.nvim_set_keymap("i", "<Up>", "<Nop>", opts)
vim.api.nvim_set_keymap("i", "<Down>", "<Nop>", opts)
vim.api.nvim_set_keymap("i", "<Left>", "<Nop>", opts)
vim.api.nvim_set_keymap("i", "<Right>", "<Nop>", opts)
+37
View File
@@ -0,0 +1,37 @@
--------------------------------------------------------------------------------
-- Bootstrap lazy plugin manager
--------------------------------------------------------------------------------
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- lazy config
require("lazy").setup({
spec = {
{ import = "plugins" },
},
install = {
missing = true,
colorscheme = { "onedark" },
},
change_detection = {
enable = true,
notify = false,
},
ui = {
border = "rounded",
backdrop = 100,
},
})
+135
View File
@@ -0,0 +1,135 @@
--------------------------------------------------------------------------------
-- LSP
--------------------------------------------------------------------------------
-- ts_ls
vim.lsp.config("ts_ls", {
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
},
},
},
})
vim.lsp.enable("ts_ls")
-- rust
vim.lsp.config("rust_analyzer", {
settings = {
["rust-analyzer"] = {
diagnostics = {
enable = true,
experimental = { enable = true },
},
},
},
})
vim.lsp.enable("rust_analyzer")
-- lua
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = {
disable = {
"missing-fields",
"undefined-global",
},
},
},
},
})
vim.lsp.enable("lua_ls")
-- python
vim.lsp.config("basedpyright", {
settings = {
basedpyright = {
inlayHints = true,
disableDiagnostics = true,
disableOrganizeImports = true,
analysis = {
-- Ignore all files for analysis to exclusively use Ruff for linting
-- Enable diagnostics
-- ignore = { "*" },
diagnosticSeverityOverrides = {
reportUnusedImport = "none",
reportUnusedVariable = "none",
reportAttributeAccessIssue = "none",
reportUnusedClass = "none",
reportUnusedFunction = "none",
reportDuplicateImport = "none",
reportArgumentType = "error",
},
typeCheckingMode = "basic",
},
},
},
})
vim.lsp.enable("basedpyright")
vim.lsp.config("pylsp", {
settings = {
pylsp = {
plugins = {
-- use black as default formatter
yapf = { enabled = false },
autopep8 = { enabled = false },
black = { enabled = true },
pycodestyle = {
enabled = true,
ignore = { "E203", "E701", "W503" },
maxLineLength = 88,
},
},
},
},
})
-- latex
vim.lsp.config("texlab", {
settings = {
texlab = {
build = {
executable = "latexmk",
args = {
"-lualatex",
"-interaction=nonstopmode",
"-outdir=build",
},
onSave = true,
},
},
},
})
vim.lsp.enable("texlab")
-- bash
vim.lsp.config("bashls", {
settings = {
bashIde = {
shellcheckArguments = {
"--exclude=SC1090,SC1091,SC2076,SC2164",
},
},
},
})
vim.lsp.enable("bashls")
-- cpp
vim.lsp.config("clangd", {
cmd = {
"clangd",
"--fallback-style=llvm",
"--header-insertion=iwyu",
"-j=4",
},
})
vim.lsp.enable("clangd")
+53 -80
View File
@@ -1,91 +1,64 @@
local options = {
ai = true,
autoindent = true,
autowrite = true,
backspace = 'indent,eol,start',
backup = false, -- creates a backup file
breakindent = true,
clipboard = 'unnamedplus', -- allows neovim to access the system clipboard
cmdheight = 1, -- more space in the neovim command line for displaying messages
completeopt = 'menu,menuone,noselect', -- mostly just for cmp
conceallevel = 0, -- so that `` is visible in markdown files
confirm = true, -- Confirm to save changes before exiting modified buffer
cursorline = true, -- highlight the current line
expandtab = true, -- convert tabs to spaces
fileencoding = 'utf-8', -- the encoding written to a file
formatoptions = 'jlnqt', -- set formatoptions, check help fo-table
grepformat = '%f:%l:%c:%m',
grepprg = 'rg --vimgrep',
hlsearch = true, -- highlight all matches on previous search pattern
ignorecase = true, -- ignore case in search patterns
inccommand = 'split', -- preview incremental substitute
laststatus = 3,
list = true,
-- listchars = { trail = '', tab = '', nbsp = '_', extends = '>', precedes = '<' }, -- highlight
mouse = 'a', -- allow the mouse to be used in neovim
number = true, -- set numbered lines
numberwidth = 4, -- set number column width to 2 {default 4}
pumblend = 10, -- Popup blen
pumheight = 10, -- pop up menu height
relativenumber = true, -- set relative numbered lines
scrolloff = 10, -- is one of my fav
sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal',
shiftround = true, -- Round indent
shiftwidth = 4, -- the number of spaces inserted for each indentation
showcmd = false,
showmode = false, -- we don't need to see things like -- INSERT -- anymore
showtabline = 0, -- always show tabs
si = true,
sidescrolloff = 8,
signcolumn = 'yes', -- always show the sign column, otherwise it would shift the text each time
smartcase = true, -- smart case
smartindent = true, -- make indenting smarter again
smarttab = true,
splitbelow = true, -- force all horizontal splits to go below current window
splitright = true, -- force all vertical splits to go to the right of current window
swapfile = false, -- creates a swapfile
tabstop = 4, -- insert 2 spaces for a tab
termguicolors = true, -- set term gui colors (most terminals support this)
timeoutlen = 300, -- time to wait for a mapped sequence to complete (in milliseconds)
title = true, -- window titles
undofile = true, -- enable persistent undo
undodir = vim.fn.stdpath('cache') .. '/undo',
undolevels = 10000,
updatetime = 250, -- balance between responsiveness and performance
wildmenu = true, -- wildmenu
wildmode = 'longest:full,full', -- Command-line completion mode
winminwidth = 5, -- Minimum window width
wrap = false, -- display lines as one long line
writebackup = false, -- do not edit backups
ai = true,
clipboard = "unnamedplus", -- use system clipboard
number = true,
relativenumber = true,
undofile = true, -- save state of file on write
undodir = vim.fn.stdpath("cache") .. "/undo",
undolevels = 10000,
autoread = true, -- autoread changes from other sources
signcolumn = "yes",
cursorline = true,
cursorlineopt = "number",
wrap = false,
scrolloff = 3,
ruler = false, -- removes cursor position from lastline
pumheight = 10, -- size of completion window
showmode = false, -- do not show mode under statusline
swapfile = false, -- creates a swapfile
backup = false, -- creates a backup file
writebackup = false, -- do not edit backups
winminwidth = 5, -- Minimum window width
termguicolors = true, -- set term gui colors (most terminals support this)
showtabline = 0, -- always show tabs
showcmd = false,
mouse = "a", -- allow the mouse to be used in neovim
confirm = true, -- Confirm to save changes before exiting modified buffer
-- tabs
smarttab = true,
tabstop = 4, -- 1 tab represented as 4 spaces
expandtab = true, -- <tab> key will create " " instead of "\t"
shiftwidth = 4, -- indent change after backspace and >> <<
softtabstop = 4, -- number of spaces instead of tab
autoindent = true, -- auto indent
smartindent = true, -- make indenting smarter again
list = true,
-- listchars = { trail = "", tab = "", nbsp = "_", extends = ">", precedes = "<" }, -- highlight
showbreak = string.rep(" ", 3),
-- Search
ignorecase = true,
smartcase = true,
hlsearch = true,
wildmenu = true,
wildmode = "longest:full,full",
wildoptions = "pum",
-- Window
splitright = true,
splitbelow = true,
title = true,
}
for k, v in pairs(options) do
vim.opt[k] = v
vim.opt[k] = v
end
-- netrw file explorer settings
vim.g.netrw_winsize = 20
vim.g.netrw_banner = 0
vim.g.netrw_liststyle = 1
vim.opt.path:append({ "**" })
vim.opt.shortmess:append({ W = true, I = true, c = true }) -- disable greeting
-- Fix markdown indentation settings
vim.g.markdown_recommended_style = 0
vim.opt.path:append({ '**' })
vim.opt.shortmess:append({ W = true, I = true, c = true })
-- hides `~` at the end of the buffer
vim.cmd([[set fillchars+=eob:\ ]])
vim.cmd([[
setlocal spell spelllang=en "Set spellcheck language to en
setlocal spell! "Disable spell checks by default
filetype plugin indent on
if has('win32')
let g:python3_host_prog = $HOME . '/scoop/apps/python/current/python.exe'
endif
let &t_Cs = "\e[4:3m" "Undercurl
let &t_Ce = "\e[4:0m"
set whichwrap+=<,>,[,],h,l
set iskeyword+=-
]])