diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..b4cde646 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..a6218fed --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.stylua.toml b/.stylua.toml index 139e9397..b14df1da 100755 --- a/.stylua.toml +++ b/.stylua.toml @@ -1,6 +1,11 @@ -column_width = 160 +column_width = 120 line_endings = "Unix" indent_type = "Spaces" indent_width = 2 +call_parentheses = "Always" quote_style = "AutoPreferSingle" -call_parentheses = "None" +collapse_simple_statement = "Never" + +[sort_requires] +enabled = false + diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua new file mode 100644 index 00000000..4f922be7 --- /dev/null +++ b/after/ftplugin/c.lua @@ -0,0 +1,5 @@ +vim.opt_local.expandtab = true +vim.opt_local.tabstop = 4 +vim.opt_local.shiftwidth = 10 +vim.opt_local.softtabstop = 4 +vim.opt_local.formatoptions:remove('o') diff --git a/after/ftplugin/crontab.lua b/after/ftplugin/crontab.lua new file mode 100644 index 00000000..d152a34b --- /dev/null +++ b/after/ftplugin/crontab.lua @@ -0,0 +1 @@ +vim.opt_local.fixeol = false diff --git a/after/ftplugin/dockerfile.lua b/after/ftplugin/dockerfile.lua new file mode 100644 index 00000000..7307b615 --- /dev/null +++ b/after/ftplugin/dockerfile.lua @@ -0,0 +1,2 @@ +vim.opt_local.expandtab = true +vim.opt_local.shiftwidth = 2 diff --git a/after/ftplugin/go.lua b/after/ftplugin/go.lua new file mode 100644 index 00000000..cd6a645d --- /dev/null +++ b/after/ftplugin/go.lua @@ -0,0 +1,10 @@ +-- Set buffer-local options for Go files +vim.opt_local.expandtab = true +vim.opt_local.commentstring = '// %s' +vim.opt_local.comments = 's1:/*,mb:*,ex:*/,://' + +-- Define a key mapping to trigger Go debugging +vim.keymap.set('n', 'td', function() + require('dap-go').debug_test() +end, { buffer = 0 }) -- Set buffer-local key mapping + diff --git a/after/ftplugin/lua.lua b/after/ftplugin/lua.lua new file mode 100644 index 00000000..b3842696 --- /dev/null +++ b/after/ftplugin/lua.lua @@ -0,0 +1,10 @@ +vim.opt.expandtab = true +vim.opt.shiftwidth = 2 +vim.opt.tabstop = 2 +vim.opt.expandtab = true + +vim.opt_local.formatoptions:remove('o') + +vim.opt_local.commentstring = '-- %s' +vim.opt_local.colorcolumn = '120' + diff --git a/after/ftplugin/make.lua b/after/ftplugin/make.lua new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/after/ftplugin/make.lua @@ -0,0 +1 @@ + diff --git a/after/ftplugin/ocaml.lua b/after/ftplugin/ocaml.lua new file mode 100644 index 00000000..bc67025c --- /dev/null +++ b/after/ftplugin/ocaml.lua @@ -0,0 +1,5 @@ +vim.opt.shiftwidth = 2 + +-- vim.keymap.set('n', 'cp', require('ocaml.mappings').dune_promote_file, { buffer = 0 }) +-- + diff --git a/after/ftplugin/python.lua b/after/ftplugin/python.lua new file mode 100644 index 00000000..e0cca3b5 --- /dev/null +++ b/after/ftplugin/python.lua @@ -0,0 +1,9 @@ +vim.opt_local.expandtab = true +vim.opt_local.commentstring = '# %s' +vim.opt_local.smarttab = true +vim.opt_local.shiftwidth = 4 +vim.opt_local.tabstop = 4 +vim.opt_local.softtabstop = 4 +vim.opt_local.fileformat = 'unix' +vim.opt_local.textwidth = 79 +vim.opt_local.colorcolumn = '80' diff --git a/after/ftplugin/rust.lua b/after/ftplugin/rust.lua new file mode 100644 index 00000000..22b5398b --- /dev/null +++ b/after/ftplugin/rust.lua @@ -0,0 +1,15 @@ +-- Set buffer-local options for Rust files +vim.opt_local.expandtab = true +vim.opt_local.autoindent = true +vim.opt_local.smartindent = true +vim.opt_local.shiftwidth = 4 +vim.opt_local.tabstop = 4 +vim.opt_local.softtabstop = 4 +vim.opt_local.textwidth = 80 +vim.opt_local.colorcolumn = '80' + +-- Define key mappings or other configurations specific to Rust +-- For example: +vim.keymap.set('n', 'r', 'Cargo run', { desc = 'Run the current Rust project', noremap = true }) +vim.keymap.set('n', 'c', 'Cargo check', { desc = 'Check the current Rust project', noremap = true }) + diff --git a/after/ftplugin/sh.lua b/after/ftplugin/sh.lua new file mode 100644 index 00000000..78d5d27a --- /dev/null +++ b/after/ftplugin/sh.lua @@ -0,0 +1,7 @@ +vim.opt_local.expandtab = true +vim.opt_local.shiftwidth = 2 +vim.opt_local.softtabstop = 2 +vim.opt_local.tabstop = 2 +vim.opt_local.textwidth = 80 + +vim.opt_local.syntax = enable diff --git a/after/ftplugin/sql.lua b/after/ftplugin/sql.lua new file mode 100644 index 00000000..ad59a736 --- /dev/null +++ b/after/ftplugin/sql.lua @@ -0,0 +1 @@ +vim.opt_local.commentstring = '-- %s' diff --git a/after/ftplugin/yaml.lua b/after/ftplugin/yaml.lua new file mode 100644 index 00000000..e69de29b diff --git a/doc/kickstart.txt b/doc/kickstart.txt deleted file mode 100755 index cb87ac3f..00000000 --- a/doc/kickstart.txt +++ /dev/null @@ -1,24 +0,0 @@ -================================================================================ -INTRODUCTION *kickstart.nvim* - -Kickstart.nvim is a project to help you get started on your neovim journey. - - *kickstart-is-not* -It is not: -- Complete framework for every plugin under the sun -- Place to add every plugin that could ever be useful - - *kickstart-is* -It is: -- Somewhere that has a good start for the most common "IDE" type features: - - autocompletion - - goto-definition - - find references - - fuzzy finding - - and hinting at what more can be done :) -- A place to _kickstart_ your journey. - - You should fork this project and use/modify it so that it matches your - style and preferences. If you don't want to do that, there are probably - other projects that would fit much better for you (and that's great!)! - - vim:tw=78:ts=8:ft=help:norl: diff --git a/doc/tags b/doc/tags deleted file mode 100755 index 687ae772..00000000 --- a/doc/tags +++ /dev/null @@ -1,3 +0,0 @@ -kickstart-is kickstart.txt /*kickstart-is* -kickstart-is-not kickstart.txt /*kickstart-is-not* -kickstart.nvim kickstart.txt /*kickstart.nvim* diff --git a/init.lua b/init.lua index 4efc851a..f2708180 100755 --- a/init.lua +++ b/init.lua @@ -1,44 +1,26 @@ --- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' - -- Install package manager -- https://github.com/folke/lazy.nvim --- Check Lua documentation for more info -local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then - vim.fn.system { + 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) +vim.opt.rtp:prepend(vim.env.LAZY or lazypath) -local opts = { - git = { log = { '--since=3 days ago' } }, - ui = { custom_keys = { false } }, - checker = { enabled = false }, - colorscheme = "monokai", -} - -require('lazy').setup({ - -- Git related plugins - 'tpope/vim-fugitive', - 'tpope/vim-rhubarb', - - -- Detect tabstop and shiftwidth automatically - 'tpope/vim-sleuth', - { - import = 'custom.plugins', - exclude = 'custom.plugins.mason', - }, -}, opts) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' +require('config.lazy') +require('config.autocmds') require('config.options') require('config.mappings') require('config.utils') require('config.themes') + +vim.cmd('filetype plugin on') diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100755 index 00000000..45b5288c --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,66 @@ +-- Auto-format on save +vim.cmd [[ + augroup FormatOnSave + autocmd! + autocmd BufWritePre * lua vim.lsp.buf.format({ async = false }) + augroup END +]] + +-- Augroup for Highlight on yank +vim.cmd([[ + augroup YankHighlight + autocmd! + autocmd TextYankPost * lua vim.highlight.on_yank() + augroup END +]]) + +-- Remove trailing whitespace +vim.cmd([[ + augroup RemoveTrailingWhitespace + autocmd! + autocmd BufWritePre * %s/\s\+$//e + augroup END +]]) + +-- Append newline at EOF, excluding YAML files +vim.cmd([[ + augroup append_newline_at_eof + autocmd! + autocmd BufWritePre * silent! if !empty(getline('$')) && getline('$') !~# '\n$' && &filetype != 'yaml' | call append(line('$'), '') | endif + augroup END +]]) + +local function augroup(name) + return vim.api.nvim_create_augroup('lazyvim_' .. name, { clear = true }) +end + +vim.api.nvim_create_autocmd('VimEnter', { + group = augroup('autoupdate'), + callback = function() + if require('lazy.status').has_updates() then + require('lazy').update({ show = false }) + end + end, +}) + +vim.api.nvim_create_autocmd('User', { + pattern = 'LazyCheck', + -- pattern = "LazyVimStarted", + desc = 'Update lazy.nvim plugins', + callback = function(event) + local start_time = os.clock() + require('lazy').sync({ wait = false, show = false }) + local end_time = os.clock() + print('Lazy plugins synced in ' .. (end_time - start_time) * 1000 .. 'ms') + print(vim.print(event)) + end, +}) + +-- Automatically start insert mode in terminal buffers +vim.cmd([[ + autocmd TermOpen * startinsert + autocmd TermOpen * setlocal nonumber norelativenumber + autocmd TermOpen * normal! G + autocmd TermOpen * tnoremap +]]) + diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100755 index 00000000..ab6217a9 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,37 @@ +local opts = { + git = { log = { '--since=3 days ago' } }, + ui = { custom_keys = { false } }, + colors = { themes = { 'monokai' } }, + checker = { + enabled = true, + -- notify = false, + }, + performance = { + rtp = { + disabled_plugins = { + 'gzip', + 'tarPlugin', + 'tohtml', + 'tutor', + 'zipPlugin', + }, + }, + }, + change_detection = { + notify = false, + }, +} + +require('lazy').setup({ + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', + { + import = 'custom.plugins', + exclude = 'custom.plugins.mason', + }, +}, opts) + diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua index ce8f7be7..63450a3f 100755 --- a/lua/config/mappings.lua +++ b/lua/config/mappings.lua @@ -1,107 +1,122 @@ --- [[ Basic Keymaps ]] +local utils = require('config.utils') +-- Basic Keymaps -- Keymaps for better default experience -- See `:help vim.keymap.set()` vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) -vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" }) +-- vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = "[P]roject [V]iew" }) +vim.keymap.set('n', '', '', { 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'", { - -- Unmap the 'gp' key for previous word - expr = true, - silent = true -}) +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 }) -- Move lines vim.keymap.set('v', 'J', ":m '>+1gv=gv", { silent = true }) vim.keymap.set('v', 'K', ":m '<-2gv=gv", { silent = true }) +vim.keymap.set('n', '>', '>gv', { silent = true }) +vim.keymap.set('n', '<', '', "zz", { desc = "Half Page Jumping Up" }) -vim.keymap.set('n', '', "zz", { desc = "Half Page Jumping Down" }) - --- Keep search line in the middle +-- Miscellaneous Navigation Keymaps +vim.keymap.set('n', 'J', 'mzj`z') +vim.keymap.set('n', '', 'zz', { desc = 'Half Page Jumping Up' }) +vim.keymap.set('n', '', 'zz', { desc = 'Half Page Jumping Down' }) vim.keymap.set('n', 'n', 'nzzzv', { silent = true }) vim.keymap.set('n', 'N', 'Nzzzv', { silent = true }) --- Unmap the 'p' key for previous word vim.api.nvim_set_keymap('n', 'gp', '', { noremap = true, silent = true }) +vim.keymap.set('n', '', 'cnextzz') +vim.keymap.set('n', '', 'cprevzz') +vim.keymap.set('n', 'k', 'lnextzz', { desc = 'Quick Fix Nav Up' }) +vim.keymap.set('n', 'j', 'lprevzz', { desc = 'Quick Fix Nav Down' }) --- Quick fix navigation -vim.keymap.set("n", "", "cnextzz") -vim.keymap.set("n", "", "cprevzz") -vim.keymap.set("n", "k", "lnextzz", { desc = "Quick Fix Nav Up" }) -vim.keymap.set("n", "j", "lprevzz", { desc = "Quick Fix Nav Down" }) +-- Buffer Navigation Keymaps +vim.keymap.set('n', 'bn', 'bnextzz', { desc = 'Quick Nav Buf Next' }) +vim.keymap.set('n', 'bp', 'bprevzz', { desc = 'Quick Nav Buf Prev' }) +vim.keymap.set('n', 'bd', 'bdelete', { desc = 'Quick Nav Buf Delete' }) +vim.keymap.set('n', 'bs', 'split', { desc = 'Openn Buf Horizontal Split' }) +vim.keymap.set('n', 'bv', 'vsp', { desc = 'Open Buf Vertical Split' }) +vim.keymap.set('n', 'bt', 'terminal') --- Copy from plus register -vim.keymap.set({ 'n', 'v' }, 'y', "\"+y", { desc = "Copy to + register" }) -vim.keymap.set('n', 'Y', "\"+Y") +-- Editing Keymaps +vim.keymap.set('x', 'p', [["_dP"]], { desc = 'Paste without register' }) +vim.keymap.set({ 'n', 'v' }, 'd', [["_d"]], { desc = 'Delete without register' }) +vim.keymap.set({ 'n', 'v' }, 'y', '"+y', { desc = 'Copy to + register' }) +vim.keymap.set('n', 'Y', '"+Y') +-- replace current word in current scope +vim.keymap.set( + 'n', + 'r', + ':%s/\\<\\>//gI', + { desc = '[R]eplace Current Word in Current Scope' } +) +-- replace current word in file scope +vim.keymap.set( + 'n', + 'R', + ':%s/\\<\\>//gI', + { desc = '[R]eplace Current Word in File Scope' } +) --- Replace current word -vim.keymap.set("n", "r", [[:%s/\<\>//gI]], - { desc = "[R]eplace Current Word" }) -vim.keymap.set("n", "x", "!chmod +x %", { desc = "Set Current File to Executable", silent = true }) +-- Open vertical split pane --- [ telescope keymaps] +-- File Management Keymaps +vim.keymap.set('n', '', 'silent !tmux neww $HOME/.local/bin/tmux_sessionizer', { desc = 'Open Session' }) +vim.keymap.set('n', 'x', '!chmod +x %', { desc = 'Set Current File to Executable', silent = true }) + +-- Telescope Keymaps -- 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, - }) - -- require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes')) + require('telescope.builtin').current_buffer_fuzzy_find( + require('telescope.themes').get_dropdown({ winblend = 10, previewer = false }) + ) end, { desc = '[/] Fuzzily search in current buffer' }) - vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', 'gb', require('telescope.builtin').git_branches, { desc = 'Search [G]it [B]ranches' }) +vim.keymap.set('n', 'gc', require('telescope.builtin').git_commits, { desc = 'Search [G]it [C]ommits' }) 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', 'sp', function() - require('telescope.builtin').grep_string({ search = vim.fn.input("Grep Search > ") }) -end, { desc = '[S]search [P]roject' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -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]resume' }) --- [ tree-sitter keymaps ] +vim.keymap.set({ 'n', 'v' }, 'sh', function() + local query = utils.get_search_query() + require('telescope.builtin').help_tags({ search = query, initial_mode = 'insert', default_text = query }) +end, { desc = '[S]earch [H]elp' }) +vim.keymap.set({ 'n', 'v' }, 'sw', function() + local query = utils.get_search_query() + require('telescope.builtin').grep_string({ search = query, initial_mode = 'insert', default_text = query }) +end, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'sp', function() + require('telescope.builtin').grep_string({ search = vim.fn.input('Grep Search > ') }) +end, { desc = '[S]search [P]roject' }) +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' }) + +-- Tree-sitter Keymaps -- 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', 'vd', function() +-- vim.diagnostic.setloclist() +-- vim.cmd('lopen') +-- end, { desc = 'Open the diagnostics location list' }) --- Open the diagnostics location list -vim.keymap.set('n', 'q', function() - vim.diagnostic.setloclist() - vim.cmd('lopen') -end, { - noremap = true, - silent = true, - expr = false, - desc = 'Open the diagnostics location list' -}) +-- Refactoring Keymaps +-- vim.keymap.set({ "x" }, "re", [[lua require('refactoring').refactor('Extract Function')]], +-- { noremap = true, silent = true, expr = false, desc = "Extract Function" }) +-- vim.keymap.set({ "x" }, "rf", [[lua require('refactoring').refactor('Extract Function To File')]], +-- { noremap = true, silent = true, expr = false, desc = "Extract Function To File" }) +-- vim.keymap.set({ "x" }, "rv", [[lua require('refactoring').refactor('Extract Variable')]], +-- { noremap = true, silent = true, expr = false, desc = "Extract Variable" }) +-- vim.keymap.set({ "n" }, "rI", [[lua require('refactoring').refactor('Inline Variable')]], +-- { noremap = true, silent = true, expr = false, desc = "Inline Variable" }) +-- vim.keymap.set({ "n", "x" }, "ri", [[lua require('refactoring').refactor('Inline Variable')]], +-- { noremap = true, silent = true, expr = false, desc = "Inline Variable" }) +-- +-- vim.keymap.set({ "n" }, "rb", [[lua require('refactoring').refactor('Extract Block')]], +-- { noremap = true, silent = true, expr = false, desc = "Extract Block" }) +-- vim.keymap.set({ "n" }, "rbf", [[lua require('refactoring').refactor('Extract Block To File')]], +-- { noremap = true, silent = true, expr = false, desc = "Extract Block To File" }) --- Close the diagnostics location list -vim.keymap.set('n', 'qq', function() - vim.cmd('lclose') -end, { - noremap = true, - silent = true, - expr = false, - desc = 'Close the diagnostics location list' -}) - --- [[ Highlight on yank ]] --- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) -vim.api.nvim_create_autocmd('TextYankPost', { - callback = function() - vim.highlight.on_yank() - end, - group = highlight_group, - pattern = '*', -}) diff --git a/lua/config/options.lua b/lua/config/options.lua index 75e3f8d1..9ab0d2d3 100755 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -3,11 +3,20 @@ local g = vim.g local opts = { -- Change cursor in insert mode - guicursor = "", + guicursor = '', + + -- set terminal tab title + title = true, + titlelen = 0, + -- titlestring = 'nvim %t (%-15.25F)%a%r%m', + titlestring = 'nvim %t (%-15.25f)%a%r%m', -- Make line numbers default relativenumber = true, + --Enable noshowmode + showmode = false, + -- Enable break indent breakindent = true, @@ -16,7 +25,6 @@ local opts = { softtabstop = 4, shiftwidth = 4, expandtab = true, - smartindent = true, -- Disable line wrap wrap = false, @@ -24,7 +32,7 @@ local opts = { -- Save undo history swapfile = false, backup = false, - undodir = vim.fn.stdpath("data") .. "/site/undodir", + undodir = vim.fn.stdpath('data') .. '/site/undodir', undofile = true, -- Searching Configuration @@ -45,7 +53,6 @@ local opts = { -- NOTE: You should make sure your terminal supports this termguicolors = true, scrolloff = 10, - colorcolumn = "80", pyxversion = 3, } @@ -64,31 +71,31 @@ end -- Disable built-in plugins local disabled_built_ins = { - "2html_plugin", - "getscript", - "getscriptPlugin", - "gzip", - "logipat", - "matchit", + '2html_plugin', + 'getscript', + 'getscriptPlugin', + 'gzip', + 'logipat', + 'matchit', -- "netrw", - "netrwFileHandlers", - "loaded_remote_plugins", - "loaded_tutor_mode_plugin", + 'netrwFileHandlers', + 'loaded_remote_plugins', + 'loaded_tutor_mode_plugin', -- "netrwPlugin", -- "netrwSettings", - "rrhelper", - "spellfile_plugin", - "tar", - "tarPlugin", - "vimball", - "vimballPlugin", - "zip", - "zipPlugin", - "matchparen", + 'rrhelper', + 'spellfile_plugin', + 'tar', + 'tarPlugin', + 'vimball', + 'vimballPlugin', + 'zip', + 'zipPlugin', + 'matchparen', } for _, plugin in pairs(disabled_built_ins) do - g["loaded_" .. plugin] = 1 + g['loaded_' .. plugin] = 1 end -- Improve Neovim startup @@ -107,13 +114,14 @@ for k, v in pairs(global_let_opts) do g[k] = v end -opt.formatoptions = "l" +opt.formatoptions = 'l' opt.formatoptions = opt.formatoptions - - "a" -- Auto formatting is BAD. - - "t" -- Don't auto format my code. I got linters for that. - + "c" -- In general, I like it when comments respect textwidth - - "o" -- O and o, don't continue comments - + "r" -- But do continue when pressing enter. - + "n" -- Indent past the formatlistpat, not underneath it. - + "j" -- Auto-remove comments if possible. - - "2" -- I'm not in gradeschool anymore + - 'a' -- Auto formatting is BAD. + - 't' -- Don't auto format my code. I got linters for that. + + 'c' -- In general, I like it when comments respect textwidth + - 'o' -- O and o, don't continue comments + + 'r' -- But do continue when pressing enter. + + 'n' -- Indent past the formatlistpat, not underneath it. + + 'j' -- Auto-remove comments if possible. + - '2' -- I'm not in gradeschool anymore + diff --git a/lua/config/themes.lua b/lua/config/themes.lua index 36fd72cb..e69de29b 100755 --- a/lua/config/themes.lua +++ b/lua/config/themes.lua @@ -1,8 +0,0 @@ --- return { --- Theme inspired by Atom --- 'navarasu/onedark.nvim', --- priority = 1000, --- config = function() --- vim.cmd.colorscheme 'onedark' --- end, --- }, diff --git a/lua/config/utils.lua b/lua/config/utils.lua index 8b137891..cc6161cf 100755 --- a/lua/config/utils.lua +++ b/lua/config/utils.lua @@ -1 +1,23 @@ +return { + -- Function to get the current visual selection + get_visual_selection = function() + vim.cmd 'noau normal! "vy"' + local text = vim.fn.getreg 'v' + vim.fn.setreg('v', {}) + text = string.gsub(text, '\n', '') + if #text > 0 then + return text + else + return '' + end + end, + + -- Function to get the current search query + get_search_query = function() + local word_under_cursor = vim.fn.expand '' + local visual_selection = require('config.utils').get_visual_selection() + + return visual_selection ~= '' and visual_selection or word_under_cursor + end, +} diff --git a/lua/custom/plugins/auto-dark-mode.lua b/lua/custom/plugins/auto-dark-mode.lua new file mode 100755 index 00000000..8a0d2c18 --- /dev/null +++ b/lua/custom/plugins/auto-dark-mode.lua @@ -0,0 +1,19 @@ +return { + 'f-person/auto-dark-mode.nvim', + event = 'VimEnter', -- Lazy load on VimEnter event + opts = { + update_interval = 1000, -- Check for mode change every second + set_dark_mode = function() + vim.cmd('colorscheme monokai') + vim.cmd('set background=dark') -- Ensure the background is set correctly + end, + set_light_mode = function() + vim.cmd('colorscheme solarized') + vim.cmd('set background=light') + end, + }, + config = function(_, opts) + require('auto-dark-mode').setup(opts) + end +} + diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua index d271227f..93085d0b 100755 --- a/lua/custom/plugins/autopairs.lua +++ b/lua/custom/plugins/autopairs.lua @@ -1,15 +1,13 @@ return { - "windwp/nvim-autopairs", - -- Optional dependency + 'windwp/nvim-autopairs', dependencies = { 'hrsh7th/nvim-cmp' }, + event = 'InsertEnter', config = function() - require("nvim-autopairs").setup {} + require('nvim-autopairs').setup({}) -- If you want to automatically add `(` after selecting a function or method local cmp_autopairs = require('nvim-autopairs.completion.cmp') local cmp = require('cmp') - cmp.event:on( - 'confirm_done', - cmp_autopairs.on_confirm_done() - ) + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) end, } + diff --git a/lua/custom/plugins/cmp.lua b/lua/custom/plugins/cmp.lua index b7126dac..84a9e5e2 100755 --- a/lua/custom/plugins/cmp.lua +++ b/lua/custom/plugins/cmp.lua @@ -11,35 +11,45 @@ return { -- Adds a number of user-friendly snippets 'rafamadriz/friendly-snippets', + + -- Optional sources + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-buffer', }, + event = { 'InsertEnter', 'CmdlineEnter' }, config = function() - -- See `:help cmp` + -- Set completion options vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } + + -- Lazy load snippets from friendly-snippets require('luasnip.loaders.from_vscode').lazy_load() - local cmp = require 'cmp' - local luasnip = require 'luasnip' - luasnip.config.setup {} + -- Import required modules + local cmp = require('cmp') + local luasnip = require('luasnip') - local select_opts = { behavior = cmp.SelectBehavior.Select } + -- Setup luasnip + luasnip.config.setup({}) - cmp.setup { + -- Setup nvim-cmp + cmp.setup({ snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, - sources = { + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, { name = 'path' }, - { name = 'nvim_lsp', keyword_length = 1 }, - { name = 'buffer', keyword_length = 3 }, - { name = 'luasnip', keyword_length = 2 }, - }, + }), window = { - documentation = cmp.config.window.bordered() + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), }, formatting = { - fields = { 'menu', 'abbr', 'kind' }, + fields = { 'abbr', 'kind', 'menu' }, format = function(entry, item) local menu_icon = { nvim_lsp = 'ฮป', @@ -47,72 +57,52 @@ return { buffer = 'ฮฉ', path = '๐Ÿ–ซ', } - - item.menu = menu_icon[entry.source.name] + item.menu = menu_icon[entry.source.name] or entry.source.name return item end, }, - mapping = cmp.mapping.preset.insert { + mapping = cmp.mapping.preset.insert({ [''] = 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.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_locally_jumpable() then + elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() else fallback() end end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then + elseif luasnip.jumpable(-1) then luasnip.jump(-1) else fallback() end end, { 'i', 's' }), - }, - } - - local sign = function(opts) - vim.fn.sign_define(opts.name, { - texthl = opts.name, - text = opts.text, - numhl = '' - }) - end - - sign({ name = 'DiagnosticSignError', text = 'โœ˜' }) - sign({ name = 'DiagnosticSignWarn', text = 'โ–ฒ' }) - sign({ name = 'DiagnosticSignHint', text = 'โš‘' }) - sign({ name = 'DiagnosticSignInfo', text = 'ยป' }) - - vim.diagnostic.config({ - virtual_text = false, - severity_sort = true, - float = { - border = 'rounded', - source = 'always', - }, + [''] = cmp.mapping.abort(), + }), }) - vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( - vim.lsp.handlers.hover, - { border = 'rounded' } - ) + -- Additional luasnip configuration + luasnip.config.set_config({ + history = true, + updateevents = 'TextChanged,TextChangedI', + }) - vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with( - vim.lsp.handlers.signature_help, - { border = 'rounded' } - ) + -- Setup for SQL filetype with vim-dadbod-completion + cmp.setup.filetype('sql', { + sources = cmp.config.sources({ + { name = 'vim-dadbod-completion' }, + { name = 'buffer' }, + }), + }) end, } + diff --git a/lua/custom/plugins/comments.lua b/lua/custom/plugins/comments.lua index 44766d55..4db08198 100755 --- a/lua/custom/plugins/comments.lua +++ b/lua/custom/plugins/comments.lua @@ -1,5 +1,5 @@ return { 'numToStr/Comment.nvim', opts = {}, - lazy = false } + diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua old mode 100644 new mode 100755 index 1a804873..8631b195 --- a/lua/custom/plugins/copilot.lua +++ b/lua/custom/plugins/copilot.lua @@ -1,3 +1,20 @@ return { - 'github/copilot.vim', + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + event = 'InsertEnter', + opts = { + suggestion = { + auto_trigger = true, + filetypes = { + ['.'] = true, + }, + keymap = { + accept_word = '', + accept_line = '', + next = 'M-[', + previous = 'M-]', + }, + }, + }, } + diff --git a/lua/custom/plugins/dadbod.lua b/lua/custom/plugins/dadbod.lua new file mode 100755 index 00000000..688a9134 --- /dev/null +++ b/lua/custom/plugins/dadbod.lua @@ -0,0 +1,14 @@ +return { + 'tpope/vim-dadbod', + dependencies = { + 'kristijanhusak/vim-dadbod-ui', + 'kristijanhusak/vim-dadbod-completion', + }, + keys = { + { 'du', 'DBUIToggle', { desc = 'Toggle dadbod', noremap = true } }, + }, + init = function() + vim.g.db_ui_use_nerd_fonts = 1 + end, +} + diff --git a/lua/custom/plugins/dap.lua b/lua/custom/plugins/dap.lua new file mode 100755 index 00000000..797e65e2 --- /dev/null +++ b/lua/custom/plugins/dap.lua @@ -0,0 +1,117 @@ +return { + -- Add the nvim-dap related plugins + { + 'mfussenegger/nvim-dap', + dependencies = { + { 'rcarriga/nvim-dap-ui', opt = true, cmd = 'DapUI' }, + { 'nvim-neotest/nvim-nio', opt = true, cmd = 'Neotest' }, + { 'theHamsta/nvim-dap-virtual-text', opt = true, ft = { 'python', 'go', 'rust' } }, + { 'mfussenegger/nvim-dap-python', opt = true, ft = 'python' }, + { 'leoluz/nvim-dap-go', opt = true, ft = 'go' }, + { 'simrat39/rust-tools.nvim', opt = true, ft = 'rust' }, + 'williamboman/mason.nvim', -- Mason for managing external tools + 'williamboman/mason-lspconfig.nvim' + }, + config = function() + local dap = require('dap') + local dapui = require('dapui') + local dap_virtual_text = require('nvim-dap-virtual-text') + local mason_registry = require('mason-registry') + + -- Initialize dap-ui + dapui.setup() + -- Initialize dap-virtual-text + dap_virtual_text.setup() + + -- Keybindings + vim.api.nvim_set_keymap('n', 'dc', ':lua require"dap".continue()', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'ds', ':lua require"dap".step_over()', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'di', ':lua require"dap".step_into()', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'do', ':lua require"dap".step_out()', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'db', ':lua require"dap".toggle_breakpoint()', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'dr', ':lua require"dap".repl.open()', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'du', ':lua require"dapui".toggle()', { noremap = true, silent = true }) + + -- DAP Python + local function get_python_path() + local cwd = vim.fn.getcwd() + if vim.env.VIRTUAL_ENV then + return vim.env.VIRTUAL_ENV .. '/bin/python' + elseif vim.fn.executable(cwd .. '/venv/bin/python') == 1 then + return cwd .. '/venv/bin/python' + elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then + return cwd .. '/.venv/bin/python' + else + return 'python' + end + end + + require('dap-python').setup(get_python_path()) + + -- DAP Go + require('dap-go').setup() + + -- DAP Rust + local rust_tools = require('rust-tools') + + -- Ensure codelldb is installed via Mason + local codelldb_package = mason_registry.get_package('codelldb') + local codelldb_path = codelldb_package:get_install_path() + local codelldb_adapter = codelldb_path .. '/extension/adapter/codelldb' + local codelldb_lib = codelldb_path .. '/extension/lldb/lib/liblldb.so' + + rust_tools.setup({ + tools = { + autoSetHints = true, + inlay_hints = { + show_parameter_hints = true, + parameter_hints_prefix = "<- ", + other_hints_prefix = "=> ", + }, + }, + server = { + on_attach = function(_, bufnr) + -- DAP Rust keymaps + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dr', ':RustDebuggables', { noremap = true, silent = true }) + -- Keybind for RustHoverActions + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', ':RustHoverActions', { noremap = true, silent = true }) + end, + }, + dap = { + adapter = require('rust-tools.dap').get_codelldb_adapter( + codelldb_adapter, + codelldb_lib + ), + }, + }) + + -- DAP UI integration + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() + end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() + end + + -- Define signs for breakpoints + vim.fn.sign_define('DapBreakpoint', { text = '๐Ÿ”ด', texthl = '', linehl = '', numhl = '' }) + vim.fn.sign_define('DapStopped', { text = '๐ŸŸข', texthl = '', linehl = '', numhl = '' }) + end, + keys = { + { 'n', 'dc', ':lua require"dap".continue()' }, + { 'n', 'ds', ':lua require"dap".step_over()' }, + { 'n', 'di', ':lua require"dap".step_into()' }, + { 'n', 'do', ':lua require"dap".step_out()' }, + { 'n', 'db', ':lua require"dap".toggle_breakpoint()' }, + { 'n', 'dB', ':lua require"dap".set_breakpoint(vim.fn.input("Breakpoint condition: "))' }, + { 'n', 'dr', ':lua require"dap".repl.open()' }, + { 'n', 'du', ':lua require"dapui".toggle()' } + }, + ft = { 'python', 'go', 'rust' } + } +} + diff --git a/lua/custom/plugins/diffview.lua b/lua/custom/plugins/diffview.lua new file mode 100755 index 00000000..ecc2b1bb --- /dev/null +++ b/lua/custom/plugins/diffview.lua @@ -0,0 +1,6 @@ +return { + 'sindrets/diffview.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = {}, +} + diff --git a/lua/custom/plugins/formatting.lua b/lua/custom/plugins/formatting.lua index 890fdb12..38b695a0 100755 --- a/lua/custom/plugins/formatting.lua +++ b/lua/custom/plugins/formatting.lua @@ -1,25 +1,41 @@ return { - "stevearc/conform.nvim", - event = { "BufReadPre", "BufNewFile" }, - config = function() - local conform = require("conform") + 'stevearc/conform.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'WhoIsSethDaniel/mason-tool-installer.nvim', + }, + event = { 'BufReadPre', 'BufNewFile' }, + opts = function() + local formatters_by_ft = { + lua = { 'stylua' }, + python = function(bufnr) + if require('conform').get_formatter_info('ruff_format', bufnr).available then + return { 'isort', 'ruff_format', 'ruff_fix' } + else + return { 'isort', 'black' } + end + end, + go = { 'gofumpt', 'goimports' }, + } - conform.setup({ - formatters_by_ft = { - python = { "isort", "black" }, - }, + require('conform').setup({ + formatters_by_ft = formatters_by_ft, format_on_save = { lsp_fallback = true, - async = false, timeout_ms = 500, }, }) - vim.keymap.set({ "n", "v" }, "mp", function() - conform.format({ - lsp_fallback = true, - async = false, - timeout_ms = 500, - }) - end, { desc = "Format file or range (in visual mode)" }) + + require('mason-tool-installer').setup({ + ensure_installed = { + 'stylua', + 'ruff', + 'isort', + 'black', + 'gofumpt', + 'goimports', + }, + }) end, } + diff --git a/lua/custom/plugins/fugitive.lua b/lua/custom/plugins/fugitive.lua index 72711a58..a686da67 100755 --- a/lua/custom/plugins/fugitive.lua +++ b/lua/custom/plugins/fugitive.lua @@ -2,5 +2,46 @@ return { 'tpope/vim-fugitive', config = function() vim.keymap.set('n', 'gs', vim.cmd.Git) - end + + local jfraeys_fugitive = vim.api.nvim_create_augroup('jfraeys_fugitive', {}) + + local autocmd = vim.api.nvim_create_autocmd + autocmd('BufWinEnter', { + group = jfraeys_fugitive, + pattern = '*', + callback = function() + if vim.bo.ft ~= 'fugitive' then + return + end + + local bufnr = vim.api.nvim_get_current_buf() + local opts = { buffer = bufnr, remap = false } + + vim.keymap.set('n', 'p', function() + vim.cmd.Git 'push' + end, opts) + + -- rebase always + vim.keymap.set('n', 'P', function() + vim.cmd.Git { 'pull', '--rebase' } + end, opts) + + -- NOTE: It allows me to easily set the branch I am pushing and any tracking + -- needed if I did not set the branch up correctly + vim.keymap.set('n', 't', ':Git push -u origin ', opts) + end, + }) + + vim.keymap.set('n', 'gu', 'diffget //2') + vim.keymap.set('n', 'gh', 'diffget //3') + end, + cond = function() + -- Function to check if the current directory is a Git repository + local is_git_repo = function() + local git_dir = vim.fn.finddir('.git', '.;') + return git_dir and #git_dir > 0 + end + return is_git_repo() + end, } + diff --git a/lua/custom/plugins/gitsigns.lua b/lua/custom/plugins/gitsigns.lua index 0a64658b..cb877b33 100755 --- a/lua/custom/plugins/gitsigns.lua +++ b/lua/custom/plugins/gitsigns.lua @@ -1,32 +1,45 @@ return { - -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - -- See `:help gitsigns.txt` - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = 'โ€พ' }, - changedelete = { text = '~' }, - }, - on_attach = function(bufnr) - vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { - buffer = bufnr, desc = 'Preview git hunk' - }) + -- Lazy load gitsigns.nvim only if in a git repository + { + 'lewis6991/gitsigns.nvim', + opts = { + -- Configuration options for gitsigns.nvim + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = 'โ€พ' }, + changedelete = { text = '~' }, + }, + -- on_attach function executed when the plugin is attached to a buffer + on_attach = function(bufnr) + vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { + buffer = bufnr, desc = 'Preview git hunk' + }) - -- don't override the built-in and fugitive keymaps - local gs = package.loaded.gitsigns - vim.keymap.set({ 'n', 'v' }, ']c', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '' - end, { expr = true, buffer = bufnr, desc = "Jump to next hunk" }) - vim.keymap.set({ 'n', 'v' }, '[c', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '' - end, { expr = true, buffer = bufnr, desc = "Jump to previous hunk" }) - end, + -- Don't override built-in and fugitive keymaps + local gs = require('gitsigns') + vim.keymap.set({ 'n', 'v' }, ']c', function() + if vim.wo.diff then + return ']c' + end + vim.schedule(function() + gs.next_hunk() + end) + return '' + end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' }) + + vim.keymap.set({ 'n', 'v' }, '[c', function() + if vim.wo.diff then + return '[c' + end + vim.schedule(function() + gs.prev_hunk() + end) + return '' + end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' }) + end, + }, }, } + diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua index 18216332..a7123012 100755 --- a/lua/custom/plugins/harpoon.lua +++ b/lua/custom/plugins/harpoon.lua @@ -1,15 +1,40 @@ return { - "theprimeagen/harpoon", - config = function() - local mark = require("harpoon.mark") - local ui = require("harpoon.ui") + 'theprimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim' }, + config = function() + local harpoon = require 'harpoon' - vim.keymap.set("n", "a", mark.add_file, { desc = "[A]dd file harpoon" }) - vim.keymap.set("n", "", ui.toggle_quick_menu, { desc = "Go to harpoon" }) + harpoon:setup() - vim.keymap.set("n", "", function() ui.nav_file(1) end) - vim.keymap.set("n", "", function() ui.nav_file(2) end) - vim.keymap.set("n", "", function() ui.nav_file(3) end) - vim.keymap.set("n", "", function() ui.nav_file(4) end) - end, + vim.keymap.set('n', 'a', function() + harpoon:list():add() + end, { desc = 'Add file to harpoon' }) + vim.keymap.set('n', '', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = 'Open harpoon window' }) + -- vim.keymap.set("n", "", function() toggle_telescope(harpoon.list()) end, { desc = "Open harpoon window" }) + + vim.keymap.set('n', '', function() + harpoon:list():select(1) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(2) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(3) + end) + vim.keymap.set('n', '', function() + harpoon:list():select(4) + end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set('n', '', function() + harpoon:list():prev() + end) + vim.keymap.set('n', '', function() + harpoon:list():next() + end) + end, } + diff --git a/lua/custom/plugins/indent.lua b/lua/custom/plugins/indent.lua index 2a83c657..02f5d094 100755 --- a/lua/custom/plugins/indent.lua +++ b/lua/custom/plugins/indent.lua @@ -3,12 +3,14 @@ return { 'lukas-reineke/indent-blankline.nvim', -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help indent_blankline.txt` - main = "ibl", + main = 'ibl', opts = { indent = { --[[ highlight = highlight ]] - char = "โ”†", - smart_indent_cap = true, + char = 'โ”†', + -- char = ' ', + -- char = "โ”‚", + -- smart_indent_cap = true, }, whitespace = { --[[ highlight = highlight, ]] @@ -17,3 +19,4 @@ return { scope = { enabled = true }, }, } + diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100755 index be0eb9d8..00000000 --- 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/custom/plugins/linting.lua b/lua/custom/plugins/linting.lua index 282ff8af..d7933cd0 100755 --- a/lua/custom/plugins/linting.lua +++ b/lua/custom/plugins/linting.lua @@ -1,38 +1,36 @@ return { - "mfussenegger/nvim-lint", + 'mfussenegger/nvim-lint', + dependencies = { 'WhoIsSethDaniel/mason-tool-installer.nvim' }, event = { - "BufReadPre", - "BufNewFile", + 'BufReadPre', + 'BufNewFile', }, config = function() - local lint = require("lint") - - lint.linters_by_ft = { - python = { "flake8", "mypy" }, - yaml = { "yamllint" }, - json = { "jsonlint" } + require('lint').linters_by_ft = { + python = { 'ruff' }, + go = { 'golangcilint' }, + yaml = { 'yamllint' }, } - local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) - vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { group = lint_augroup, callback = function() - lint.try_lint() + require('lint').try_lint() end, }) - local mason_tool_installer = require("mason-tool-installer") + vim.keymap.set('n', 'l', function() + require('lint').try_lint() + end, { desc = 'Lint the current buffer' }) - mason_tool_installer.setup({ + require('mason-tool-installer').setup({ ensure_installed = { - "prettier", - "stylua", - "isort", - "black", - "flake8", - "mypy", - "revive", + 'ruff', + -- 'mypy', + 'golangci-lint', + 'yamllint', }, }) end, diff --git a/lua/custom/plugins/lsp-config.lua b/lua/custom/plugins/lsp-config.lua index 21b6feda..c226d213 100755 --- a/lua/custom/plugins/lsp-config.lua +++ b/lua/custom/plugins/lsp-config.lua @@ -1,5 +1,4 @@ return { - -- LSP Configuration & Plugin 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim @@ -8,88 +7,68 @@ return { 'WhoIsSethDaniel/mason-tool-installer.nvim', -- Useful status updates for LSP - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', tag = 'legacy', - opts = {} + opts = {}, }, -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', }, config = function() - -- 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 on_attach = function(client, bufnr) local nmap = function(keys, func, desc) if desc then desc = 'LSP: ' .. desc end - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) end + -- Key mappings for LSP features nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') nmap('ca', function() - vim.lsp.buf.code_action(require('telescope.themes').get_dropdown { + vim.lsp.buf.code_action(require('telescope.themes').get_dropdown({ winblend = 10, previewer = false, - }) + })) end, '[C]ode [A]ction') - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + 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', vim.lsp.buf.type_definition, 'Type [D]efinition') + 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('gv', ':vsplit:lua vim.lsp.buf.declaration()', '[G]oto [V]irtual Text') 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 and lint' }) - - -- Enable auto-formatting on save - vim.api.nvim_command([[ - augroup AutoFormatOnSave - autocmd! - autocmd BufWritePre * :Format - augroup END - ]]) end - -- Setup neovim lua configuration - require('neodev').setup() + local capabilities = vim.lsp.protocol.make_client_capabilities() + if pcall(require, 'cmp_nvim_lsp') then + capabilities = require('cmp_nvim_lsp').default_capabilities() + end - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers - local capabilities = require('cmp_nvim_lsp').default_capabilities() + require('neodev').setup({ + library = { + plugins = { 'nvim-dap-ui' }, + types = true, + }, + }) - -- Servers configuration local servers = { clangd = {}, gopls = { settings = { - plugins = { - revive = {}, - }, gopls = { completeUnimported = true, usePlaceholders = true, @@ -99,89 +78,143 @@ return { }, }, }, - pylsp = { + htmx = { + filetypes = { 'html' }, + }, + ruff_lsp = { + filetypes = { 'python' }, + }, + pyright = { + filetypes = { 'python' }, settings = { - pylsp = { - plugins = { - black = { - blackArgs = { - "--line-length", "79", - "--exclude", "venv", - "--exclude", "env", - "--exclude", ".git", - "--exclude", ".hg", - }, - lineLength = 79, - }, - flake8 = {}, - isort = { - profile = "black", - }, - mypy = { - args = {}, - command = "mypy", - diagnostics = true, - enabled = true, - }, - pycodestyle = { - ignore = { "W391" }, - maxLineLength = 79, - }, - }, - python = { - analysis = { - autoSearchPaths = true, - diagnosticMode = "openFilesOnly", - typeCheckingMode = "strict", - useLibraryCodeForTypes = true, - }, - pythonPath = "/usr/local/bin/python3", + python = { + analysis = { + autoSearchPaths = false, + diagnosticMode = 'workspace', + useLibraryCodeForTypes = true, + typeCheckingMode = 'off', }, }, }, }, - -- rust_analyzer = {}, - -- tsserver = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + rust_analyzer = { + cmd = { 'rustup', 'run', 'stable', 'rust-analyzer' }, + }, lua_ls = { - Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, + filetypes = { 'lua' }, + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + path = vim.split(package.path, ';'), + }, + diagnostics = { + globals = { 'vim' }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file('', true), + checkThirdParty = false, + }, + telemetry = { + enable = false, + }, + }, }, }, + ocamllsp = { + manual_install = true, + filetypes = { 'ocaml', 'ocaml.interface', 'ocaml.cram', 'ocaml.menhir' }, + settings = { + codelens = { enabled = true }, + inlayHints = { enable = true }, + }, + }, + yamlls = { + filetypes = { 'yaml' }, + settings = { + yaml = { + schemas = { + ['https://json.schemasstore.org/github-workflow.json'] = '/.github/workflows/*.{yml,yaml}', + }, + }, + }, + }, + taplo = { + filetypes = { 'toml' }, + }, + dockerls = { + filetypes = { 'Dockerfile' }, + }, } - -- Setup Mason configuration - local mason = require('mason') - mason.setup { + local ensure_installed = vim.tbl_filter(function(key) + local t = servers[key] + if type(t) == 'table' then + return not t.manual_install + else + return t + end + end, vim.tbl_keys(servers)) + + require('mason').setup({ ui = { icons = { - package_installed = "โœ“", - package_pending = "โžœ", - package_uninstalled = "โœ—", + package_installed = 'โœ“', + package_pending = 'โžœ', + package_uninstalled = 'โœ—', }, }, - } + }) - -- Ensure the servers above are installed local mason_lspconfig = require('mason-lspconfig') - mason_lspconfig.setup { - ensure_installed = vim.tbl_keys(servers), - } + mason_lspconfig.setup({ + ensure_installed = ensure_installed, + }) - -- Add Mason handlers - mason_lspconfig.setup_handlers { - function(server_name) - require('lspconfig')[server_name].setup { + for name, config in pairs(servers) do + if config then + require('lspconfig')[name].setup({ capabilities = capabilities, on_attach = on_attach, - settings = servers[server_name], - filetypes = (servers[server_name] or {}).filetypes, - } + settings = config.settings, + filetypes = config.filetypes, + cmd = config.cmd, + }) end - } + end - -- Load nvim-cmp after Mason to allow Mason to configure it first require('cmp') - end + + local sign = function(opts) + vim.fn.sign_define(opts.name, { + texthl = opts.name, + text = opts.text, + numhl = '', + }) + end + + vim.diagnostic.config({ + underline = true, + severity_sort = true, + signs = true, + update_in_insert = false, + virtual_text = { + spacing = 2, + }, + float = { + source = 'if_many', + border = 'rounded', + }, + }) + + sign({ name = 'DiagnosticSignError', text = 'โœ˜' }) + sign({ name = 'DiagnosticSignWarn', text = 'โ–ฒ' }) + sign({ name = 'DiagnosticSignHint', text = 'โš‘' }) + sign({ name = 'DiagnosticSignInfo', text = 'ยป' }) + + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'rounded' }) + vim.lsp.handlers['textDocument/signatureHelp'] = + vim.lsp.with(vim.lsp.handlers.signature_help, { border = 'rounded' }) + end, } + diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua index 82bce4ed..527ee34d 100755 --- a/lua/custom/plugins/lualine.lua +++ b/lua/custom/plugins/lualine.lua @@ -1,13 +1,33 @@ return { - -- Set lualine as statusline 'nvim-lualine/lualine.nvim', - -- See `:help lualine.txt` - opts = { - options = { - icons_enabled = false, - theme = 'onedark', - component_separators = '|', - section_separators = '', - }, - }, + dependencies = { 'nvim-tree/nvim-web-devicons', 'tpope/vim-fugitive' }, + config = function() + require('lualine').setup({ + options = { + theme = 'auto', + icons_enabled = true, + component_separators = '|', + section_separators = '', + }, + sections = { + lualine_a = { + { 'buffers', show_modified_status = true, symbols = { modified = 'โ—', alternate_file = '#', directory = '๎—พ' } }, + }, + lualine_b = { + { 'mode', icons_enabled = true }, + }, + lualine_c = { + 'branch', + { 'diff', colored = false, symbols = { added = '๏ƒพ ', modified = '๏ฑ ', removed = '๏…† ' } }, + }, + lualine_x = { + 'encoding', + { 'fileformat', symbols = { unix = '๎œ’ ', mac = '๎œ‘ ', dos = '๎œ ' } }, + 'filetype', + }, + }, + extensions = { 'fugitive', 'nvim-tree' }, + }) + end, } + diff --git a/lua/custom/plugins/marks.lua b/lua/custom/plugins/marks.lua new file mode 100755 index 00000000..aa2f20f9 --- /dev/null +++ b/lua/custom/plugins/marks.lua @@ -0,0 +1,8 @@ +return { + 'chentoast/marks.nvim', + opts = { + default_mappings = true, + default_view = 'vertical', + }, +} + diff --git a/lua/custom/plugins/monokai.lua b/lua/custom/plugins/monokai.lua index 3e172efa..b34be699 100755 --- a/lua/custom/plugins/monokai.lua +++ b/lua/custom/plugins/monokai.lua @@ -2,6 +2,7 @@ return { 'tanvirtin/monokai.nvim', priority = 1000, config = function() - vim.cmd.colorscheme('monokai') + end, } + diff --git a/lua/custom/plugins/neogen.lua b/lua/custom/plugins/neogen.lua new file mode 100755 index 00000000..cc75cfa0 --- /dev/null +++ b/lua/custom/plugins/neogen.lua @@ -0,0 +1,19 @@ +return { + 'danymat/neogen', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'L3MON4D3/LuaSnip', + }, + keys = { + { 'nf', function() require('neogen').generate({ type = 'func' }) end, desc = 'Generate function doc' }, + { 'nt', function() require('neogen').generate({ type = 'type' }) end, desc = 'Generate type doc' }, + }, + config = function() + require('neogen').setup({ + snippet_engine = 'luasnip', + }) + end, + -- Uncomment next line if you want to follow only stable versions + -- version = "*" +} + diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100755 index 00000000..0a6114b2 --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,26 @@ +return { + 'stevearc/oil.nvim', + dependencies = { + 'kyazdani42/nvim-web-devicons', -- Lazy dependency for devicons + }, + config = function() + require('oil').setup({ + columns = { + 'icon', + -- 'permissions', + }, + keymaps = { + ['C-h'] = false, + ['M-h'] = 'actions.select_split', + }, + view_options = { + show_hidden = true, + }, + }) + + vim.keymap.set('n', '-', 'Oil', { noremap = true, silent = true, desc = 'Open parent directory' }) + vim.keymap.set('n', '-', function() require('oil').toggle_float() end, + { noremap = true, silent = true, desc = 'Toggle oil floating window' }) + end, +} + diff --git a/lua/custom/plugins/refactoring.lua b/lua/custom/plugins/refactoring.lua new file mode 100755 index 00000000..c948c743 --- /dev/null +++ b/lua/custom/plugins/refactoring.lua @@ -0,0 +1,22 @@ +return { + 'theprimeagen/refactoring.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-treesitter/nvim-treesitter', + }, + keys = { + { 'ef', ":lua require('refactoring').refactor('Extract Function')", mode = 'x', desc = 'Extract Function' }, + { 'eff', ":lua require('refactoring').refactor('Extract Function To File')", mode = 'x', desc = 'Extract Function To File' }, + { 'ev', ":lua require('refactoring').refactor('Extract Variable')", mode = 'x', desc = 'Extract Variable' }, + { 'eI', ":lua require('refactoring').refactor('Inline Function')", mode = 'n', desc = 'Inline Function' }, + { 'ei', ":lua require('refactoring').refactor('Inline Variable')", mode = { 'n', 'x' }, desc = 'Inline Variable' }, + { 'eb', ":lua require('refactoring').refactor('Extract Block')", mode = 'n', desc = 'Extract Block' }, + { 'ebf', ":lua require('refactoring').refactor('Extract Block To File')", mode = 'n', desc = 'Extract Block To File' }, + }, + config = function() + require('refactoring').setup({ + show_success_message = false, + }) + end, +} + diff --git a/lua/custom/plugins/snippets.lua b/lua/custom/plugins/snippets.lua new file mode 100755 index 00000000..51f53e35 --- /dev/null +++ b/lua/custom/plugins/snippets.lua @@ -0,0 +1,36 @@ +return { + { + 'L3MON4D3/LuaSnip', + -- follow latest release. + version = 'v2.*', -- Replace by the latest released major (first number of latest release) + -- install jsregexp (optional!). + build = 'make install_jsregexp', + + dependencies = { 'rafamadriz/friendly-snippets' }, + + config = function() + local ls = require('luasnip') + ls.filetype_extend('javascript', { 'jsdoc' }) + ls.filetype_extend('python', { 'google' }) + + --- TODO: What is expand? + vim.keymap.set({ 'i' }, 'e', function() + ls.expand() + end, { silent = true }) + + vim.keymap.set({ 'i', 's' }, ';', function() + ls.jump(1) + end, { silent = true }) + vim.keymap.set({ 'i', 's' }, ',', function() + ls.jump(-1) + end, { silent = true }) + + vim.keymap.set({ 'i', 's' }, '', function() + if ls.choice_active() then + ls.change_choice(1) + end + end, { silent = true }) + end, + }, +} + diff --git a/lua/custom/plugins/solarized.lua b/lua/custom/plugins/solarized.lua new file mode 100755 index 00000000..04eb8a60 --- /dev/null +++ b/lua/custom/plugins/solarized.lua @@ -0,0 +1,8 @@ +return { + 'shaunsingh/solarized.nvim', + event = "VeryLazy", + config = function() + vim.g.solarized_variant = 'light' + end, +} + diff --git a/lua/custom/plugins/surround.lua b/lua/custom/plugins/surround.lua new file mode 100755 index 00000000..b21edb8c --- /dev/null +++ b/lua/custom/plugins/surround.lua @@ -0,0 +1,7 @@ +return { + 'tpope/vim-surround', + config = function() + -- You may configure any additional settings here if needed + end, +} + diff --git a/lua/custom/plugins/telescope-undo.lua b/lua/custom/plugins/telescope-undo.lua index b585e565..ca312bc3 100755 --- a/lua/custom/plugins/telescope-undo.lua +++ b/lua/custom/plugins/telescope-undo.lua @@ -1,34 +1,44 @@ return { - "debugloop/telescope-undo.nvim", - dependencies = { -- note how they're inverted to above example - { - "nvim-telescope/telescope.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - }, - }, - keys = { - { -- lazy style key map - "u", - "Telescope undo", - desc = "undo history", - }, - }, - opts = { - extensions = { - undo = { - side_by_side = true, - layout_strategy = "vertical", - layout_config = { - preview_height = 0.8, - }, - }, - }, - }, - config = function(_, opts) - -- Calling telescope's setup from multiple specs does not hurt, it will happily merge the - -- configs for us. We won't use data, as everything is in it's own namespace (telescope - -- defaults, as well as each extension). - require("telescope").setup(opts) - require("telescope").load_extension("undo") - end, + -- "debugloop/telescope-undo.nvim", + -- dependencies = { -- note how they're inverted to above example + -- { + -- "nvim-telescope/telescope.nvim", + -- dependencies = { "nvim-lua/plenary.nvim" }, + -- }, + -- }, + -- keys = { + -- { -- lazy style key map + -- "u", "Telescope undo", desc = "undo history", + -- }, + -- }, + -- opts = { + -- extensions = { + -- undo = { + -- mapping = { + -- i = { + -- [""] = require("telescope-undo.actions").yank_additions, + -- [""] = require("telescope-undo.actions").yank_deletions, + -- [""] = require("telescope-undo.actions").restore, + -- }, + -- n = { + -- ["y"] = require("telescope-undo.actions").yank_additions, + -- ["Y"] = require("telescope-undo.actions").yank_deletions, + -- ["u"] = require("telescope-undo.actions").restore, + -- }, + -- }, + -- side_by_side = true, + -- layout_strategy = "vertical", + -- layout_config = { + -- preview_height = 0.8, + -- }, + -- }, + -- }, + -- }, + -- config = function(_, opts) + -- -- Calling telescope's setup from multiple specs does not hurt, it will happily merge the + -- -- configs for us. We won't use data, as everything is in it's own namespace (telescope + -- -- defaults, as well as each extension). + -- require("telescope").setup(opts) + -- require("telescope").load_extension("undo") + -- end, } diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua index 011384c1..ed56f162 100755 --- a/lua/custom/plugins/telescope.lua +++ b/lua/custom/plugins/telescope.lua @@ -1,6 +1,7 @@ return { -- Fuzzy Finder (files, lsp, etc) 'nvim-telescope/telescope.nvim', + event = "VimEnter", branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', @@ -13,13 +14,14 @@ return { -- NOTE: If you are having trouble with this installation, -- refer to the README for telescope-fzf-native for more instructions. build = 'make', - cond = function() - return vim.fn.executable 'make' == 1 + config = function() + require('telescope').load_extension('fzf') end, }, 'nvim-tree/nvim-web-devicons', }, config = function() + -- Configure Telescope require('telescope').setup({ defaults = { mappings = { @@ -30,30 +32,19 @@ return { }, }, }) - -- Enable telescope fzf native, if installed - pcall(require('telescope').load_extension, 'fzf') -- 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 + local current_dir = current_file == '' and vim.fn.getcwd() or vim.fn.fnamemodify(current_file, ':h') -- 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] + 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 + print('Not a git repository. Searching on the current working directory.') + return vim.fn.getcwd() end return git_root end @@ -68,8 +59,8 @@ return { end end + -- Define a user command for live_grep_git_root vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) - - -- require("telescope").extensions.undo.undo() end, } + diff --git a/lua/custom/plugins/tree-sitter.lua b/lua/custom/plugins/tree-sitter.lua index 8c4d51df..c16b50ae 100755 --- a/lua/custom/plugins/tree-sitter.lua +++ b/lua/custom/plugins/tree-sitter.lua @@ -3,23 +3,22 @@ return { 'nvim-treesitter/nvim-treesitter', dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects', + 'https://github.com/apple/pkl-neovim.git', 'windwp/nvim-ts-autotag', }, build = ':TSUpdate', - -- setup autotag with default options - opts = { - enable = true, - }, config = function() - -- See `:help nvim-treesitter` - require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'lua', 'python', 'go', 'vimdoc', 'vim' }, - - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, - - highlight = { enable = true }, + -- Lazy loading of treesitter + local ts = require('nvim-treesitter.configs') + ts.setup({ + ensure_installed = { + 'c', 'cpp', 'lua', 'python', 'go', 'rust', 'vimdoc', 'vim' + }, + ignore_install = { '' }, + highlight = { + enable = true, + additional_vim_regex_highlighting = { 'markdown' }, + }, indent = { enable = true }, incremental_selection = { enable = true, @@ -33,9 +32,8 @@ return { textobjects = { select = { enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, keymaps = { - -- You can use the capture groups defined in textobjects.scm ['aa'] = '@parameter.outer', ['ia'] = '@parameter.inner', ['af'] = '@function.outer', @@ -46,7 +44,7 @@ return { }, move = { enable = true, - set_jumps = true, -- whether to set jumps in the jumplist + set_jumps = true, goto_next_start = { [']m'] = '@function.outer', [']]'] = '@class.outer', @@ -74,6 +72,17 @@ return { }, }, }, - } - end + }) + + -- Autotag setup + require('nvim-ts-autotag').setup({ + enable = true, + }) + end, + opts = { + autotag = { + enable = true, + }, + }, } + diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100755 index 00000000..acc8b660 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,15 @@ +return { + 'folke/trouble.nvim', + cmd = "Trouble", + opts = { + auto_open = false, + auto_close = true, + auto_preview = true, + auto_fold = true, + use_diagnostic_signs = true, + }, + keys = { + { "tt", "Trouble diagnostics toggle", desc = "Diagnostics (Trouble)" }, + }, +} + diff --git a/lua/custom/plugins/undotree.lua b/lua/custom/plugins/undotree.lua index c5d4ad9a..b6ed98dc 100755 --- a/lua/custom/plugins/undotree.lua +++ b/lua/custom/plugins/undotree.lua @@ -1,6 +1,6 @@ return { - -- 'mbbill/undotree', - -- config = function() - -- vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle, { desc = '[U]ndotree' }) - -- end + 'mbbill/undotree', + config = function() + vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle, { desc = '[U]ndotree' }) + end, } diff --git a/lua/custom/plugins/venv-selector.lua b/lua/custom/plugins/venv-selector.lua index 17f7b8ab..ad5a06c0 100755 --- a/lua/custom/plugins/venv-selector.lua +++ b/lua/custom/plugins/venv-selector.lua @@ -1,45 +1,40 @@ return { - "linux-cultist/venv-selector.nvim", - dependencies = { "neovim/nvim-lspconfig", "nvim-telescope/telescope.nvim" }, - event = "VeryLazy", -- Optional: needed only if you want to type `:VenvSelect` without a keymapping - keys = { - { - "vs", ":VenvSelect", - -- Key mapping for directly retrieving from cache. You may set an autocmd if you prefer the hands-free approach. - "vc", ":VenvSelectCached" - } - }, - config = function() - -- Function to find the nearest venv path in parent directories. - local function find_nearest_venv(starting_path) - local current_path = starting_path - while current_path do - local venv_path = current_path .. '/venv/bin/python' - if vim.fn.filereadable(venv_path) == 1 then - return venv_path - end - local parent_path = vim.fn.fnamemodify(current_path, ':h') - if parent_path == current_path then - break - end - current_path = parent_path - end - return nil - end + { + 'linux-cultist/venv-selector.nvim', + dependencies = { + 'neovim/nvim-lspconfig', + { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } }, + }, + ft = 'python', -- Load only for Python files + branch = 'regexp', -- This is the regexp branch, use this for the new version + opts = { + settings = { + options = { + -- If you put the callback here as a global option, its used for all searches (including the default ones by the plugin) + on_telescope_result_callback = function(filename) + return filename:gsub('/bin/python', '') + end, + }, + debug = true, - -- Get the path of the current file. - local current_file = vim.fn.expand('%:p') - - -- Get the venv path for the current project directory. - local venv_path = find_nearest_venv(current_file) - - if venv_path then - -- Activate the venv and use its Python interpreter. - vim.g.venv_selector_auto_activate = 1 - vim.g.python3_host_prog = venv_path - else - -- Fallback to a system-wide Python interpreter. - vim.g.python3_host_prog = '/usr/bin/python3' - end - end + search = { + my_venvs = { + command = 'fd -H -I python$ ~/Documents/Projects/', + on_telescope_result_callback = function(filename) + return filename:gsub('/bin/python', '') + end, + }, + my_conda_envs = { + command = 'fd -t l python$ /usr/local/Caskroom/miniforge/base/envs/', + on_telescope_result_callback = function(filename) + return filename:gsub('/bin/python', '') + end, + }, + }, + }, + }, + keys = { + { ',v', 'VenvSelect' }, + }, + }, } diff --git a/lua/custom/plugins/which-key.lua b/lua/custom/plugins/which-key.lua index 6f820e0f..5b7258bb 100755 --- a/lua/custom/plugins/which-key.lua +++ b/lua/custom/plugins/which-key.lua @@ -1,13 +1,18 @@ return { - "folke/which-key.nvim", - event = "VeryLazy", - init = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - end, + 'folke/which-key.nvim', + event = 'VimEnter', opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - } + plugins = { + marks = true, + registers = true, + spelling = { + enabled = true, + suggestions = 20, + }, + }, + windows = { + border = 'single', + }, + }, } + diff --git a/lua/custom/snippets/go.lua b/lua/custom/snippets/go.lua new file mode 100644 index 00000000..31f6dd87 --- /dev/null +++ b/lua/custom/snippets/go.lua @@ -0,0 +1,26 @@ +local ls = require('luasnip') + +local s = ls.snippet +local i = ls.insert_node +local t = ls.text_node + +local fmt = require('luasnip.extras.fmt').fmt + +ls.add_snippets('go', { + s('ee', { + t({ 'panic(' }), + i(1, 'err'), + t({ ')' }), + }), + s( + 'ei', + fmt( + [[ +if err != nil {{ + panic({}) +}} + ]], + { i(1, 'err') } + ) + ), +}) diff --git a/lua/custom/snippets/lua.lua b/lua/custom/snippets/lua.lua new file mode 100644 index 00000000..81d5d1fa --- /dev/null +++ b/lua/custom/snippets/lua.lua @@ -0,0 +1,20 @@ +local ls = require 'luasnip' + +local s = ls.snippet +local i = ls.insert_node +local t = ls.text_node + +ls.add_snippets('lua', { + s('lr', { + t 'local ', + i(1, 'module'), + t ' = require("', + i(2, 'module'), + t '")', + }), + s('pr', { + t 'print(', + i(1, 'text'), + t ')', + }), +}) diff --git a/lua/custom/snippets/pyhton.lua b/lua/custom/snippets/pyhton.lua new file mode 100644 index 00000000..cfce5500 --- /dev/null +++ b/lua/custom/snippets/pyhton.lua @@ -0,0 +1,15 @@ +local ls = require('luasnip') + +local s = ls.snippet +local i = ls.insert_node +local t = ls.text_node + +ls.add_snippets('python', { + s('log', { + t({ 'LOG.' }), + i(1, 'level'), + t({ '(' }), + i(2, 'message'), + t({ ')' }), + }), +})