From 1a924cb0b24ba5799b3c4d5b550d940cfeb1a9df Mon Sep 17 00:00:00 2001 From: Alec Goncharow Date: Sun, 9 Feb 2025 10:54:12 -0500 Subject: many things. --- .config/nvim/lua/autocomplete.lua | 16 ++++++----- .config/nvim/lua/lsp.lua | 13 ++++++++- .config/nvim/lua/lspsaga_conf.lua | 2 +- .config/nvim/lua/mappings.lua | 58 +++++++++++++++++++++++++++++++-------- .config/nvim/lua/plugins.lua | 32 ++++++++++++++++++++- .config/nvim/lua/treesitter.lua | 2 +- 6 files changed, 101 insertions(+), 22 deletions(-) (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/autocomplete.lua b/.config/nvim/lua/autocomplete.lua index 1de4271..7746750 100644 --- a/.config/nvim/lua/autocomplete.lua +++ b/.config/nvim/lua/autocomplete.lua @@ -1,6 +1,7 @@ -- Set up nvim-cmp. local cmp = require 'cmp' + cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine @@ -11,11 +12,12 @@ cmp.setup({ -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. end, }, - experimental = { - ghost_text = { - hl_group = "CmpGhostText", - }, - }, + -- can't figure this out, could be cool if ghost text actually took on different color + -- experimental = { + -- ghost_text = { + -- hl_group = "CmpGhostText", + -- }, + -- }, window = { completion = cmp.config.window.bordered({ border = 'none' }), documentation = cmp.config.window.bordered({ border = 'none' }), @@ -24,7 +26,7 @@ cmp.setup({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [''] = cmp.mapping.abort(), + [''] = cmp.mapping.complete(), }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, @@ -37,7 +39,7 @@ cmp.setup({ { name = 'buffer' }, }), completion = { - autocomplete = false + autocomplete = false, } }) diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index e70ce07..3178a5d 100644 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -58,7 +58,6 @@ local lspconfig = require('lspconfig') lspconfig.zls.setup({ on_attach = on_attach, capabilities = capabilities, - }) lspconfig.bashls.setup({ @@ -160,6 +159,18 @@ end lspconfig.jails.setup({}) vim.filetype.add({ extension = { jai = "jai", } }) +lspconfig.ols.setup({ + on_attach = on_attach, + capabilities = capabilities, + init_options = { + enable_references = true, + enable_rename = true, + enable_semantic_tokens = true, + enable_checker_only_saved = true, + enable_inlay_hints = true, + } +}) + vim.api.nvim_create_autocmd('BufWritePre', { pattern = '*.go', callback = function() diff --git a/.config/nvim/lua/lspsaga_conf.lua b/.config/nvim/lua/lspsaga_conf.lua index 73d5695..b31aeff 100644 --- a/.config/nvim/lua/lspsaga_conf.lua +++ b/.config/nvim/lua/lspsaga_conf.lua @@ -88,7 +88,7 @@ require('lspsaga').setup({ }, }) -Nmap('', ':Lspsaga outline') +Nmap('', ':Lspsaga outline') -- Nmap('', ':Lspsaga show_buf_diagnostics') Nmap('', ':Lspsaga show_buf_diagnostics') Nmap('', ':Lspsaga code_action') diff --git a/.config/nvim/lua/mappings.lua b/.config/nvim/lua/mappings.lua index 838ba4f..e6c34ca 100644 --- a/.config/nvim/lua/mappings.lua +++ b/.config/nvim/lua/mappings.lua @@ -25,20 +25,56 @@ function Tmap(shortcut, command) Map('t', shortcut, command) end ---- pane nav -Nmap("", ":wincmd k") -Nmap("", ":wincmd j") -Nmap("", ":wincmd h") -Nmap("", ":wincmd l") +-- pane nav +Nmap("u", ":wincmd k") +Nmap("e", ":wincmd j") +Nmap("n", ":wincmd h") +Nmap("i", ":wincmd l") ---- pane resize -Nmap("_", ":resize -1") -Nmap("+", ":resize +1") +-- -- pane resize +-- Nmap("_", ":resize -1") +-- Nmap("+", ":resize +1") -- pane spawn -Nmap("t", ':split:wincmd j:term') -Nmap("s", ':vs:wincmd l') -Nmap("", ':only') +Nmap("t", ':split:wincmd j:term') +Nmap("s", ':vs:wincmd l') +Nmap("wo", ':only') -- escape terminal mode easier Tmap('', '') + + +-- yoinked from https://github.com/dycw/dotfiles/blob/master/nvim/lua/keymaps.lua +local function merge_tables(t1, t2) + local result = {} + for key, value in pairs(t1) do + result[key] = value + end + for key, value in pairs(t2) do + result[key] = value + end + return result +end + +local keymap_opts = { noremap = true, silent = true } + +local keymap_set = function(mode, lhs, rhs, desc) + vim.keymap.set(mode, lhs, rhs, merge_tables(keymap_opts, { desc = desc })) +end +-- command +keymap_set("n", ";", ":", "Command") + +-- global marks +local prefixes = "m'" +local letters = "abcdefghijklmnopqrstuvwxyz" +for i = 1, #prefixes do + local prefix = prefixes:sub(i, i) + for j = 1, #letters do + local lower_letter = letters:sub(j, j) + local upper_letter = string.upper(lower_letter) + keymap_set({ "n", "v" }, prefix .. lower_letter, prefix .. upper_letter, "Mark " .. upper_letter) + end +end + +-- paste in insert mode +keymap_set("i", "", "p", "Paste") diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 44a7294..0a72469 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -46,7 +46,7 @@ return require('lazy').setup({ 'scrooloose/nerdcommenter', -- commenting shortcuts 'tpope/vim-eunuch', -- wrappers UNIX commands - 'tpope/vim-surround', -- surround characters shortcuts + --'tpope/vim-surround', -- surround characters shortcuts 'tpope/vim-endwise', -- wisely add 'tpope/vim-repeat', -- repeat for plugins -- 'tpope/vim-vinegar', -- make explore better @@ -88,6 +88,9 @@ return require('lazy').setup({ -- jai 'rluba/jai.vim', + -- Odin + 'Tetralux/odin.vim', + 'johmsalas/text-case.nvim', -- integer base conversions @@ -116,5 +119,32 @@ return require('lazy').setup({ vim.g.lsp_zero_extend_cmp = 0 vim.g.lsp_zero_extend_lspconfig = 0 end, + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { + keywords = { + FIX = { + icon = " ", -- icon used for the sign, and in search results + color = "error", -- can be a hex color, or a named color (see below) + alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords + -- signs = false, -- configure signs for some keywords individually + }, + TODO = { icon = " ", color = "info", alt = { "nocheckin" } }, + HACK = { icon = " ", color = "warning" }, + WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } }, + PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + NOTE = { icon = " ", color = "hint", alt = { "INFO" } }, + TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } }, + }, + } + }, + + -- movement + 'ggandor/leap.nvim', + { + "chentoast/marks.nvim", + event = "VeryLazy", + opts = { + }, }, }) diff --git a/.config/nvim/lua/treesitter.lua b/.config/nvim/lua/treesitter.lua index cbf7d0c..ce17c70 100644 --- a/.config/nvim/lua/treesitter.lua +++ b/.config/nvim/lua/treesitter.lua @@ -1,6 +1,6 @@ require 'nvim-treesitter.configs'.setup { -- A list of parser names, or "all" - ensure_installed = { "rust", "c", "lua", "vim", "zig", "go" }, + ensure_installed = { "rust", "c", "lua", "vim", "zig", "go", "odin" }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = false, -- cgit v1.2.3-70-g09d2