aboutsummaryrefslogtreecommitdiffstats
path: root/.config/nvim/init.lua
diff options
context:
space:
mode:
authorkj_sh6042026-06-07 12:44:03 -0400
committerkj_sh6042026-06-07 12:44:03 -0400
commita2fdad205a29d1555ae5819e05eec80ceedcfc52 (patch)
treefdf26d42063eae9c30d4f9ced4b766c64640d6d7 /.config/nvim/init.lua
parentc93163a589f69d6249f4e38e1adfb29239c1ea8c (diff)
refactor: beautify and change update keybind
Diffstat (limited to '')
-rw-r--r--.config/nvim/init.lua368
1 files changed, 184 insertions, 184 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index 080a864..4427ca1 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -28,38 +28,38 @@ vim.g.pear_tree_ft_disabled = { "TelescopePrompt", "TelescopeResults" }
-- options
local opts = {
- autochdir = true,
- autoindent = true,
- autoread = true,
- backup = false,
- cursorline = true,
- expandtab = true,
- hlsearch = true,
- ignorecase = true,
- linebreak = true,
- listchars = { tab = ">-", trail = "~", extends = ">", precedes = "<", space = "." },
- mouse = "a",
- number = true,
- relativenumber = true,
- shiftwidth = 4,
- showmatch = true,
- signcolumn = "yes",
- smartcase = true,
- softtabstop = 4,
- splitbelow = true,
- splitright = true,
- tabstop = 4,
- termguicolors = true,
- ttimeout = true,
- ttimeoutlen = 1,
- ttyfast = true,
- undofile = true,
- updatetime = 300,
- writebackup = false,
+ autochdir = true,
+ autoindent = true,
+ autoread = true,
+ backup = false,
+ cursorline = true,
+ expandtab = true,
+ hlsearch = true,
+ ignorecase = true,
+ linebreak = true,
+ listchars = { tab = ">-", trail = "~", extends = ">", precedes = "<", space = "." },
+ mouse = "a",
+ number = true,
+ relativenumber = true,
+ shiftwidth = 4,
+ showmatch = true,
+ signcolumn = "yes",
+ smartcase = true,
+ softtabstop = 4,
+ splitbelow = true,
+ splitright = true,
+ tabstop = 4,
+ termguicolors = true,
+ ttimeout = true,
+ ttimeoutlen = 1,
+ ttyfast = true,
+ undofile = true,
+ updatetime = 300,
+ writebackup = false,
}
for k, v in pairs(opts) do
- vim.opt[k] = v
+ vim.opt[k] = v
end
-- spell and cursor shape
@@ -69,7 +69,7 @@ vim.g.t_EI = "\27[2 q"
-- terminal tweaks
if vim.env.TERM == "alacritty" then
- vim.opt.ttymouse = "sgr"
+ vim.opt.ttymouse = "sgr"
end
-- custom functions for keymaps
@@ -113,8 +113,8 @@ keymap("n", "<A-n>", ":NERDTreeToggle<CR>", { noremap = true })
keymap("n", "<S-A-n>", ":NERDTree<CR>", { noremap = true })
keymap("n", "<S-A-j>", "<C-W>w", { noremap = true })
keymap("n", "<S-A-k>", "<C-W>W", { noremap = true })
-keymap({"n", "t"}, "<S-A-b>j", function() toggle_terminal() end, { noremap = true })
-keymap({"n", "t"}, "<S-A-b><S-A-j>", function() toggle_terminal() end, { noremap = true })
+keymap({ "n", "t" }, "<S-A-b>j", function() toggle_terminal() end, { noremap = true })
+keymap({ "n", "t" }, "<S-A-b><S-A-j>", function() toggle_terminal() end, { noremap = true })
keymap("n", "<leader>sc", ":set spell!<CR>", { noremap = true, silent = true })
keymap("n", "<A-j>", ":bnext<CR>", { noremap = true, silent = true })
@@ -139,31 +139,31 @@ keymap("n", "<A-'>", ":tabmove +<CR>", { noremap = true })
keymap("n", "<leader>ft", ":set filetype=", { noremap = true })
-- copilot
-keymap("i", "<C-l>", 'copilot#Accept("<CR>")', { expr = true, silent = true, replace_keycodes = false })
+keymap("i", "<A-a>", 'copilot#Accept("<CR>")', { expr = true, silent = true, replace_keycodes = false })
-- ui and colors
vim.cmd("colorscheme kijish")
if vim.fn.has("gui_running") == 1 then
- vim.opt.t_Co = 256
- vim.opt.guifont = "Roboto Mono 11"
- vim.opt.guioptions:remove("m")
- vim.opt.guioptions:remove("T")
- vim.opt.guioptions:remove("r")
- vim.opt.guioptions:remove("L")
- vim.cmd("colorscheme tender")
+ vim.opt.t_Co = 256
+ vim.opt.guifont = "Roboto Mono 11"
+ vim.opt.guioptions:remove("m")
+ vim.opt.guioptions:remove("T")
+ vim.opt.guioptions:remove("r")
+ vim.opt.guioptions:remove("L")
+ vim.cmd("colorscheme tender")
end
-- autocmds
vim.api.nvim_create_autocmd("BufWritePre", {
- pattern = { "*.py", "*.f90", "*.f95", "*.for" },
- command = [[%s/\s\+$//e]],
+ pattern = { "*.py", "*.f90", "*.f95", "*.for" },
+ command = [[%s/\s\+$//e]],
})
local autoread_group = vim.api.nvim_create_augroup("autoread", { clear = true })
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
- group = autoread_group,
- command = "if mode() !~ '\''[cCeEsS]'\'' | checktime | endif",
+ group = autoread_group,
+ command = "if mode() !~ '\''[cCeEsS]'\'' | checktime | endif",
})
vim.cmd("filetype plugin on")
@@ -174,11 +174,11 @@ vim.cmd("highlight LineNr guifg=darkgray ctermfg=darkgray")
vim.cmd("highlight CursorLineNr guifg=cyan ctermfg=cyan")
vim.opt.fillchars = vim.opt.fillchars + {
- vert = "â–ˆ",
- fold = "â–ˆ",
- diff = "â–ˆ",
- stl = "-",
- stlnc = "-",
+ vert = "â–ˆ",
+ fold = "â–ˆ",
+ diff = "â–ˆ",
+ stl = "-",
+ stlnc = "-",
}
vim.cmd([[
@@ -192,54 +192,54 @@ vim.cmd([[
-- statusline
vim.o.statusline = table.concat({
- "%1* %n %*",
- "%3* %y %*",
- "%4* %<%f %*",
- "%2* %m %*",
- "%1* %= %5l %*",
- "%2* /%L %*",
- "%1* %4v %*",
- "%2* 0x%04B %*",
- "%5* %{&ff} %*",
+ "%1* %n %*",
+ "%3* %y %*",
+ "%4* %<%f %*",
+ "%2* %m %*",
+ "%1* %= %5l %*",
+ "%2* /%L %*",
+ "%1* %4v %*",
+ "%2* 0x%04B %*",
+ "%5* %{&ff} %*",
})
-- telescope
local tele_ok, builtin = pcall(require, "telescope.builtin")
if tele_ok then
- keymap("n", "<leader>fg", function()
- builtin.live_grep({
- find_command = { "rg", "--ignore", "--hidden", "--files" },
- prompt_prefix = " search: ",
- })
- end, {})
-
- keymap("n", "<leader>ff", function()
- builtin.find_files({
- find_command = { "rg", "--ignore", "--hidden", "--files" },
- prompt_prefix = " search: ",
- })
- end, {})
-
- keymap("n", "<leader>fb", function()
- builtin.buffers({
- prompt_prefix = " search: ",
- })
- end, {})
-
- keymap("n", "<leader>fh", function()
- builtin.help_tags({
- prompt_prefix = " search: ",
- })
- end, {})
+ keymap("n", "<leader>fg", function()
+ builtin.live_grep({
+ find_command = { "rg", "--ignore", "--hidden", "--files" },
+ prompt_prefix = " search: ",
+ })
+ end, {})
+
+ keymap("n", "<leader>ff", function()
+ builtin.find_files({
+ find_command = { "rg", "--ignore", "--hidden", "--files" },
+ prompt_prefix = " search: ",
+ })
+ end, {})
+
+ keymap("n", "<leader>fb", function()
+ builtin.buffers({
+ prompt_prefix = " search: ",
+ })
+ end, {})
+
+ keymap("n", "<leader>fh", function()
+ builtin.help_tags({
+ prompt_prefix = " search: ",
+ })
+ end, {})
end
-- lsp
vim.diagnostic.config({
- update_in_insert = false,
- severity_sort = true,
- float = { border = "rounded", source = "if_many" },
- underline = { severity = { min = vim.diagnostic.severity.WARN } },
- virtual_text = true,
+ update_in_insert = false,
+ severity_sort = true,
+ float = { border = "rounded", source = "if_many" },
+ underline = { severity = { min = vim.diagnostic.severity.WARN } },
+ virtual_text = true,
})
keymap("n", "[d", function() vim.diagnostic.jump({ count = -1 }) end, { desc = "diagnostic prev" })
@@ -251,49 +251,49 @@ keymap("n", "<S-A-m>", vim.diagnostic.setloclist, { desc = "diagnostic list" })
vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("user-lsp-attach", { clear = true }),
- callback = function(event)
- local map = function(keys, func, desc, mode)
- mode = mode or "n"
- vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "lsp: " .. desc })
- end
-
- map("grn", vim.lsp.buf.rename, "rename")
- map("gra", vim.lsp.buf.code_action, "code action", { "n", "x" })
- map("grD", vim.lsp.buf.declaration, "declaration")
- map("gri", vim.lsp.buf.implementation, "implementation")
- map("grr", vim.lsp.buf.references, "references")
- map("grd", vim.lsp.buf.definition, "definition")
- map("grt", vim.lsp.buf.type_definition, "type definition")
- map("K", vim.lsp.buf.hover, "hover")
- map("<leader>F", function() vim.lsp.buf.format({ async = true }) end, "format", { "n", "x" })
-
- local client = vim.lsp.get_client_by_id(event.data.client_id)
- if client and client:supports_method("textDocument/documentHighlight", event.buf) then
- local highlight_group = vim.api.nvim_create_augroup("user-lsp-highlight", { clear = false })
- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
- buffer = event.buf,
- group = highlight_group,
- callback = vim.lsp.buf.document_highlight,
- })
- vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
- buffer = event.buf,
- group = highlight_group,
- callback = vim.lsp.buf.clear_references,
- })
- end
-
- if client and client:supports_method("textDocument/inlayHint", event.buf) then
- map("<leader>th", function()
- vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
- end, "toggle inlay hints")
- end
- end,
+ group = vim.api.nvim_create_augroup("user-lsp-attach", { clear = true }),
+ callback = function(event)
+ local map = function(keys, func, desc, mode)
+ mode = mode or "n"
+ vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "lsp: " .. desc })
+ end
+
+ map("grn", vim.lsp.buf.rename, "rename")
+ map("gra", vim.lsp.buf.code_action, "code action", { "n", "x" })
+ map("grD", vim.lsp.buf.declaration, "declaration")
+ map("gri", vim.lsp.buf.implementation, "implementation")
+ map("grr", vim.lsp.buf.references, "references")
+ map("grd", vim.lsp.buf.definition, "definition")
+ map("grt", vim.lsp.buf.type_definition, "type definition")
+ map("K", vim.lsp.buf.hover, "hover")
+ map("<leader>F", function() vim.lsp.buf.format({ async = true }) end, "format", { "n", "x" })
+
+ local client = vim.lsp.get_client_by_id(event.data.client_id)
+ if client and client:supports_method("textDocument/documentHighlight", event.buf) then
+ local highlight_group = vim.api.nvim_create_augroup("user-lsp-highlight", { clear = false })
+ vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
+ buffer = event.buf,
+ group = highlight_group,
+ callback = vim.lsp.buf.document_highlight,
+ })
+ vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
+ buffer = event.buf,
+ group = highlight_group,
+ callback = vim.lsp.buf.clear_references,
+ })
+ end
+
+ if client and client:supports_method("textDocument/inlayHint", event.buf) then
+ map("<leader>th", function()
+ vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
+ end, "toggle inlay hints")
+ end
+ end,
})
local ok_fidget, fidget = pcall(require, "fidget")
if ok_fidget then
- fidget.setup({})
+ fidget.setup({})
end
local ok_mason, mason = pcall(require, "mason")
@@ -302,48 +302,48 @@ local ok_tools, mason_tool_installer = pcall(require, "mason-tool-installer")
-- put lsp servers here to ensure they are installed and configured
local servers = {
- bashls = {},
- clangd = {},
- dockerls = {},
- docker_compose_language_service = {},
- html = {},
- cssls = {},
- ts_ls = {},
- intelephense = {},
- pylsp = {},
- lua_ls = {
- settings = {
- Lua = {
- completion = { callSnippet = "Replace" },
- diagnostics = { globals = { "vim" } },
- workspace = {
- checkThirdParty = false,
- library = vim.api.nvim_get_runtime_file("", true),
- },
- telemetry = { enable = false },
- },
- },
- },
+ bashls = {},
+ clangd = {},
+ dockerls = {},
+ docker_compose_language_service = {},
+ html = {},
+ cssls = {},
+ ts_ls = {},
+ intelephense = {},
+ pylsp = {},
+ lua_ls = {
+ settings = {
+ Lua = {
+ completion = { callSnippet = "Replace" },
+ diagnostics = { globals = { "vim" } },
+ workspace = {
+ checkThirdParty = false,
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ telemetry = { enable = false },
+ },
+ },
+ },
}
if ok_mason then
- mason.setup()
+ mason.setup()
end
if ok_tools then
- mason_tool_installer.setup({ ensure_installed = vim.tbl_keys(servers) })
+ mason_tool_installer.setup({ ensure_installed = vim.tbl_keys(servers) })
end
if ok_mlsp then
- mason_lspconfig.setup({
- ensure_installed = vim.tbl_keys(servers),
- automatic_installation = true,
- })
+ mason_lspconfig.setup({
+ ensure_installed = vim.tbl_keys(servers),
+ automatic_installation = true,
+ })
end
for server_name, server_config in pairs(servers) do
- vim.lsp.config(server_name, server_config)
- vim.lsp.enable(server_name)
+ vim.lsp.config(server_name, server_config)
+ vim.lsp.enable(server_name)
end
-- completion
@@ -351,31 +351,31 @@ vim.opt.completeopt = { "menu", "menuone", "noinsert" }
local ok_cmp, cmp = pcall(require, "cmp")
if ok_cmp then
- cmp.setup({
- mapping = cmp.mapping.preset.insert({
- ["<Tab>"] = cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_next_item()
- else
- fallback()
- end
- end, { "i", "s" }),
- ["<S-Tab>"] = cmp.mapping(function(fallback)
- if cmp.visible() then
- cmp.select_prev_item()
- else
- fallback()
- end
- end, { "i", "s" }),
- ["<C-Space>"] = cmp.mapping.complete(),
- ["<C-e>"] = cmp.mapping.abort(),
- ["<CR>"] = cmp.mapping.confirm({ select = true }),
- }),
- sources = cmp.config.sources({
- { name = "nvim_lsp" },
- }, {
- { name = "buffer" },
- { name = "path" },
- }),
- })
+ cmp.setup({
+ mapping = cmp.mapping.preset.insert({
+ ["<Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ else
+ fallback()
+ end
+ end, { "i", "s" }),
+ ["<S-Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ else
+ fallback()
+ end
+ end, { "i", "s" }),
+ ["<C-Space>"] = cmp.mapping.complete(),
+ ["<C-e>"] = cmp.mapping.abort(),
+ ["<CR>"] = cmp.mapping.confirm({ select = true }),
+ }),
+ sources = cmp.config.sources({
+ { name = "nvim_lsp" },
+ }, {
+ { name = "buffer" },
+ { name = "path" },
+ }),
+ })
end