From abe81c01b36c70130d79a2dcccc32dac537c19d0 Mon Sep 17 00:00:00 2001 From: FaultyBranches Date: Sat, 23 May 2026 20:28:34 -0500 Subject: [PATCH] feat: A working state during the transfer between the old neovim configurations and using newer built-in functionality in the 0.12.x versions of Neovim. Further work is needed for treesitter updates, cleanup of the conversion work and testing to verify old functionality isn't lessened to get the benefits of a cleaner config and vastly faster load times. --- README.md | 10 +- nvim/init.lua | 8 +- nvim/lua/custom_commands.lua | 2 +- nvim/lua/custom_functions.lua | 7 +- nvim/lua/keymappings.lua | 8 +- nvim/lua/language_support.lua | 77 ++++++++++ nvim/lua/lsp.lua | 8 -- nvim/lua/plugins.lua | 80 ++++++----- nvim/lua/plugins/autopairs.lua | 6 - nvim/lua/plugins/comment.lua | 16 --- nvim/lua/plugins/floaterm.lua | 8 -- nvim/lua/plugins/gitsigns.lua | 94 ++++++------ nvim/lua/plugins/gruvbox.lua | 10 -- nvim/lua/plugins/lspconfig.lua | 39 ----- nvim/lua/plugins/lualine.lua | 37 +++-- nvim/lua/plugins/luasnip.lua | 32 +++-- nvim/lua/plugins/markdown-preview.lua | 15 -- nvim/lua/plugins/mason.lua | 45 +++--- nvim/lua/plugins/nvim-cmp.lua | 128 ++++++++--------- nvim/lua/plugins/render-markdown.lua | 27 ++-- nvim/lua/plugins/telekasten.lua | 77 ++++------ nvim/lua/plugins/telescope.lua | 199 ++++++++------------------ nvim/lua/plugins/treesitter.lua | 103 ++++++------- nvim/lua/plugins/twilight.lua | 38 +++-- nvim/lua/plugins/vim-gitgutter.lua | 3 - nvim/lua/plugins/vim-godot.lua | 4 - nvim/lua/settings.lua | 5 +- nvim/lua/treesitter.lua | 13 ++ 28 files changed, 490 insertions(+), 609 deletions(-) create mode 100644 nvim/lua/language_support.lua delete mode 100644 nvim/lua/lsp.lua delete mode 100644 nvim/lua/plugins/autopairs.lua delete mode 100644 nvim/lua/plugins/comment.lua delete mode 100644 nvim/lua/plugins/floaterm.lua delete mode 100644 nvim/lua/plugins/gruvbox.lua delete mode 100644 nvim/lua/plugins/lspconfig.lua delete mode 100644 nvim/lua/plugins/markdown-preview.lua delete mode 100644 nvim/lua/plugins/vim-gitgutter.lua delete mode 100644 nvim/lua/plugins/vim-godot.lua create mode 100644 nvim/lua/treesitter.lua diff --git a/README.md b/README.md index 52ff373..7a3b596 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,8 @@ The config adds the following settings outside of oh-my-zsh: - User $HOME based `.local/bin` - Keychain initialization for caching SSH keys - Adding a timing function for checking ZSH load timing -- Local specific configuration file loading, with three initial configs: - - `.zsh_aliases`: Aliases for local specific commands - - `.zsh_exports`: Exported variables for a specific system - - `.zsh_functions`: Custom functions - - `.zsh_local`: Local ZSH settings for a specific system such as any environment specific bash required to set up a system's shell or direct ZSH settings +- Split configuration file loading with three main configs and a local override: + - `zsh_aliases`: Aliases for common commands + - `zsh_exports`: Exported variables for the system + - `zsh_functions`: Custom functions beyond simple aliasing can fulfill but not requiring a script + - `zsh_local`: Local ZSH settings for a specific system such as any environment specific bash required to set up a system's shell or direct ZSH settings diff --git a/nvim/init.lua b/nvim/init.lua index d26bbd4..745a0ec 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -42,13 +42,11 @@ -- -- Created: 7/2/2012 --- local vim = vim vim.loader.enable() -require('custom_functions') require('custom_commands') +require('plugins') +require('language_support') +require('autocmds') require('keymappings') require('settings') -require('autocmds') -require('lsp') -require('plugins') diff --git a/nvim/lua/custom_commands.lua b/nvim/lua/custom_commands.lua index 6af6f4d..e3f9ef5 100644 --- a/nvim/lua/custom_commands.lua +++ b/nvim/lua/custom_commands.lua @@ -1,5 +1,5 @@ vim.api.nvim_create_user_command('FindAndReplace', function(opts) -- Update each quickfix location using substitute, update the files to save changes, close the opened buffers and close the quickfix window -- TODO: Does not close the buffers opened through changes - vim.api.nvim_command(string.format('cdo s/%s/%s/g', opts.fargs[1], opts.fargs[2]) .. '| update | cclose') + vim.api.nvim_command(string.format('cfdo s/%s/%s/gc', opts.fargs[1], opts.fargs[2]) .. '| update | cclose') end, { nargs = '*' }) diff --git a/nvim/lua/custom_functions.lua b/nvim/lua/custom_functions.lua index 567aaac..7d9528e 100644 --- a/nvim/lua/custom_functions.lua +++ b/nvim/lua/custom_functions.lua @@ -1,5 +1,6 @@ return { execute = function(type) + -- Mapping of filetypes to commands local command_table = { build = { rust = 'cargo build', @@ -21,11 +22,15 @@ return { cpp = 'make upload', } } + + -- Save the file vim.api.nvim_command('write') + local command = command_table[type][vim.bo.filetype] if command ~= nil then - vim.cmd('FloatermNew --autoclose=0 --height=0.9 --width=0.9 ' .. command) + -- Run command in a new terminal buffer + vim.cmd('terminal ' .. command) end end } diff --git a/nvim/lua/keymappings.lua b/nvim/lua/keymappings.lua index d49ac72..bcd1b42 100644 --- a/nvim/lua/keymappings.lua +++ b/nvim/lua/keymappings.lua @@ -50,6 +50,10 @@ vim.keymap.set('n', 'w', ':set list!', options) -- Folding the section under the cursor vim.keymap.set('n', '', 'za') +-- Comment toggling +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) vim.keymap.set('n', 'er', function() custom_functions.execute('run') end) @@ -57,6 +61,8 @@ vim.keymap.set('n', 'ec', function() custom_functions.execute('compile') vim.keymap.set('n', 'eb', function() custom_functions.execute('benchmark') end) vim.keymap.set('n', 'eu', function() custom_functions.execute('upload') end) +-- Netrw directory exploration vim.keymap.set('n', 'eo', ':Lexplore', options) -vim.keymap.set('n', 'l', ':Lazy', options) +-- Allow for leaving Terminal mode using the escape key instead of the odd default +vim.keymap.set('t', '', '') diff --git a/nvim/lua/language_support.lua b/nvim/lua/language_support.lua new file mode 100644 index 0000000..14cf30b --- /dev/null +++ b/nvim/lua/language_support.lua @@ -0,0 +1,77 @@ +-- 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 +}) + +vim.diagnostic.config({ + underline = true, + virtual_text = { + prefix = "●", + source = 'always', + }, + -- signs = true, + severity_sort = true, + -- update_in_insert = true, + float = { + source = 'always' + } +}) + +-- LSP +vim.pack.add({ + 'https://github.com/neovim/nvim-lspconfig', +}) + +-- Auto set keymaps and other settings on LSP attach +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('my.lsp', {}), + callback = function(args) + -- Native completion + -- local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) + -- local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end + -- client.server_capabilities.completionProvider.triggerCharacters = chars + -- + -- vim.lsp.completion.enable(true, args.data.client_id, args.buf, { + -- autotrigger = true, + -- convert = function(item) + -- local abbr = item.label + -- abbr = abbr:gsub("%b()", ""):gsub("%b{}", "") + -- abbr = abbr:match("[%w_.]+.*") or abbr + -- abbr = #abbr > 20 and abbr:sub(1, 19) .. "..." or abbr + -- + -- return { abbr = abbr } + -- end, + -- }) + + -- Keyboard Mappings + local bufnr = args.buf + + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set('n', '', vim.diagnostic.goto_prev, bufopts) + vim.keymap.set('n', '', vim.diagnostic.goto_next, bufopts) + vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + 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', 'r', vim.lsp.buf.rename, bufopts) + vim.keymap.set('i', '', vim.lsp.completion.get, bufopts) + end, +}) + +-- Enable LSP engines +-- vim.lsp.enable('clangd') +vim.lsp.enable('gdscript') diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp.lua deleted file mode 100644 index b71e050..0000000 --- a/nvim/lua/lsp.lua +++ /dev/null @@ -1,8 +0,0 @@ -vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - underline = true, - virtual_text = true, - signs = true, - update_in_insert = true, - } -) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 48b8fbd..5bf10a7 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -1,41 +1,43 @@ -local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' +require('vim._core.ui2').enable() -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', - lazypath, - }) -end - -vim.opt.rtp:prepend(lazypath) - -require('lazy').setup({ - require('plugins.lspconfig'), -- LSP configuration - require('plugins.mason'), -- LSP and DAP manager - require('plugins.gruvbox'), -- Colorscheme - require('plugins.comment'), -- Simple language specific commenting shortcuts - require('plugins.dap'), -- DAP debugging plugin - require('plugins.dap-python'), -- Debug plugin settings specifically for python - require('plugins.treesitter'), -- Treesitter syntax highlighting and tree support - require('plugins.gitsigns'), -- Gutter symbols for Git status and quick actions for Git operations - require('plugins.luasnip'), -- Snippet engine - -- require('plugins.nvim-lint'), -- Linter loader - require('plugins.nvim-cmp'), -- Autocompletion engine - require('plugins.lualine'), -- Status line - require('plugins.telekasten'), -- Note taking setup - require('plugins.telescope'), -- Floating windows for searching and other operations - 'tpope/vim-surround', -- Change surrounding symbols - require('plugins.floaterm'), -- Floating terminal - require('plugins.vim-godot'), -- Godot specific bindings and debug - -- require('plugins.markdown-preview'), -- Open a preview of markdown rendered in a browser - require('plugins.render-markdown'), -- Render markdown directly in nvim (experimental, may take over for markdown-preview) - require('plugins.autopairs'), -- Autocomplete symbol pairs when typing (experimental) - require('plugins.twilight'), -- Focus mode, dim lines around the current segment of code - require('plugins.yaml-companion'), -- Additional YAML and JSON schema helper - require('plugins.fugitive'), -- _The_ Git integration plugin people have been using forever - -- require('plugins.schemastore'), -- Loads YAML and JSON schemas for autocompletion +-- 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 + +-- 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.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 + + require('nvim-autopairs').setup() +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/autopairs.lua b/nvim/lua/plugins/autopairs.lua deleted file mode 100644 index d878d76..0000000 --- a/nvim/lua/plugins/autopairs.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - 'windwp/nvim-autopairs', - config = function() - require('nvim-autopairs').setup() - end -} diff --git a/nvim/lua/plugins/comment.lua b/nvim/lua/plugins/comment.lua deleted file mode 100644 index df45378..0000000 --- a/nvim/lua/plugins/comment.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - 'numToStr/Comment.nvim', - config = function() - require('Comment').setup { - ignore = '^$', - toggler = { - line = 'gc', - block = '', - }, - } - end, - keys = { - { 'c', ':norm gcc' }, - { 'c', ':norm gc', mode = 'v' }, - } -} diff --git a/nvim/lua/plugins/floaterm.lua b/nvim/lua/plugins/floaterm.lua deleted file mode 100644 index f50504b..0000000 --- a/nvim/lua/plugins/floaterm.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - 'voldikss/vim-floaterm', - keys = { - { 't', ':FloatermToggle myfloat' }, - { '', ':q', mode = 't' }, - }, - lazy = false, -} diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua index 55684af..25435c6 100644 --- a/nvim/lua/plugins/gitsigns.lua +++ b/nvim/lua/plugins/gitsigns.lua @@ -1,52 +1,52 @@ -return { - 'lewis6991/gitsigns.nvim', - config = function() - require('gitsigns').setup { - on_attach = function(bufnr) - local gitsigns = require('gitsigns') +vim.pack.add({ + 'https://github.com/lewis6991/gitsigns.nvim' +}) - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end +require('gitsigns').setup { + on_attach = function(bufnr) + local gitsigns = require('gitsigns') - -- Navigation - map('n', ']c', function() - if vim.wo.diff then - vim.cmd.normal({ ']c', bang = true }) - else - gitsigns.nav_hunk('next') - end - end) + -- TODO: Move to custom functions? + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end - map('n', '[c', function() - if vim.wo.diff then - vim.cmd.normal({ '[c', bang = true }) - else - gitsigns.nav_hunk('prev') - end - end) - - -- Actions - map('n', 'gs', gitsigns.stage_hunk) - 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('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('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', 'gtd', gitsigns.toggle_deleted) - - -- Text object - map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk') + -- Navigation + map('n', ']c', function() + if vim.wo.diff then + vim.cmd.normal({ ']c', bang = true }) + else + gitsigns.nav_hunk('next') end - } - end, + end) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal({ '[c', bang = true }) + else + gitsigns.nav_hunk('prev') + end + end) + + -- Actions + map('n', 'gs', gitsigns.stage_hunk) + 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('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('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', 'gtd', gitsigns.toggle_deleted) + + -- Text object + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk') + end } diff --git a/nvim/lua/plugins/gruvbox.lua b/nvim/lua/plugins/gruvbox.lua deleted file mode 100644 index a25e987..0000000 --- a/nvim/lua/plugins/gruvbox.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - 'sainnhe/gruvbox-material', - config = function() - vim.g.gruvbox_material_enable_italic = true - vim.g.gruvbox_material_background = 'hard' - vim.cmd.colorscheme('gruvbox-material') - end, - lazy = false, - priority = 1000, -} diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua deleted file mode 100644 index 1153706..0000000 --- a/nvim/lua/plugins/lspconfig.lua +++ /dev/null @@ -1,39 +0,0 @@ -return { - 'neovim/nvim-lspconfig', - config = function() - vim.diagnostic.config({ - virtual_text = { - source = 'always', - }, - severity_sort = true, - float = { - source = 'always' - } - }) - - -- Auto set keymaps and other settings on LSP attach - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('my.lsp', {}), - callback = function(args) - local bufnr = args.buf - - -- Keyboard Mappings - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', '', vim.diagnostic.goto_prev, bufopts) - vim.keymap.set('n', '', vim.diagnostic.goto_next, bufopts) - vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - 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', 'r', vim.lsp.buf.rename, bufopts) - end, - }) - - vim.lsp.enable('gdscript') - end -} diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua index 437414f..25f70be 100644 --- a/nvim/lua/plugins/lualine.lua +++ b/nvim/lua/plugins/lualine.lua @@ -6,26 +6,23 @@ local function get_schema() return schema.result[1].name end -return { - 'nvim-lualine/lualine.nvim', - config = function() - require('lualine').setup { - tabline = { - lualine_a = { - 'tabs', - }, - lualine_z = { - 'buffers', - } - }, - sections = { - lualine_x = { - 'encoding', 'fileformat', 'filetype', get_schema - }, - } +vim.pack.add({ + 'https://github.com/nvim-tree/nvim-web-devicons', + 'https://github.com/nvim-lualine/lualine.nvim' +}) + +require('lualine').setup { + tabline = { + lualine_a = { + 'tabs', + }, + lualine_z = { + 'buffers', } - end, - dependencies = { - 'nvim-tree/nvim-web-devicons' }, + sections = { + lualine_x = { + 'encoding', 'fileformat', 'filetype', get_schema + }, + } } diff --git a/nvim/lua/plugins/luasnip.lua b/nvim/lua/plugins/luasnip.lua index 00ac06c..761bc00 100644 --- a/nvim/lua/plugins/luasnip.lua +++ b/nvim/lua/plugins/luasnip.lua @@ -1,12 +1,20 @@ -return { - 'L3MON4D3/LuaSnip', - config = function() - require('luasnip.loaders.from_vscode').lazy_load() - require('luasnip.loaders.from_lua').lazy_load({ paths = "./snippets" }) - end, - dependencies = { - 'saadparwaiz1/cmp_luasnip', -- Wrapper to load snippets in nvim-cmp - 'rafamadriz/friendly-snippets', - }, - build = "make install_jsregexp" -} +vim.pack.add({ + 'https://github.com/saadparwaiz1/cmp_luasnip', + 'https://github.com/rafamadriz/friendly-snippets', + 'https://github.com/L3MON4D3/LuaSnip' +}) + +local luasnip_lua_path = vim.api.nvim_get_runtime_file('lua/luasnip/init.lua', false)[1] +if not luasnip_lua_path then return end +local luasnip_root = vim.fn.fnamemodify(luasnip_lua_path, ':h:h:h') + +vim.api.nvim_create_autocmd('PackChanged', { callback = function(args) + local name, kind = args.data.spec.name, args.data.kind + if name == 'luasnip' and kind == 'update' then + if not args.data.active then vim.cmd.packadd('luasnip') end + vim.system({'make', 'install_jsregexp'}, { cwd = luasnip_root }) + end +end}) + +require('luasnip.loaders.from_vscode').lazy_load() +require('luasnip.loaders.from_lua').lazy_load({ paths = "./snippets" }) diff --git a/nvim/lua/plugins/markdown-preview.lua b/nvim/lua/plugins/markdown-preview.lua deleted file mode 100644 index a014c7c..0000000 --- a/nvim/lua/plugins/markdown-preview.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - 'iamcco/markdown-preview.nvim', - cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' }, - ft = { 'markdown' }, - build = function() - vim.fn['mkdp#util#install']() - end, - keys = { - { - 'md', - ':MarkdownPreviewToggle', - desc = 'Toggles Markdown preview service' - } - }, -} diff --git a/nvim/lua/plugins/mason.lua b/nvim/lua/plugins/mason.lua index 5305398..3935866 100644 --- a/nvim/lua/plugins/mason.lua +++ b/nvim/lua/plugins/mason.lua @@ -1,27 +1,22 @@ -return { - 'mason-org/mason.nvim', - config = function() - require('mason').setup() +vim.pack.add({ + 'https://github.com/mason-org/mason.nvim', + 'https://github.com/mason-org/mason-lspconfig.nvim', +}) - require('mason-lspconfig').setup { - automatic_enable = true, - ensure_installed = { - 'ansiblels', -- Ansible - 'arduino_language_server', -- Arduino specific C - 'bashls', -- Bash - 'clangd', -- C/C++ - 'intelephense', -- PHP - 'lua_ls', -- Lua - 'marksman', -- markdown - 'pylsp', -- Python - 'rust_analyzer', -- Rust - 'ts_ls', -- Typscript - 'yamlls', -- YAML - } - } - end, - dependencies = { - 'mason-org/mason-lspconfig.nvim', - }, - lazy = false, +require('mason').setup() +require('mason-lspconfig').setup { + automatic_enable = true, + ensure_installed = { + 'ansiblels', -- Ansible + 'arduino_language_server', -- Arduino specific C + 'bashls', -- Bash + 'clangd', -- C/C++ + 'intelephense', -- PHP + 'lua_ls', -- Lua + 'marksman', -- markdown + 'pylsp', -- Python + 'rust_analyzer', -- Rust + 'ts_ls', -- Typscript + 'yamlls', -- YAML + } } diff --git a/nvim/lua/plugins/nvim-cmp.lua b/nvim/lua/plugins/nvim-cmp.lua index b7305f1..11f863d 100644 --- a/nvim/lua/plugins/nvim-cmp.lua +++ b/nvim/lua/plugins/nvim-cmp.lua @@ -1,70 +1,66 @@ -return { - 'hrsh7th/nvim-cmp', - config = function() - local cmp = require('cmp') - cmp.setup { - completion = { - completeopt = 'menu,menuone,noinsert', - }, - experimental = { - ghost_text = true, - }, - mapping = { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - }, - formatting = { - format = function(entry, vim_item) - vim_item.menu = ({ - buffer = '[Buf]', - luasnip = '[Snips]', - nvim_lsp = '[LSP]', - nvim_lua = '[Lua]', - })[entry.source.name] - return vim_item - end, - field = { 'abbr', 'kind', 'menu' } - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - { name = 'render-markdown' }, - }, { - { name = 'buffer' }, - }) - } +vim.pack.add({ + 'https://github.com/hrsh7th/nvim-cmp', + 'https://github.com/hrsh7th/cmp-nvim-lsp', + 'https://github.com/hrsh7th/cmp-buffer', + 'https://github.com/hrsh7th/cmp-path', + 'https://github.com/hrsh7th/cmp-cmdline', + 'https://github.com/hrsh7th/cmp-nvim-lua', +}) - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' }, - }, { - { name = 'cmdline' }, - }) - }) +local cmp = require('cmp') - cmp.setup.cmdline({ '/', '?' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } - }) - end, - dependencies = { - { 'hrsh7th/cmp-nvim-lsp', lazy = false }, - { 'hrsh7th/cmp-buffer', lazy = false }, - { 'hrsh7th/cmp-path', lazy = false }, - { 'hrsh7th/cmp-cmdline', lazy = false }, - { 'L3MON4D3/LuaSnip', lazy = false }, +cmp.setup { + completion = { + completeopt = 'menu,menuone,noinsert', }, - event = 'InsertEnter', - lazy = false, + experimental = { + ghost_text = true, + }, + mapping = { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }), + }, + formatting = { + format = function(entry, vim_item) + vim_item.menu = ({ + buffer = '[Buf]', + luasnip = '[Snips]', + nvim_lsp = '[LSP]', + nvim_lua = '[Lua]', + })[entry.source.name] + return vim_item + end, + field = { 'abbr', 'kind', 'menu' } + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + { name = 'render-markdown' }, + }, { + { name = 'buffer' }, + }) } + +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' }, + }, { + { name = 'cmdline' }, + }) +}) + +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) diff --git a/nvim/lua/plugins/render-markdown.lua b/nvim/lua/plugins/render-markdown.lua index 89482a0..dd2295e 100644 --- a/nvim/lua/plugins/render-markdown.lua +++ b/nvim/lua/plugins/render-markdown.lua @@ -1,14 +1,13 @@ -return { - 'meanderingprogrammer/render-markdown.nvim', - config = function() - require('render-markdown').setup({ - enabled = true, - render_modes = { 'n', 'c', 't' }, - max_file_size = 10.0, - file_types = { - 'markdown', - 'telekasten' - }, - }) - end, -} +vim.pack.add({ + 'https://github.com/meanderingprogrammer/render-markdown.nvim' +}) + +require('render-markdown').setup({ + enabled = true, + render_modes = { 'n', 'c', 't' }, + max_file_size = 10.0, + file_types = { + 'markdown', + 'telekasten' + }, +}) diff --git a/nvim/lua/plugins/telekasten.lua b/nvim/lua/plugins/telekasten.lua index eb8b47c..1b70238 100644 --- a/nvim/lua/plugins/telekasten.lua +++ b/nvim/lua/plugins/telekasten.lua @@ -2,58 +2,31 @@ function string.insert(str1, str2, pos) return str1:sub(1, pos) .. str2 .. str1:sub(pos + 1) end --- function ToggleTODO(current_line) - -- local todo_str = '%- %[ %] ' - -- local todo_checked_str = '%- %[x%] ' +vim.pack.add({ + 'https://github.com/renerocksai/telekasten.nvim' +}) - -- if current_line:find(todo_str, 1) then - -- return string.gsub(current_line, todo_str, '', 1) - -- elseif current_line:find(todo_checked_str, 1) then - -- return string.gsub(current_line, todo_checked_str, '', 1) - -- else - -- local first_idx = current_line:find('[%-%w]', 1) - 1 - -- return string.insert(current_line, '- [ ] ', first_idx) - -- end --- end +local home = vim.fn.expand('~/.zettelkasten') +require('telekasten').setup({ + home = home, + dailies = home .. '/' .. 'daily', + weeklies = home .. '/' .. 'weeklies', + templates = home .. '/' .. 'templates', + template_new_note = home .. '/' .. 'templates/new_note.md', + template_new_daily = home .. '/' .. 'templates/daily.md', + template_new_weekly = home .. '/' .. 'templates/weekly.md', + command_palette_theme = 'ivy', + show_tags_theme = 'get_cursor', + plug_into_calendar = false, +}) --- vim.api.nvim_create_user_command('ToggleTODO', function() - -- local current_line = vim.api.nvim_get_current_line() - -- local row, _ = unpack(vim.api.nvim_win_get_cursor(0)) +-- Color for telekasten syntax +vim.api.nvim_set_hl(0, 'tkLink', { ctermfg = 72, cterm = { bold = true, underdouble = true }, fg = '#689d6a', bold = true, underdouble = true }) +vim.api.nvim_set_hl(0, 'tkBrackets', { ctermfg = 'gray', fg = 'gray' }) +vim.api.nvim_set_hl(0, 'tkTag', { ctermfg = 'gray', fg = 'gray' }) - -- local new_line = ToggleTODO(current_line) - - -- vim.api.nvim_buf_set_lines(0, row - 1, row, true, { new_line }) --- end, {}) - -return { - 'renerocksai/telekasten.nvim', - config = function() - local home = vim.fn.expand('~/.zettelkasten') - require('telekasten').setup({ - home = home, - dailies = home .. '/' .. 'daily', - weeklies = home .. '/' .. 'weeklies', - templates = home .. '/' .. 'templates', - template_new_note = home .. '/' .. 'templates/new_note.md', - template_new_daily = home .. '/' .. 'templates/daily.md', - template_new_weekly = home .. '/' .. 'templates/weekly.md', - command_palette_theme = 'ivy', - show_tags_theme = 'get_cursor', - plug_into_calendar = false, - - }) - - -- Color for telekasten syntax - vim.api.nvim_set_hl(0, 'tkLink', { ctermfg = 72, cterm = { bold = true, underdouble = true }, fg = '#689d6a', bold = true, underdouble = true }) - vim.api.nvim_set_hl(0, 'tkBrackets', { ctermfg = 'gray', fg = 'gray' }) - vim.api.nvim_set_hl(0, 'tkTag', { ctermfg = 'gray', fg = 'gray' }) - end, - keys = { - { 'zt', ':Telekasten toggle_todo' }, - { 'zfn', ':Telekasten find_notes' }, - { 'zft', ':Telekasten show_tags' }, - { 'zn', ':Telekasten new_note' }, - { 'zp', ':Telekasten panel' }, - }, - lazy = false -} +vim.keymap.set('n', 'zt', ':Telekasten toggle_todo') +vim.keymap.set('n', 'zf', ':Telekasten find_notes') +vim.keymap.set('n', 'zn', ':Telekasten new_note') +vim.keymap.set('n', 'zp', ':Telekasten panel') +vim.keymap.set('n', 'zT', ':Telekasten goto_today') diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index f59f9a9..70d9db8 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -1,148 +1,63 @@ -return { - 'nvim-telescope/telescope.nvim', - config = function(_, opts) - local telescope = require('telescope') - local actions = require('telescope.actions') - local action_state = require('telescope.actions.state') - local fb_actions = telescope.extensions.file_browser.actions +vim.pack.add({ + 'https://github.com/kevinhwang91/nvim-bqf', + 'https://github.com/nvim-telescope/telescope-file-browser.nvim', + 'https://github.com/nvim-lua/plenary.nvim', + 'https://github.com/nvim-telescope/telescope.nvim', +}) - opts.defaults = { - file_ignore_patterns = { - '.png$', - '.jpg$', - '.jpeg$', - '.ico$', - '.icns$', - '.webp$', - '.uproject$', - '-workspace$', - '.git/', - '.node_modules/', - 'node_modules', +require('telescope').setup { + defaults = { + file_ignore_patterns = { + '.png$', + '.jpg$', + '.jpeg$', + '.ico$', + '.icns$', + '.webp$', + '.uproject$', + '-workspace$', + '.git/', + '.node_modules/', + 'node_modules', + }, + layout_config = { prompt_position = 'bottom' }, + -- layout_strategy = 'vertical', + mappings = { + i = { + [''] = require('telescope.actions').close, }, - layout_config = { prompt_position = 'bottom' }, - layout_strategy = 'vertical', - mappings = { - i = { - [''] = actions.close, - }, - }, - prompt_prefix = '  ', - results_title = false, - selection_caret = '➤ ', - sorting_strategy = 'ascending', - winblend = 0, - } - - opts.pickers = { - diagnostics = { - -- theme = 'ivy', - initial_mode = 'normal', - layout_config = { - preview_cutoff = 9999, - }, - }, - } - - opts.extensions = { - file_browser = { - theme = 'dropdown', - hijack_netrw = true, - mappings = { - ['n'] = { - ['N'] = fb_actions.create, - ['h'] = fb_actions.goto_parent_dir, - }, - }, - }, - } - - telescope.setup(opts) - telescope.load_extension('file_browser') - end, - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope-file-browser.nvim', - 'kevinhwang91/nvim-bqf', + }, + prompt_prefix = '  ', + results_title = false, + selection_caret = '➤ ', + sorting_strategy = 'ascending', + winblend = 0, }, - keys = { - { - ';f', - function() - require('telescope.builtin').find_files({ - no_ignore = false, - hidden = true, - }) - end, - }, - { - ';r', - function() - require('telescope.builtin').live_grep() - end, - }, - { - ';b', - function() - require('telescope.builtin').buffers() - end, - }, - { - ';h', - function() - require('telescope.builtin').help_tags() - end, - }, - { - ';;', - function() - require('telescope.builtin').resume() - end, - }, - { - ';d', - function() - require('telescope.builtin').diagnostics() - end, - }, - { - ';t', - function() - require('telescope.builtin').treesitter() - end, - }, - { - ';s', - function() - require('telescope.builtin').lsp_document_symbols() - end - }, - { - ';w', - function() - require('telescope.builtin').lsp_dynamic_workspace_symbols() - end - }, - { - ';e', - function() - local telescope = require('telescope') - - local function telescope_buffer_dir() - return vim.fn.expand('%:p:h') - end - - telescope.extensions.file_browser.file_browser({ - path = '%:p:h', - cwd = telescope_buffer_dir(), - respect_gitignore = false, - hidden = true, - grouped = true, - previewer = false, - initial_mode = 'normal', - layout_config = { height = 40 }, - }) - end, + pickers = { + diagnostics = { + -- theme = 'ivy', + initial_mode = 'normal', + layout_config = { + preview_cutoff = 9999, + }, }, }, } + +local builtin = require('telescope.builtin') + +vim.keymap.set('n', ';f', function() + builtin.find_files({ + no_ignore = false, + hidden = true, + }) +end) + +vim.keymap.set('n', ';r', function() builtin.live_grep() end) +vim.keymap.set('n', ';b', function() builtin.buffers() end) +vim.keymap.set('n', ';h', function() builtin.help_tags() end) +vim.keymap.set('n', ';;', function() builtin.resume() end) +vim.keymap.set('n', ';d', function() builtin.diagnostics() end) +vim.keymap.set('n', ';t', function() builtin.treesitter() end) +vim.keymap.set('n', ';s', function() builtin.lsp_document_symbols() end) +vim.keymap.set('n', ';w', function() builtin.lsp_dynamic_workspace_symbols() end) diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index 2145aa2..738e335 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -1,50 +1,55 @@ -return { - 'nvim-treesitter/nvim-treesitter', - build = function() - require('nvim-treesitter.install').update({ with_sync = true }) - end, - config = function() - 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.pack.add({ + 'https://github.com/nvim-treesitter/nvim-treesitter' +}) - vim.treesitter.language.register('markdown', 'telekasten') - end, -} +-- 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 262c64a..8c6d7ce 100644 --- a/nvim/lua/plugins/twilight.lua +++ b/nvim/lua/plugins/twilight.lua @@ -1,21 +1,19 @@ -return { - 'folke/twilight.nvim', - config = function() - require('twilight').setup({ - dimming = { - alpha = 0.3, - }, - context = 6, - treesitter = true, - expand = { - "function", - "method", - "table", - "if_statement", - } - }) - end, - keys = { - { 'f', ':Twilight' } +vim.pack.add({ + 'https://github.com/folke/twilight.nvim' +}) + +require('twilight').setup({ + dimming = { + alpha = 0.3, + }, + context = 6, + treesitter = true, + expand = { + "function", + "method", + "table", + "if_statement", } -} +}) + +vim.keymap.set('n', 'f', ':Twilight') diff --git a/nvim/lua/plugins/vim-gitgutter.lua b/nvim/lua/plugins/vim-gitgutter.lua deleted file mode 100644 index c01d5d6..0000000 --- a/nvim/lua/plugins/vim-gitgutter.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - 'airblade/vim-gitgutter' -} diff --git a/nvim/lua/plugins/vim-godot.lua b/nvim/lua/plugins/vim-godot.lua deleted file mode 100644 index 31f2722..0000000 --- a/nvim/lua/plugins/vim-godot.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - 'habamax/vim-godot', - ft = 'gdscript', -} diff --git a/nvim/lua/settings.lua b/nvim/lua/settings.lua index 94874f6..cb97a31 100644 --- a/nvim/lua/settings.lua +++ b/nvim/lua/settings.lua @@ -1,6 +1,9 @@ +-- Experimental +-- vim.o.autocomplete = true + vim.opt.background = 'dark' -- Force a dark background for the colorscheme vim.opt.clipboard = 'unnamed,unnamedplus' -- Use both the "*" and "+" registers for yanks and deletes (puts things in the system clipboard) -vim.opt.completeopt = 'menu,menuone,noinsert' -- Change how the completion menu is interacted with +vim.opt.completeopt = 'fuzzy,menuone,noinsert,popup' -- Change how the completion menu is interacted with and displays vim.opt.cursorcolumn = true -- Highlight the column the cursor is on vim.opt.cursorline = true -- Highlight the line the cursor is on. vim.opt.expandtab = true -- Expand tabs into spaces diff --git a/nvim/lua/treesitter.lua b/nvim/lua/treesitter.lua new file mode 100644 index 0000000..e590cc3 --- /dev/null +++ b/nvim/lua/treesitter.lua @@ -0,0 +1,13 @@ +-- 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 +})