From 25cf1e91e83ffc0dcea4301b44d330915b012aa3 Mon Sep 17 00:00:00 2001 From: Ian Roddis <31021769+iroddis@users.noreply.github.com> Date: Wed, 6 May 2026 12:20:14 -0300 Subject: [PATCH] Refactoring --- init.lua | 422 +-------------------------- lua/custom/plugins/init.lua | 5 - lua/iroddis/cfg_conform.lua | 19 ++ lua/iroddis/cfg_slime.lua | 10 + lua/iroddis/cfg_telescope.lua | 17 ++ lua/iroddis/cmatches.lua | 56 ++++ lua/iroddis/init.lua | 10 + lua/iroddis/lazy.lua | 48 +++ lua/iroddis/lsp.lua | 44 +++ lua/iroddis/remaps.lua | 35 +++ lua/iroddis/set.lua | 65 +++++ lua/kickstart/plugins/autoformat.lua | 74 ----- lua/kickstart/plugins/debug.lua | 87 ------ 13 files changed, 305 insertions(+), 587 deletions(-) delete mode 100644 lua/custom/plugins/init.lua create mode 100644 lua/iroddis/cfg_conform.lua create mode 100644 lua/iroddis/cfg_slime.lua create mode 100644 lua/iroddis/cfg_telescope.lua create mode 100644 lua/iroddis/cmatches.lua create mode 100644 lua/iroddis/init.lua create mode 100644 lua/iroddis/lazy.lua create mode 100644 lua/iroddis/lsp.lua create mode 100644 lua/iroddis/remaps.lua create mode 100644 lua/iroddis/set.lua delete mode 100644 lua/kickstart/plugins/autoformat.lua delete mode 100644 lua/kickstart/plugins/debug.lua diff --git a/init.lua b/init.lua index 088fb4a..862b5c0 100644 --- a/init.lua +++ b/init.lua @@ -1,430 +1,10 @@ --- [[ NOTE: ]] Must happen before plugins are required (otherwise wrong leader will be used) -vim.g.mapleader = ',' -vim.g.maplocalleader = ',' - --- [[ Install `lazy.nvim` plugin manager ]] -local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then - vim.fn.system { - 'git', - 'clone', - '--filter=blob:none', - 'https://github.com/folke/lazy.nvim.git', - '--branch=stable', -- latest stable release - lazypath, - } -end -vim.opt.rtp:prepend(lazypath) - --- [[ Configure plugins ]] -require('lazy').setup({ - -- Git related plugins - 'junegunn/vim-easy-align', -- Nice alignment - 'jpalardy/vim-slime', -- Send text from buffer to a tmux pane - 'neovim/nvim-lspconfig', -- LSP - 'stevearc/conform.nvim', -- Autoformatting - 'tanvirtin/monokai.nvim', -- Theme - 'lewis6991/gitsigns.nvim', -- Nice git annotations - 'nvim-treesitter/nvim-treesitter', - { 'nvim-mini/mini.nvim', version = '*' }, - - -- Fuzzy Finder (files, lsp, etc) - { - 'nvim-telescope/telescope.nvim', - version = '*', - dependencies = { - 'nvim-lua/plenary.nvim', - -- optional but recommended - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, - }, - }, - -- Marks management - { - 'chentoast/marks.nvim', - event = 'VeryLazy', - opts = { - builtin_marks = { '<', '>', '{', '}' }, - }, - }, -}, {}) - -local servers = {} -for _, dir in ipairs(vim.api.nvim_get_runtime_file('lsp', true)) do - for name, type in vim.fs.dir(dir) do - if (type == 'file' or type == 'link') and name:sub(-4) == '.lua' then - servers[name:sub(1, -5)] = true -- dedupe across runtimepath entries - end - end -end -vim.lsp.enable(vim.tbl_keys(servers)) - --- [[ Setting options ]] --- vim.opt.autocomplete = true -- Autoindent -vim.opt.autocomplete = true -vim.opt.ai = true -- Autoindent -vim.opt.updatetime = 50 -vim.opt.mouse = '' -vim.opt.ttimeoutlen = 1000 -vim.opt.ttimeout = true --- vim.opt.ttimeoutlen = 0 -- Leader timeout (default 50) - --- Whitespace -vim.opt.tabstop = 2 -vim.opt.softtabstop = 2 -vim.opt.shiftwidth = 2 -vim.opt.expandtab = true - --- Search -vim.opt.ignorecase = true -vim.opt.incsearch = true -vim.opt.hlsearch = false -vim.opt.smartcase = true - --- Display -vim.opt.nu = true -vim.opt.wrap = false -vim.opt.termguicolors = false -vim.opt.scrolloff = 8 -vim.opt.signcolumn = 'yes' -vim.opt.foldlevel = 99 -vim.opt.foldmethod = 'expr' -vim.opt.wildmode = 'longest:full' - --- swap -vim.opt.swapfile = false -vim.opt.backup = false -vim.opt.undodir = os.getenv 'HOME' .. '/tmp/vim.undo' -vim.opt.undofile = true - --- Sync clipboard between OS and Neovim. --- Remove this option if you want your OS clipboard to remain independent. --- See `:help 'clipboard'` --- vim.o.clipboard = 'unnamedplus' - --- Enable break indent -vim.o.breakindent = true - --- Keep signcolumn on by default -vim.wo.signcolumn = 'yes' - --- Decrease update time -vim.o.updatetime = 250 -vim.o.timeoutlen = 300 - --- Set completeopt to have a better completion experience -vim.o.completeopt = 'menuone,noselect' - --- NOTE: You should make sure your terminal supports this -vim.o.termguicolors = true - --- [[ Basic Keymaps ]] - --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) - --- Remap for dealing with word wrap -vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) - --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - -vim.keymap.set('n', ',', ':w!') -vim.keymap.set('n', 'qq', ':qa!') -vim.keymap.set('n', "'", vim.cmd.tabn) -vim.keymap.set('n', ';', vim.cmd.tabp) -vim.keymap.set('n', '', ':tabe ') -vim.keymap.set('n', '', vim.diagnostic.goto_next) -vim.keymap.set('n', '', vim.diagnostic.goto_prev) -vim.keymap.set('n', 'r', ':%s/\\s*$//') - --- Moving code!! --- vim.keymap.set('v', 'J', ":m '>+1gv=gv") --- vim.keymap.set('v', 'K', ":m '<-2gv=gv") --- vim.keymap.set('x', 'o', '"_dP') - --- System copy/paste -vim.keymap.set('n', 'y', '"+y') -vim.keymap.set('v', 'y', '"+y') -vim.keymap.set('n', 'y', '"+Y') -vim.keymap.set('n', 'Y', ':.w! ~/.vimpaste') -vim.keymap.set('v', 'Y', ':w! ~/.vimpaste') -vim.keymap.set('n', 'P', ':r ~/.vimpaste') - -vim.api.nvim_create_autocmd('FileType', { - pattern = { 'markdown' }, - callback = function(_) - vim.keymap.set('n', 'f', '{!}fmt -p 150') - vim.keymap.set('v', 'f', ':!fmt -p 150') - end, -}) +require 'iroddis' require('monokai').setup { palette = require('monokai').ristretto } --- [[ Configure Telescope ]] --- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { - defaults = { - mappings = { - i = { - [''] = false, - [''] = false, - }, - }, - }, -} - -require('mini.snippets').setup {} -require('mini.keymap').setup {} -require('mini.icons').setup {} -require('mini.completion').setup {} - --- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') - --- Formatting -require('conform').setup { - formatters_by_ft = { - elixir = { 'mix' }, - heex = { 'mix' }, - go = { 'gofmt' }, - javascript = { 'prettier' }, - lua = { 'stylua' }, - python = { 'black' }, - rust = { 'rustfmt', lsp_format = 'fallback' }, - cpp = { 'clang-format' }, - }, - format_on_save = { - -- These options will be passed to conform.format() - timeout_ms = 500, - lsp_format = 'fallback', - }, -} - --- Telescope live_grep in git root --- Function to find the git root directory based on the current buffer's path -local function find_git_root() - -- Use the current buffer's path as the starting point for the git search - local current_file = vim.api.nvim_buf_get_name(0) - local current_dir - local cwd = vim.fn.getcwd() - -- If the buffer is not associated with a file, return nil - if current_file == '' then - current_dir = cwd - else - -- Extract the directory from the current file's path - current_dir = vim.fn.fnamemodify(current_file, ':h') - end - - -- Find the Git root directory from the current file's path - local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] - if vim.v.shell_error ~= 0 then - print 'Not a git repository. Searching on current working directory' - return cwd - end - return git_root -end - --- Custom live_grep function to search in git root -local function live_grep_git_root() - local git_root = find_git_root() - if git_root then - require('telescope.builtin').live_grep { - search_dirs = { git_root }, - } - end -end - -vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) - --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', function() - -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { - winblend = 10, - previewer = false, - }) -end, { desc = '[/] Fuzzily search in current buffer' }) - -local function telescope_live_grep_open_files() - require('telescope.builtin').live_grep { - grep_open_files = true, - prompt_title = 'Live Grep in Open Files', - } -end -vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) -vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) - --- This function gets run when an LSP connects to a particular buffer. -local on_attach = function(_, bufnr) - -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself - -- many times. - -- - -- In this case, we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. - 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('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', function() - vim.lsp.buf.code_action { context = { only = { 'quickfix', 'refactor', 'source' } } } - end, '[C]ode [A]ction') - - nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') - - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') - - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, { desc = 'Format current buffer with LSP' }) -end - -vim.g.slime_target = 'tmux' - -vim.keymap.set('n', '', 'SlimeLineSend') -vim.keymap.set('v', '', "SlimeRegionSend'>") -vim.keymap.set('n', 'v', ':SlimeConfig') - -vim.api.nvim_create_autocmd('FileType', { - pattern = 'python', - callback = function() - vim.g.slime_python_ipython = 1 - end, -}) - --- vim.api.nvim_create_autocmd('FileType', { --- pattern = '*', --- callback = function() --- vim.treesitter.start() --- end, --- }) - -vim.api.nvim_create_autocmd('FileType', { - group = vim.api.nvim_create_augroup('tree-sitter-enable', { clear = true }), - callback = function(args) - local lang = vim.treesitter.language.get_lang(args.match) - if not lang or not vim.treesitter.language.add(lang) then - return - end - - if vim.treesitter.query.get(lang, 'highlights') then - vim.treesitter.start(args.buf) - end - - if vim.treesitter.query.get(lang, 'indents') then - vim.opt_local.indentexpr = 'v:lua.require("nvim-treesitter").indentexpr()' - end - - if vim.treesitter.query.get(lang, 'folds') then - vim.opt_local.foldmethod = 'expr' - vim.opt_local.foldexpr = 'v:lua.vim.treesitter.foldexpr()' - end - end, -}) - vim.keymap.set('n', 'ga', ':EasyAlign') vim.keymap.set('v', 'ga', ':EasyAlign') -local builtin = require 'telescope.builtin' -vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', '', builtin.git_files, {}) -vim.keymap.set('n', 'ps', function() - builtin.grep_string { search = vim.fn.input 'Grep > ' } -end) - --- Define a function to highlight the current search term -local highlight_search_term = function(label) - local search_term = vim.fn.getreg '/' - if search_term ~= '' then - -- local matches = - vim.fn.matchadd(label, search_term) - -- for match_id in matches do - -- vim.api.nvim_buf_add_highlight(0, -1, label, 0, match_id[1] - 1, match_id[2]) - -- end - end -end - -vim.keymap.set('n', 'm1', function() - highlight_search_term 'Matchadd_1' -end) -vim.keymap.set('n', 'm2', function() - highlight_search_term 'Matchadd_2' -end) -vim.keymap.set('n', 'm3', function() - highlight_search_term 'Matchadd_3' -end) -vim.keymap.set('n', 'm4', function() - highlight_search_term 'Matchadd_4' -end) -vim.keymap.set('n', 'm5', function() - highlight_search_term 'Matchadd_5' -end) -vim.keymap.set('n', 'mc', function() - vim.fn.clearmatches() -end) - -local colors = { - base03 = '#002b36', - base02 = '#073642', - base01 = '#586e75', - base00 = '#657b83', - base0 = '#839496', - base1 = '#93a1a1', - base2 = '#eee8d5', - base3 = '#fdf6e3', - yellow = '#b58900', - orange = '#cb4b16', - red = '#dc322f', - magenta = '#d33682', - violet = '#6c71c4', - blue = '#268bd2', - cyan = '#2aa198', - green = '#859900', -} - -vim.api.nvim_set_hl(0, 'Matchadd_1', { bg = colors.blue, fg = 0 }) -vim.api.nvim_set_hl(0, 'Matchadd_2', { bg = colors.violet, fg = 0 }) -vim.api.nvim_set_hl(0, 'Matchadd_3', { bg = colors.cyan, fg = 0 }) -vim.api.nvim_set_hl(0, 'Matchadd_4', { bg = colors.red, fg = 0 }) -vim.api.nvim_set_hl(0, 'Matchadd_5', { bg = colors.orange, fg = 0 }) -vim.api.nvim_set_hl(0, 'Matchadd_6', { bg = colors.yellow, fg = 0 }) - -- Because nvim filetypes are stupid ... need to disable formatoptions for all file types vim.api.nvim_create_autocmd('FileType', { pattern = '*', diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index be0eb9d..0000000 --- a/lua/custom/plugins/init.lua +++ /dev/null @@ -1,5 +0,0 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) --- --- See the kickstart.nvim README for more information -return {} diff --git a/lua/iroddis/cfg_conform.lua b/lua/iroddis/cfg_conform.lua new file mode 100644 index 0000000..7375e21 --- /dev/null +++ b/lua/iroddis/cfg_conform.lua @@ -0,0 +1,19 @@ +-- Formatting +require('conform').setup { + formatters_by_ft = { + elixir = { 'mix' }, + heex = { 'mix' }, + go = { 'gofmt' }, + javascript = { 'prettier' }, + lua = { 'stylua' }, + python = { 'black' }, + rust = { 'rustfmt', lsp_format = 'fallback' }, + cpp = { 'clang-format' }, + }, + format_on_save = { + -- These options will be passed to conform.format() + timeout_ms = 500, + lsp_format = 'fallback', + }, +} + diff --git a/lua/iroddis/cfg_slime.lua b/lua/iroddis/cfg_slime.lua new file mode 100644 index 0000000..5fd5aba --- /dev/null +++ b/lua/iroddis/cfg_slime.lua @@ -0,0 +1,10 @@ +vim.g.slime_target = 'tmux' +vim.keymap.set('n', '', 'SlimeLineSend') +vim.keymap.set('v', '', "SlimeRegionSend'>") +vim.keymap.set('n', 'v', ':SlimeConfig') +vim.api.nvim_create_autocmd('FileType', { + pattern = 'python', + callback = function() + vim.g.slime_python_ipython = 1 + end, +}) diff --git a/lua/iroddis/cfg_telescope.lua b/lua/iroddis/cfg_telescope.lua new file mode 100644 index 0000000..e844dea --- /dev/null +++ b/lua/iroddis/cfg_telescope.lua @@ -0,0 +1,17 @@ +require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + }, +} +pcall(require('telescope').load_extension, 'fzf') +vim.api.nvim_create_autocmd('FileType', { + pattern = '*', + callback = function() + vim.keymap.set('n', 'gd', require('telescope.builtin').lsp_definitions, { buffer = bufnr, desc = '[G]oto [D]efinition' }) + end, +}) diff --git a/lua/iroddis/cmatches.lua b/lua/iroddis/cmatches.lua new file mode 100644 index 0000000..042039e --- /dev/null +++ b/lua/iroddis/cmatches.lua @@ -0,0 +1,56 @@ +-- Define a function to highlight the current search term +local highlight_search_term = function(label) + local search_term = vim.fn.getreg '/' + if search_term ~= '' then + -- local matches = + vim.fn.matchadd(label, search_term) + -- for match_id in matches do + -- vim.api.nvim_buf_add_highlight(0, -1, label, 0, match_id[1] - 1, match_id[2]) + -- end + end +end + +vim.keymap.set('n', 'm1', function() + highlight_search_term 'Matchadd_1' +end) +vim.keymap.set('n', 'm2', function() + highlight_search_term 'Matchadd_2' +end) +vim.keymap.set('n', 'm3', function() + highlight_search_term 'Matchadd_3' +end) +vim.keymap.set('n', 'm4', function() + highlight_search_term 'Matchadd_4' +end) +vim.keymap.set('n', 'm5', function() + highlight_search_term 'Matchadd_5' +end) +vim.keymap.set('n', 'mc', function() + vim.fn.clearmatches() +end) + +local colors = { + base03 = '#002b36', + base02 = '#073642', + base01 = '#586e75', + base00 = '#657b83', + base0 = '#839496', + base1 = '#93a1a1', + base2 = '#eee8d5', + base3 = '#fdf6e3', + yellow = '#b58900', + orange = '#cb4b16', + red = '#dc322f', + magenta = '#d33682', + violet = '#6c71c4', + blue = '#268bd2', + cyan = '#2aa198', + green = '#859900', +} + +vim.api.nvim_set_hl(0, 'Matchadd_1', { bg = colors.blue, fg = 0 }) +vim.api.nvim_set_hl(0, 'Matchadd_2', { bg = colors.violet, fg = 0 }) +vim.api.nvim_set_hl(0, 'Matchadd_3', { bg = colors.cyan, fg = 0 }) +vim.api.nvim_set_hl(0, 'Matchadd_4', { bg = colors.red, fg = 0 }) +vim.api.nvim_set_hl(0, 'Matchadd_5', { bg = colors.orange, fg = 0 }) +vim.api.nvim_set_hl(0, 'Matchadd_6', { bg = colors.yellow, fg = 0 }) diff --git a/lua/iroddis/init.lua b/lua/iroddis/init.lua new file mode 100644 index 0000000..7b73970 --- /dev/null +++ b/lua/iroddis/init.lua @@ -0,0 +1,10 @@ +-- require("iroddis.remaps") +-- require("iroddis.packer") +require 'iroddis.set' +require 'iroddis.lazy' +require 'iroddis.lsp' +require 'iroddis.cmatches' + +require 'iroddis.cfg_conform' +require 'iroddis.cfg_slime' +require 'iroddis.cfg_telescope' diff --git a/lua/iroddis/lazy.lua b/lua/iroddis/lazy.lua new file mode 100644 index 0000000..33176c1 --- /dev/null +++ b/lua/iroddis/lazy.lua @@ -0,0 +1,48 @@ +-- [[ Install `lazy.nvim` plugin manager ]] +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', -- latest stable release + lazypath, + } +end +vim.opt.rtp:prepend(lazypath) + +-- require 'custom' + +-- [[ Configure plugins ]] +require('lazy').setup({ + -- Git related plugins + 'junegunn/vim-easy-align', -- Nice alignment + 'jpalardy/vim-slime', -- Send text from buffer to a tmux pane + 'neovim/nvim-lspconfig', -- LSP + 'stevearc/conform.nvim', -- Autoformatting + 'tanvirtin/monokai.nvim', -- Theme + 'lewis6991/gitsigns.nvim', -- Nice git annotations + 'nvim-treesitter/nvim-treesitter', + -- { 'nvim-mini/mini.nvim', version = '*' }, + + { 'nvim-mini/mini.nvim', version = '*' }, + -- Fuzzy Finder (files, lsp, etc) + { + 'nvim-telescope/telescope.nvim', + version = '*', + dependencies = { + 'nvim-lua/plenary.nvim', + -- optional but recommended + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + }, + }, + -- Marks management + { + 'chentoast/marks.nvim', + event = 'VeryLazy', + opts = { + builtin_marks = { '<', '>', '{', '}' }, + }, + }, +}, {}) diff --git a/lua/iroddis/lsp.lua b/lua/iroddis/lsp.lua new file mode 100644 index 0000000..7e1545f --- /dev/null +++ b/lua/iroddis/lsp.lua @@ -0,0 +1,44 @@ +local servers = {} +for _, dir in ipairs(vim.api.nvim_get_runtime_file('lsp', true)) do + for name, type in vim.fs.dir(dir) do + if (type == 'file' or type == 'link') and name:sub(-4) == '.lua' then + servers[name:sub(1, -5)] = true -- dedupe across runtimepath entries + end + end +end + +vim.lsp.enable({ +'ansiblels', +'arduino_language_server', +'asm_lsp', +'ast_grep', +'awk_ls', +'bashls', +'clangd', +'cmake', +'cssls', +'css_variables', +'ctags_lsp', +'elixirls', +'eslint', +'fish_lsp', +'gleam', +'golangci_lint_ls', +'gopls', +'graphql', +'html', +'htmx', +'janet_lsp', +'jsonls', +'julials', +'just', +'lua_ls', +'nginx_language_server', +'ruff', +'rust_analyzer', +'systemd_lsp', +'tailwindcss', +'ty', +'vimls', +'ziggy' +}) diff --git a/lua/iroddis/remaps.lua b/lua/iroddis/remaps.lua new file mode 100644 index 0000000..bcc4a28 --- /dev/null +++ b/lua/iroddis/remaps.lua @@ -0,0 +1,35 @@ +-- Keymaps for better default experience +-- See `:help vim.keymap.set()` +vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +vim.keymap.set('n', ',', ':w!') +vim.keymap.set('n', 'qq', ':qa!') +vim.keymap.set('n', "'", vim.cmd.tabn) +vim.keymap.set('n', ';', vim.cmd.tabp) +vim.keymap.set('n', '', ':tabe ') +vim.keymap.set('n', '', vim.diagnostic.goto_next) +vim.keymap.set('n', '', vim.diagnostic.goto_prev) +vim.keymap.set('n', 'r', ':%s/\\s*$//') + +-- Moving code!! +-- vim.keymap.set('v', 'J', ":m '>+1gv=gv") +-- vim.keymap.set('v', 'K', ":m '<-2gv=gv") +-- vim.keymap.set('x', 'o', '"_dP') + +-- System copy/paste +vim.keymap.set('n', 'y', '"+y') +vim.keymap.set('v', 'y', '"+y') +vim.keymap.set('n', 'y', '"+Y') +vim.keymap.set('n', 'Y', ':.w! ~/.vimpaste') +vim.keymap.set('v', 'Y', ':w! ~/.vimpaste') +vim.keymap.set('n', 'P', ':r ~/.vimpaste') diff --git a/lua/iroddis/set.lua b/lua/iroddis/set.lua new file mode 100644 index 0000000..276d8f5 --- /dev/null +++ b/lua/iroddis/set.lua @@ -0,0 +1,65 @@ +-- [[ NOTE: ]] Must happen before plugins are required (otherwise wrong leader will be used) +vim.g.mapleader = ',' +vim.g.maplocalleader = ',' + +vim.opt.autocomplete = true +vim.opt.ai = true -- Autoindent +vim.opt.updatetime = 50 +vim.opt.mouse = '' +vim.opt.ttimeoutlen = 1000 +vim.opt.ttimeout = true +-- vim.opt.ttimeoutlen = 0 -- Leader timeout (default 50) + +-- Whitespace +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true + +-- Search +vim.opt.ignorecase = true +vim.opt.incsearch = true +vim.opt.hlsearch = false +vim.opt.smartcase = true + +-- Display +vim.opt.nu = true +vim.opt.wrap = false +vim.opt.termguicolors = false +vim.opt.scrolloff = 8 +vim.opt.signcolumn = 'yes' +vim.opt.foldlevel = 99 +vim.opt.foldmethod = 'expr' +vim.opt.wildmode = 'longest:full' + +-- swap +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv 'HOME' .. '/tmp/vim.undo' +vim.opt.undofile = true + +-- Sync clipboard between OS and Neovim. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +-- vim.o.clipboard = 'unnamedplus' + +vim.o.breakindent = true +vim.wo.signcolumn = 'yes' +vim.o.updatetime = 250 +vim.o.timeoutlen = 300 +vim.o.completeopt = 'menuone,noselect' +vim.o.termguicolors = true +-- Because nvim filetypes are stupid ... need to disable formatoptions for all file types +vim.api.nvim_create_autocmd('FileType', { + pattern = '*', + callback = function() + vim.opt.formatoptions:remove 'r' + vim.opt.formatoptions:remove 'o' + end, +}) + +-- Disable change-detection if in diff mode. Allows for diffs involving redirects +-- eg nvim -d <(cmd 1) <(cmd 2) +if vim.diff then + vim.opt.autoread = false +end diff --git a/lua/kickstart/plugins/autoformat.lua b/lua/kickstart/plugins/autoformat.lua deleted file mode 100644 index bc56b15..0000000 --- a/lua/kickstart/plugins/autoformat.lua +++ /dev/null @@ -1,74 +0,0 @@ --- autoformat.lua --- --- Use your language server to automatically format your code on save. --- Adds additional commands as well to manage the behavior - -return { - 'neovim/nvim-lspconfig', - config = function() - -- Switch for controlling whether you want autoformatting. - -- Use :KickstartFormatToggle to toggle autoformatting on or off - local format_is_enabled = true - vim.api.nvim_create_user_command('KickstartFormatToggle', function() - format_is_enabled = not format_is_enabled - print('Setting autoformatting to: ' .. tostring(format_is_enabled)) - end, {}) - - -- Create an augroup that is used for managing our formatting autocmds. - -- We need one augroup per client to make sure that multiple clients - -- can attach to the same buffer without interfering with each other. - local _augroups = {} - local get_augroup = function(client) - if not _augroups[client.id] then - local group_name = 'kickstart-lsp-format-' .. client.name - local id = vim.api.nvim_create_augroup(group_name, { clear = true }) - _augroups[client.id] = id - end - - return _augroups[client.id] - end - - -- Whenever an LSP attaches to a buffer, we will run this function. - -- - -- See `:help LspAttach` for more information about this autocmd event. - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), - -- This is where we attach the autoformatting for reasonable clients - callback = function(args) - local client_id = args.data.client_id - local client = vim.lsp.get_client_by_id(client_id) - local bufnr = args.buf - - -- Only attach to clients that support document formatting - if not client.server_capabilities.documentFormattingProvider then - return - end - - -- Tsserver usually works poorly. Sorry you work with bad languages - -- You can remove this line if you know what you're doing :) - if client.name == 'tsserver' then - return - end - - -- Create an autocmd that will run *before* we save the buffer. - -- Run the formatting command for the LSP that has just attached. - vim.api.nvim_create_autocmd('BufWritePre', { - group = get_augroup(client), - buffer = bufnr, - callback = function() - if not format_is_enabled then - return - end - - vim.lsp.buf.format { - async = false, - filter = function(c) - return c.id == client.id - end, - } - end, - }) - end, - }) - end, -} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua deleted file mode 100644 index 7fc783f..0000000 --- a/lua/kickstart/plugins/debug.lua +++ /dev/null @@ -1,87 +0,0 @@ --- debug.lua --- --- Shows how to use the DAP plugin to debug your code. --- --- Primarily focused on configuring the debugger for Go, but can --- be extended to other languages as well. That's why it's called --- kickstart.nvim and not kitchen-sink.nvim ;) - -return { - -- NOTE: Yes, you can install new plugins here! - 'mfussenegger/nvim-dap', - -- NOTE: And you can specify dependencies as well - dependencies = { - -- Creates a beautiful debugger UI - 'rcarriga/nvim-dap-ui', - - -- Installs the debug adapters for you - 'williamboman/mason.nvim', - 'jay-babu/mason-nvim-dap.nvim', - - -- Add your own debuggers here - 'leoluz/nvim-dap-go', - }, - config = function() - local dap = require 'dap' - local dapui = require 'dapui' - - require('mason-nvim-dap').setup { - -- Makes a best effort to setup the various debuggers with - -- reasonable debug configurations - automatic_setup = true, - - -- You can provide additional configuration to the handlers, - -- see mason-nvim-dap README for more information - handlers = {}, - - -- You'll need to check that you have the required things installed - -- online, please don't ask me how to install them :) - ensure_installed = { - -- Update this to ensure that you have the debuggers for the langs you want - 'delve', - }, - } - - -- Basic debugging keymaps, feel free to change to your liking! - vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) - vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) - vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) - vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) - vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) - vim.keymap.set('n', 'B', function() - dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, { desc = 'Debug: Set Breakpoint' }) - - -- Dap UI setup - -- For more information, see |:help nvim-dap-ui| - dapui.setup { - -- Set icons to characters that are more likely to work in every terminal. - -- Feel free to remove or use ones that you like more! :) - -- Don't feel like these are good choices. - icons = { expanded = '▾', collapsed = '▸', current_frame = '*' }, - controls = { - icons = { - pause = '⏸', - play = '▶', - step_into = '⏎', - step_over = '⏭', - step_out = '⏮', - step_back = 'b', - run_last = '▶▶', - terminate = '⏹', - disconnect = '⏏', - }, - }, - } - - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) - - dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close - - -- Install golang specific config - require('dap-go').setup() - end, -}