From a587e16f1f9823f8ed3c6c5e742f8dab90673fc4 Mon Sep 17 00:00:00 2001 From: FaultyBranches Date: Tue, 26 May 2026 05:28:54 -0500 Subject: [PATCH] feat: Adding a bunch of changes to move further towards a clean and more builtin setup rather than relying upon plugins. --- nvim/init.lua | 1 - nvim/lua/autocmds.lua | 2 +- nvim/lua/custom_commands.lua | 4 + nvim/lua/keymappings.lua | 4 +- nvim/lua/plugins.lua | 51 +++--- nvim/lua/plugins/dap.lua | 189 ++++++++------------ nvim/lua/plugins/gitsigns.lua | 12 +- nvim/lua/plugins/gruvbox.lua | 8 + nvim/lua/{ => plugins}/language_support.lua | 21 +-- nvim/lua/plugins/nvim-cmp.lua | 2 +- nvim/lua/plugins/treesitter.lua | 55 ------ nvim/lua/plugins/twilight.lua | 3 +- nvim/lua/plugins/yaml-companion.lua | 15 +- nvim/lua/settings.lua | 3 + nvim/lua/treesitter.lua | 13 -- 15 files changed, 137 insertions(+), 246 deletions(-) create mode 100644 nvim/lua/plugins/gruvbox.lua rename nvim/lua/{ => plugins}/language_support.lua (80%) delete mode 100644 nvim/lua/plugins/treesitter.lua delete mode 100644 nvim/lua/treesitter.lua diff --git a/nvim/init.lua b/nvim/init.lua index 745a0ec..6bc0772 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -46,7 +46,6 @@ vim.loader.enable() require('custom_commands') require('plugins') -require('language_support') require('autocmds') require('keymappings') require('settings') diff --git a/nvim/lua/autocmds.lua b/nvim/lua/autocmds.lua index c9ee26f..30969e1 100644 --- a/nvim/lua/autocmds.lua +++ b/nvim/lua/autocmds.lua @@ -3,7 +3,7 @@ vim.api.nvim_create_autocmd({ 'BufReadPre' }, { pattern = '*', group = vim.api.nvim_create_augroup('largefile', { clear = true }), callback = function(args) - local max_filesize_MiB = 2 + local max_filesize_MiB = 1 local _, stats = pcall(function() return vim.loop.fs_stat(vim.api.nvim_buf_get_name(args.buf)) diff --git a/nvim/lua/custom_commands.lua b/nvim/lua/custom_commands.lua index e3f9ef5..4202426 100644 --- a/nvim/lua/custom_commands.lua +++ b/nvim/lua/custom_commands.lua @@ -3,3 +3,7 @@ vim.api.nvim_create_user_command('FindAndReplace', function(opts) -- TODO: Does not close the buffers opened through changes vim.api.nvim_command(string.format('cfdo s/%s/%s/gc', opts.fargs[1], opts.fargs[2]) .. '| update | cclose') end, { nargs = '*' }) + +--vim.api.nvim_create_user_command('TSI', function (opts) +-- +--end) diff --git a/nvim/lua/keymappings.lua b/nvim/lua/keymappings.lua index bcd1b42..b16bb8a 100644 --- a/nvim/lua/keymappings.lua +++ b/nvim/lua/keymappings.lua @@ -51,8 +51,8 @@ vim.keymap.set('n', 'w', ':set list!', options) vim.keymap.set('n', '', 'za') -- Comment toggling -vim.keymap.set('n', 'c', 'gcc', {remap=true}) -vim.keymap.set('v', 'c', 'gc', {remap=true}) +vim.keymap.set('n', 'c', 'gcc', { remap = true }) +vim.keymap.set('v', 'c', 'gc', { remap = true }) -- Keymaps for custom functions vim.keymap.set('n', 'et', function() custom_functions.execute('test') end) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 5bf10a7..58323a6 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -1,43 +1,34 @@ -require('vim._core.ui2').enable() +require('vim._core.ui2').enable() -- message + cmdline presentation layer replacement -- Load the following plugins eagerly to prevent visual oddities -vim.pack.add({ - 'https://github.com/sainnhe/gruvbox-material', -}) - -vim.g.gruvbox_material_enable_italic = true -vim.g.gruvbox_material_background = 'hard' -vim.g.gruvbox_material_better_performance = 1 -vim.cmd.colorscheme('gruvbox-material') - -require('plugins.lualine') -- Status line plugin +require('plugins.gruvbox') -- Colorscheme setup +require('plugins.lualine') -- Status line plugin -- vim.schedule defers plugin loading for after the main loop starts -- Startup is cleaner and faster than ever -vim.schedule(function () - require('plugins.gitsigns') -- Git gutter notifiers - require('plugins.nvim-cmp') -- Autocompletion plugin (TODO: Move to builtin completion?) - require('plugins.telescope') -- Floating window fuzzy searching different sources - require('plugins.telekasten') -- Note taking plugins - require('plugins.mason') -- LSP and DAP manager - require('plugins.twilight') -- Focus mode, dim lines around the cursor's location - require('plugins.render-markdown') -- Render markdown directly in neovim - require('plugins.luasnip') -- Snippet engine - require('plugins.treesitter') -- Syntax highlighting and tree support +vim.schedule(function() + require('plugins.language_support') -- LSP, treesitter and any other language specific support plugins + require('plugins.gitsigns') -- Git gutter notifiers + require('plugins.nvim-cmp') -- Autocompletion plugin (TODO: Move to builtin completion?) + require('plugins.telescope') -- Floating window fuzzy searching different sources + require('plugins.telekasten') -- Note taking plugins + require('plugins.mason') -- LSP and DAP manager + require('plugins.twilight') -- Focus mode, dim lines around the cursor's location + require('plugins.render-markdown') -- Render markdown directly in neovim + require('plugins.luasnip') -- Snippet engine - vim.pack.add({'https://github.com/windwp/nvim-autopairs'}) -- Autocomplete symbol pairs when typing - vim.pack.add({'https://github.com/tpope/vim-surround'}) -- Change surrounding characters (doesn't need setup called) - vim.pack.add({'https://github.com/habamax/vim-godot'}) -- Godot specific bindings and debug + vim.pack.add({ 'https://github.com/windwp/nvim-autopairs' }) -- Autocomplete symbol pairs when typing + vim.pack.add({ 'https://github.com/tpope/vim-surround' }) -- Change surrounding characters (doesn't need setup called) + vim.pack.add({ 'https://github.com/tpope/vim-fugitive' }) -- _The_ Git integration plugin people have been using forever + vim.pack.add({ 'https://github.com/habamax/vim-godot' }) -- Godot specific bindings and debug - require('nvim-autopairs').setup() + require('nvim-autopairs').setup() -- Automatic pair completion of paranteticals, braces, quotes, etc. + require('plugins.dap') -- DAP debugging plugin + require('plugins.dap-python') -- Debug plugin settings specifically for python + require('plugins.yaml-companion') -- Additional YAML and JSON schema helper end) -- TODO: Still in need of translation to the new setup --- require('plugins.dap'), -- DAP debugging plugin --- require('plugins.dap-python'), -- Debug plugin settings specifically for python --- require('plugins.yaml-companion'), -- Additional YAML and JSON schema helper -- Currently not enabled -- require('plugins.nvim-lint'), -- Linter loader --- require('plugins.fugitive'), -- _The_ Git integration plugin people have been using forever --- require('plugins.schemastore'), -- Loads YAML and JSON schemas for autocompletion diff --git a/nvim/lua/plugins/dap.lua b/nvim/lua/plugins/dap.lua index ab42709..35cdc48 100644 --- a/nvim/lua/plugins/dap.lua +++ b/nvim/lua/plugins/dap.lua @@ -1,78 +1,69 @@ -return { - 'mfussenegger/nvim-dap', - dependencies = { - { 'jay-babu/mason-nvim-dap.nvim' }, - { 'nvim-neotest/nvim-nio' }, +vim.pack.add({ + 'https://github.com/rcarriga/nvim-dap-ui', + 'https://github.com/mfussenegger/nvim-dap', + 'https://github.com/nvim-neotest/nvim-nio', + 'https://github.com/theHamsta/nvim-dap-virtual-text', +}) + +require('dapui').setup({ + mappings = { + open = 'o', + remove = 'd', + edit = 'e', + repl = 'r', + toggle = 't', + }, + layouts = { { - 'rcarriga/nvim-dap-ui', - config = function() - require('dapui').setup({ - mappings = { - open = 'o', - remove = 'd', - edit = 'e', - repl = 'r', - toggle = 't', - }, - layouts = { - { - elements = { - 'scopes', - 'breakpoints', - 'stacks', - }, - size = 0.33, - position = 'right', - }, - { - elements = { - 'console', - 'watches', - }, - size = 0.2, - position = 'bottom', - }, - }, - floating = { - max_height = nil, - max_width = nil, - border = 'single', - mappings = { - close = { 'q', '' }, - }, - }, - windows = { - indent = 1 - }, - render = { - max_type_length = nil, - }, - }) - end, + elements = { + 'scopes', + 'breakpoints', + 'stacks', + }, + size = 0.33, + position = 'right', }, { - 'theHamsta/nvim-dap-virtual-text', - config = function() - require('nvim-dap-virtual-text').setup() - end, + elements = { + 'console', + 'watches', + }, + size = 0.2, + position = 'bottom', }, }, - config = function() - local mason_dap = require('mason-nvim-dap') + floating = { + max_height = nil, + max_width = nil, + border = 'single', + mappings = { + close = { 'q', '' }, + }, + }, + windows = { + indent = 1 + }, + render = { + max_type_length = nil, + }, +}) + +require('nvim-dap-virtual-text').setup() + -- local mason_dap = require('mason-nvim-dap') local dap, dapui = require('dap'), require('dapui') - mason_dap.setup({ - ensure_installed = { - 'codelldb', - 'debugpy', - }, - automatic_installation = true, - handlers = { - function(config) - require('mason-nvim-dap').default_setup(config) - end, - } - }) + -- mason_dap.setup({ + -- ensure_installed = { + -- 'codelldb', + -- 'debugpy', + -- }, + -- automatic_installation = true, + -- handlers = { + -- function(config) + -- require('mason-nvim-dap').default_setup(config) + -- end, + -- } + -- }) dap.listeners.before.attach.dapui_config = function() dapui.open() @@ -136,53 +127,15 @@ return { } } } - end, - keys = { - { - 'b', - function() require('dap').toggle_breakpoint() end, - desc = 'DAP: Toggle Breakpoint', - }, - { - 'B', - function() require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, - desc = 'DAP: Set conditional breakpoint', - }, - { - 'dh', - function() require('dap.ui.widgets').hover() end, - mode = { 'n', 'v' }, - desc = 'DAP: Debug hover', - }, - { - '', - function() require('dap').continue() end, - desc = 'DAP: Continue', - }, - { - '', - function() require('dap').run_to_cursor() end, - desc = 'DAP: Run to cursor', - }, - { - '', - function() require('dap').terminate() end, - desc = 'DAP: Terminate debug session', - }, - { - '', - function() require('dap').step_over() end, - desc = 'DAP: Step Over', - }, - { - '', - function() require('dap').step_into() end, - desc = 'DAP: Step Into', - }, - { - '', - function() require('dap').step_out() end, - desc = 'DAP: Step Out', - }, - }, -} + +vim.keymap.set('n', 'b', function () + require('dap').toggle_breakpoint() +end) +vim.keymap.set('n', 'B', function() require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) end) +vim.keymap.set({'n', 'v'}, 'dh', function() require('dap.ui.widgets').hover() end) +vim.keymap.set('n', '', function() require('dap').continue() end) +vim.keymap.set('n', '', function() require('dap').run_to_cursor() end) +vim.keymap.set('n', '', function() require('dap').terminate() end) +vim.keymap.set('n', '', function() require('dap').step_over() end) +vim.keymap.set('n', '', function() require('dap').step_into() end) +vim.keymap.set('n', '', function() require('dap').step_out() end) diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua index 25435c6..8957fc2 100644 --- a/nvim/lua/plugins/gitsigns.lua +++ b/nvim/lua/plugins/gitsigns.lua @@ -31,19 +31,19 @@ require('gitsigns').setup { end) -- Actions - map('n', 'gs', gitsigns.stage_hunk) + map('n', 'gs', gitsigns.stage_hunk) -- TODO: Overlaps with LSP keymappings map('n', 'gu', gitsigns.undo_stage_hunk) - map('n', 'gr', gitsigns.reset_hunk) - map('v', 'gs', function() gitsigns.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end) + map('n', 'gr', gitsigns.reset_hunk) -- TODO: Overlaps with LSP keymappings + map('v', 'gs', function() gitsigns.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end) -- TODO: Overlaps with LSP keymappings map('v', 'gu', function() gitsigns.undo_stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end) - map('v', 'gr', function() gitsigns.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end) + map('v', 'gr', function() gitsigns.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end) -- TODO: Overlaps with LSP keymappings map('n', 'gS', gitsigns.stage_buffer) map('n', 'gR', gitsigns.reset_buffer) map('n', 'gp', gitsigns.preview_hunk) map('n', 'gb', function() gitsigns.blame_line { full = true } end) map('n', 'gtb', gitsigns.toggle_current_line_blame) - map('n', 'gd', gitsigns.diffthis) - map('n', 'gD', function() gitsigns.diffthis('~') end) + map('n', 'gd', gitsigns.diffthis) -- TODO: Overlaps with LSP keymappings + map('n', 'gD', function() gitsigns.diffthis('~') end) -- TODO: Overlaps with LSP keymappings map('n', 'gtd', gitsigns.toggle_deleted) -- Text object diff --git a/nvim/lua/plugins/gruvbox.lua b/nvim/lua/plugins/gruvbox.lua new file mode 100644 index 0000000..aef1547 --- /dev/null +++ b/nvim/lua/plugins/gruvbox.lua @@ -0,0 +1,8 @@ +vim.pack.add({ + 'https://github.com/sainnhe/gruvbox-material', +}) + +vim.g.gruvbox_material_enable_italic = true +vim.g.gruvbox_material_background = 'hard' +vim.g.gruvbox_material_better_performance = 1 +vim.cmd.colorscheme('gruvbox-material') diff --git a/nvim/lua/language_support.lua b/nvim/lua/plugins/language_support.lua similarity index 80% rename from nvim/lua/language_support.lua rename to nvim/lua/plugins/language_support.lua index 14cf30b..63c5c33 100644 --- a/nvim/lua/language_support.lua +++ b/nvim/lua/plugins/language_support.lua @@ -1,14 +1,16 @@ -- Treesitter --- def tsi [parser: string] { --- let tree = $"($env.HOME)/.local/share/nvim/site" --- luarocks $"--tree=($tree)" install $"tree-sitter-($parser)" --- } +local rocks_path = os.getenv('HOME') .. "/.luarocks/lib/luarocks/rocks-5.1" -local rocks_path = vim.fn.stdpath("data") .. "/site/lib/luarocks/rocks-5.1" +-- Pick up the installed +for _, parser_dir in ipairs(vim.fn.glob(rocks_path .. '/tree-sitter-*/*/', true, true)) do + vim.opt.runtimepath:prepend(parser_dir) +end +-- Start treesitter parsing on the current buffer vim.api.nvim_create_autocmd("FileType", { - callback = function (args) - pcall(vim.treesitter.start, args.buf) + callback = function(ev) + -- Use pcall to prevent blocking errors + pcall(vim.treesitter.start, ev.buf) end }) @@ -18,15 +20,14 @@ vim.diagnostic.config({ prefix = "●", source = 'always', }, - -- signs = true, severity_sort = true, - -- update_in_insert = true, float = { source = 'always' } }) -- LSP +-- TODO: test out removing the lspconfig plugin and using the built-in enablement vim.pack.add({ 'https://github.com/neovim/nvim-lspconfig', }) @@ -66,7 +67,7 @@ vim.api.nvim_create_autocmd('LspAttach', { vim.keymap.set('n', 'gs', vim.lsp.buf.signature_help, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) + vim.keymap.set('n', 'for', function() vim.lsp.buf.format { async = true } end, bufopts) vim.keymap.set('n', 'r', vim.lsp.buf.rename, bufopts) vim.keymap.set('i', '', vim.lsp.completion.get, bufopts) end, diff --git a/nvim/lua/plugins/nvim-cmp.lua b/nvim/lua/plugins/nvim-cmp.lua index 11f863d..d9bfbc3 100644 --- a/nvim/lua/plugins/nvim-cmp.lua +++ b/nvim/lua/plugins/nvim-cmp.lua @@ -21,7 +21,7 @@ cmp.setup { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), + [''] = cmp.mapping.complete(), -- TODO: Overlaps with completion(? possibly doesn't due to state) [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true, diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index 738e335..0000000 --- a/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,55 +0,0 @@ -vim.pack.add({ - 'https://github.com/nvim-treesitter/nvim-treesitter' -}) - --- require('nvim-treesitter.configs').setup { --- auto_install = true, --- ensure_installed = { --- 'c', --- 'c_sharp', --- 'comment', --- 'css', --- 'gdscript', --- 'gitignore', --- 'html', --- 'java', --- 'javascript', --- 'json', --- 'lua', --- 'markdown', --- 'markdown_inline', --- 'python', --- 'query', --- 'rust', --- 'sql', --- 'tera', --- 'toml', --- 'tsx', --- 'typescript', --- 'yaml', --- }, --- highlight = { --- enable = true, --- additional_vim_regex_highlighting = false, --- }, --- incremental_selection = { --- enable = true, --- }, --- indent = { --- enable = true, --- }, --- rainbow = { --- enable = true, --- } --- } - -vim.treesitter.language.register('markdown', 'telekasten') - --- return { --- 'nvim-treesitter/nvim-treesitter', --- build = function() --- require('nvim-treesitter.install').update({ with_sync = true }) --- end, --- config = function() --- end, --- } diff --git a/nvim/lua/plugins/twilight.lua b/nvim/lua/plugins/twilight.lua index 8c6d7ce..566021f 100644 --- a/nvim/lua/plugins/twilight.lua +++ b/nvim/lua/plugins/twilight.lua @@ -1,3 +1,4 @@ +-- Focus plugin that 'dims' lines around the current block/line vim.pack.add({ 'https://github.com/folke/twilight.nvim' }) @@ -16,4 +17,4 @@ require('twilight').setup({ } }) -vim.keymap.set('n', 'f', ':Twilight') +vim.keymap.set('n', 'foc', ':Twilight') diff --git a/nvim/lua/plugins/yaml-companion.lua b/nvim/lua/plugins/yaml-companion.lua index 63f4d65..796f403 100644 --- a/nvim/lua/plugins/yaml-companion.lua +++ b/nvim/lua/plugins/yaml-companion.lua @@ -1,8 +1,7 @@ -return { - 'mosheavni/yaml-companion.nvim', - config = function(_, opts) - local cfg = require('yaml-companion').setup(opts) - vim.lsp.config('yamlls', cfg) - vim.lsp.enable('yamlls') - end, -} +vim.pack.add({ + 'https://github.com/mosheavni/yaml-companion.nvim' +}) + +local cfg = require('yaml-companion').setup() +vim.lsp.config('yamlls', cfg) +vim.lsp.enable('yamlls') diff --git a/nvim/lua/settings.lua b/nvim/lua/settings.lua index cb97a31..7baa31f 100644 --- a/nvim/lua/settings.lua +++ b/nvim/lua/settings.lua @@ -37,3 +37,6 @@ vim.opt.undodir = os.getenv('HOME') .. '/.config/nvim/undodir' -- Set a spe vim.opt.undofile = true -- Enable undo files vim.opt.updatetime = 50 -- Update time in milliseconds vim.opt.wrap = false -- Do _not_ wrap lines + +vim.g.netrw_liststyle = 3 -- Use the tree style display for netrw directory listings +vim.g.netrw_winsize = 25 -- Percentage based pane size for directory exploring diff --git a/nvim/lua/treesitter.lua b/nvim/lua/treesitter.lua deleted file mode 100644 index e590cc3..0000000 --- a/nvim/lua/treesitter.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Treesitter --- def tsi [parser: string] { --- let tree = $"($env.HOME)/.local/share/nvim/site" --- luarocks $"--tree=($tree)" install $"tree-sitter-($parser)" --- } - -local rocks_path = vim.fn.stdpath("data") .. "/site/lib/luarocks/rocks-5.1" - -vim.api.nvim_create_autocmd("FileType", { - callback = function (args) - pcall(vim.treesitter.start, args.buf) - end -})