diff --git a/README.md b/README.md index a04da26..31edf94 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ - **Modular Structure**: Organized Lua scripts for readability and easy customization. - **Language Support**: Automated setup for various languages using Mason.nvim. -- **Keybindings**: Streamlined shortcuts for productivity, detailed in `lua/plugins/configs/whichkey.lua`. +- **Keybindings**: Streamlined shortcuts for productivity, detailed in `lua/plugins/tools/whichkey.lua`. - **Plugins**: Handpicked plugins managed via Lazy.nvim for enhanced functionality. ## System dependencies diff --git a/dotfyle.json b/dotfyle.json index 438e326..c8cd9ab 100644 --- a/dotfyle.json +++ b/dotfyle.json @@ -1 +1 @@ -{"distribution": "custom", "masonTools": ["bash-language-server", "beautysh", "black", "clangd", "codespell", "cspell", "djlint", "emmet-ls", "eslint_d", "isort", "jdtls", "lua-language-server", "markdownlint", "phpcs", "prettier", "prettierd", "pylint", "pyright", "pyright-langserver", "ruff", "rust-analyzer", "selene", "stylua", "tailwindcss-language-server", "taplo", "trivy", "typescript-language-server", "vscode-css-language-server", "vscode-html-language-server", "yaml-language-server"], "plugins": ["2kabhishek/nerdy.nvim", "2kabhishek/termim.nvim", "Bilal2453/luvit-meta", "Exafunction/codeium.vim", "HiPhish/rainbow-delimiters.nvim", "L3MON4D3/LuaSnip", "LudoPinelli/comment-box.nvim", "LunarVim/bigfile.nvim", "MunifTanjim/nui.nvim", "ThePrimeagen/refactoring.nvim", "ThePrimeagen/vim-be-good", "akinsho/toggleterm.nvim", "altermo/ultimate-autopair.nvim", "andymass/vim-matchup", "creativenull/dotfyle-metadata.nvim", "cvigilv/esqueleto.nvim", "debugloop/telescope-undo.nvim", "eandrju/cellular-automaton.nvim", "echasnovski/mini.files", "echasnovski/mini.icons", "echasnovski/mini.nvim", "epwalsh/pomo.nvim", "folke/lazy.nvim", "folke/lazydev.nvim", "folke/noice.nvim", "folke/persistence.nvim", "folke/trouble.nvim", "folke/twilight.nvim", "folke/which-key.nvim", "folke/zen-mode.nvim", "gbprod/yanky.nvim", "ggandor/leap.nvim", "hrsh7th/cmp-buffer", "hrsh7th/cmp-cmdline", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp-signature-help", "hrsh7th/cmp-nvim-lua", "hrsh7th/cmp-path", "hrsh7th/nvim-cmp", "iamcco/markdown-preview.nvim", "j-hui/fidget.nvim", "kawre/leetcode.nvim", "kristijanhusak/vim-dadbod-completion", "kristijanhusak/vim-dadbod-ui", "lambdalisue/suda.vim", "linux-cultist/venv-selector.nvim", "lukas-reineke/indent-blankline.nvim", "m-demare/hlargs.nvim", "m4xshen/hardtime.nvim", "max397574/better-escape.nvim", "mbbill/undotree", "meznaric/key-analyzer.nvim", "mfussenegger/nvim-dap", "mfussenegger/nvim-dap-python", "mfussenegger/nvim-lint", "mg979/vim-visual-multi", "michaelb/sniprun", "mistricky/codesnap.nvim", "mstuttgart/odoo-snippets", "mvllow/modes.nvim", "nacro90/numb.nvim", "navarasu/onedark.nvim", "neovim/nvim-lspconfig", "numToStr/Navigator.nvim", "nvchad/showkeys", "nvim-lua/plenary.nvim", "nvim-lualine/lualine.nvim", "nvim-neo-tree/neo-tree.nvim", "nvim-neotest/neotest", "nvim-neotest/neotest-jest", "nvim-neotest/neotest-python", "nvim-neotest/nvim-nio", "nvim-pack/nvim-spectre", "nvim-telescope/telescope-file-browser.nvim", "nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope-symbols.nvim", "nvim-telescope/telescope-ui-select.nvim", "nvim-telescope/telescope.nvim", "nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter-context", "nvim-treesitter/nvim-treesitter-textobjects", "nvimdev/dashboard-nvim", "nvimdev/lspsaga.nvim", "olimorris/neotest-rspec", "onsails/lspkind.nvim", "rafamadriz/friendly-snippets", "rcarriga/nvim-dap-ui", "rcarriga/nvim-notify", "rshkarin/mason-nvim-lint", "saadparwaiz1/cmp_luasnip", "sedm0784/vim-rainbow-trails", "smjonas/inc-rename.nvim", "stevearc/conform.nvim", "stevearc/dressing.nvim", "ton/vim-alternate", "tpope/vim-dadbod", "uga-rosa/ccc.nvim", "wakatime/vim-wakatime", "williamboman/mason-lspconfig.nvim", "williamboman/mason.nvim", "willothy/flatten.nvim", "windwp/nvim-ts-autotag", "zapling/mason-conform.nvim", "zapling/mason-lock.nvim"], "pluginManager": "lazy.nvim", "treesitterParsers": ["bash", "c", "css", "diff", "gitcommit", "html", "java", "javascript", "json", "liquid", "lua", "luadoc", "markdown", "markdown_inline", "python", "scss", "tsx", "typescript", "vim", "vimdoc"], "lspServers": ["bashls", "clangd", "cssls", "emmet_ls", "html", "jdtls", "lua_ls", "pyright", "ruff", "rust_analyzer", "tailwindcss", "taplo", "ts_ls", "yamlls"], "leaderKey": ""} \ No newline at end of file +{"distribution": "custom", "masonTools": ["bash-language-server", "gopls", "hadolint", "jdtls", "lua-language-server", "pyright", "pyright-langserver", "rubocop", "ruff", "rust-analyzer", "shellcheck", "solargraph", "typescript-language-server", "typos-lsp", "vim-language-server", "vscode-eslint-language-server", "vscode-json-language-server"], "plugins": ["2kabhishek/markit.nvim", "2kabhishek/nerdy.nvim", "2kabhishek/termim.nvim", "CopilotC-Nvim/CopilotChat.nvim", "Exafunction/codeium.vim", "LudoPinelli/comment-box.nvim", "MunifTanjim/nui.nvim", "RRethy/nvim-treesitter-endwise", "RRethy/nvim-treesitter-textsubjects", "ThePrimeagen/refactoring.nvim", "ThePrimeagen/vim-be-good", "abecodes/tabout.nvim", "akinsho/toggleterm.nvim", "chrisgrieser/nvim-spider", "creativenull/dotfyle-metadata.nvim", "cvigilv/esqueleto.nvim", "debugloop/telescope-undo.nvim", "echasnovski/mini.ai", "echasnovski/mini.surround", "epwalsh/pomo.nvim", "folke/flash.nvim", "folke/lazy.nvim", "folke/lazydev.nvim", "folke/snacks.nvim", "folke/which-key.nvim", "giuxtaposition/blink-cmp-copilot", "iamcco/markdown-preview.nvim", "jay-babu/mason-null-ls.nvim", "lewis6991/gitsigns.nvim", "m4xshen/hardtime.nvim", "mfussenegger/nvim-dap", "michaelb/sniprun", "mistricky/codesnap.nvim", "navarasu/onedark.nvim", "neovim/nvim-lspconfig", "numToStr/Navigator.nvim", "nvchad/showkeys", "nvim-lua/plenary.nvim", "nvim-lualine/lualine.nvim", "nvim-neo-tree/neo-tree.nvim", "nvim-neotest/neotest", "nvim-neotest/neotest-jest", "nvim-neotest/neotest-python", "nvim-neotest/nvim-nio", "nvim-telescope/telescope-file-browser.nvim", "nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope.nvim", "nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter-refactor", "nvim-treesitter/nvim-treesitter-textobjects", "nvimdev/lspsaga.nvim", "nvimtools/none-ls.nvim", "olimorris/neotest-rspec", "rafamadriz/friendly-snippets", "rcarriga/nvim-dap-ui", "rcarriga/nvim-notify", "ruifm/gitlinker.nvim", "saghen/blink.cmp", "stevearc/dressing.nvim", "tpope/vim-fugitive", "tpope/vim-rails", "uga-rosa/ccc.nvim", "wakatime/vim-wakatime", "weizheheng/ror.nvim", "williamboman/mason-lspconfig.nvim", "williamboman/mason.nvim", "windwp/nvim-autopairs", "windwp/nvim-spectre", "windwp/nvim-ts-autotag", "zapling/mason-lock.nvim", "zbirenbaum/copilot.lua"], "pluginManager": "lazy.nvim", "treesitterParsers": ["bash", "c", "css", "dart", "elixir", "gitcommit", "go", "html", "java", "javascript", "json", "lua", "markdown", "markdown_inline", "python", "ruby", "rust", "scss", "typescript", "vim", "vimdoc", "yaml"], "lspServers": ["bashls", "eslint", "gopls", "jdtls", "jsonls", "lua_ls", "pyright", "rubocop", "ruff", "rust_analyzer", "solargraph", "ts_ls", "typos_lsp", "vimls"], "leaderKey": ""} \ No newline at end of file diff --git a/init.lua b/init.lua index 10b4a2b..1adfab1 100644 --- a/init.lua +++ b/init.lua @@ -2,4 +2,6 @@ require('core.options') require('core.functions') require('core.keys') require('core.autocmd') -require('core.lazy') +require('plugins.lazy') +-- Add user configs to this module +pcall(require, 'user') diff --git a/lua/core/autocmd.lua b/lua/core/autocmd.lua index 9db6ea3..7752deb 100644 --- a/lua/core/autocmd.lua +++ b/lua/core/autocmd.lua @@ -1,11 +1,8 @@ local function augroup(name) - return vim.api.nvim_create_augroup('nvim' .. name, { clear = true }) + return vim.api.nvim_create_augroup('nvim2k_' .. name, { clear = true }) end --- ╭───────────────────────────────────────────────────────────────────╮ --- │ Strip trailing spaces before write │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- Strip trailing spaces before write vim.api.nvim_create_autocmd({ 'BufWritePre' }, { group = augroup('strip_space'), pattern = { '*' }, @@ -14,19 +11,13 @@ vim.api.nvim_create_autocmd({ 'BufWritePre' }, { end, }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ Check if we need to reload the file when it changed │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- Check if we need to reload the file when it changed vim.api.nvim_create_autocmd({ 'FocusGained', 'TermClose', 'TermLeave' }, { group = augroup('checktime'), command = 'checktime', }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ Highlight on yank │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- Highlight on yank vim.api.nvim_create_autocmd('TextYankPost', { group = augroup('highlight_yank'), callback = function() @@ -34,10 +25,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ resize splits if window got resized │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- resize splits if window got resized vim.api.nvim_create_autocmd({ 'VimResized' }, { group = augroup('resize_splits'), callback = function() @@ -45,10 +33,7 @@ vim.api.nvim_create_autocmd({ 'VimResized' }, { end, }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ go to last loc when opening a buffer │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- go to last loc when opening a buffer vim.api.nvim_create_autocmd('BufReadPost', { group = augroup('last_loc'), callback = function() @@ -60,10 +45,7 @@ vim.api.nvim_create_autocmd('BufReadPost', { end, }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ close some filetypes with │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- close some filetypes with vim.api.nvim_create_autocmd('FileType', { group = augroup('close_with_q'), pattern = { @@ -71,6 +53,7 @@ vim.api.nvim_create_autocmd('FileType', { 'Jaq', 'PlenaryTestPopup', 'fugitive', + 'git', 'help', 'lir', 'lspinfo', @@ -87,10 +70,7 @@ vim.api.nvim_create_autocmd('FileType', { end, }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ wrap and check for spell in text filetypes │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- wrap and check for spell in text filetypes vim.api.nvim_create_autocmd('FileType', { group = augroup('wrap_spell'), pattern = { 'gitcommit', 'markdown' }, @@ -100,11 +80,7 @@ vim.api.nvim_create_autocmd('FileType', { end, }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ Auto create dir when saving a file, in case some intermediate │ --- │ directory does not exist │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- Auto create dir when saving a file, in case some intermediate directory does not exist vim.api.nvim_create_autocmd({ 'BufWritePre' }, { group = augroup('auto_create_dir'), callback = function(event) @@ -113,20 +89,14 @@ vim.api.nvim_create_autocmd({ 'BufWritePre' }, { end, }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ Set arb filetype │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- Set arb filetype vim.api.nvim_create_autocmd({ 'BufEnter' }, { group = augroup('set_file_type'), pattern = { '*.arb' }, command = require('lib.util').get_file_type_cmd('arb'), }) --- ╭───────────────────────────────────────────────────────────────────╮ --- │ Disable format options │ --- ╰───────────────────────────────────────────────────────────────────╯ - +-- Disable format options vim.api.nvim_create_autocmd('FileType', { group = augroup('disable_formatoptions'), pattern = '*', @@ -135,77 +105,22 @@ vim.api.nvim_create_autocmd('FileType', { end, }) -vim.api.nvim_create_autocmd('BufReadPost', { - callback = function() - if vim.fn.line('\'"') > 1 and vim.fn.line('\'"') <= vim.fn.line('$') then - vim.cmd('normal! g`"') - end - end, - group = augroup('General'), - desc = 'Go To The Last Cursor Position', -}) +local function enable_autoformat() + vim.api.nvim_create_autocmd({ 'BufWritePre' }, { + group = augroup('autoformat'), + pattern = { '*' }, + callback = function() + vim.lsp.buf.format() + end, + }) +end -vim.api.nvim_create_autocmd('FileType', { - pattern = { 'c', 'cpp', 'py', 'java', 'cs' }, - callback = function() - vim.bo.shiftwidth = 4 - end, - group = augroup('General'), - desc = 'Set shiftwidth to 4 in these filetypes', -}) +enable_autoformat() --- Toggle between relative/absolute line numbers -local numbertoggle = augroup('numbertoggle') -vim.api.nvim_create_autocmd({ 'BufEnter', 'FocusGained', 'InsertLeave', 'CmdlineLeave', 'WinEnter' }, { - pattern = '*', - group = numbertoggle, - callback = function() - if vim.o.nu and vim.api.nvim_get_mode().mode ~= 'i' then - vim.opt.relativenumber = true - end - end, -}) - -vim.api.nvim_create_autocmd({ 'BufLeave', 'FocusLost', 'InsertEnter', 'CmdlineEnter', 'WinLeave' }, { - pattern = '*', - group = numbertoggle, - callback = function() - if vim.o.nu then - vim.opt.relativenumber = false - vim.cmd.redraw() - end - end, -}) - --- ╭─────────────────────────────────────────────────────────╮ --- │ VIM-VISUAL-MULTI │ --- ╰─────────────────────────────────────────────────────────╯ -local visual_multi_group = vim.api.nvim_create_augroup('VisualMulti', { clear = true }) -vim.api.nvim_create_autocmd('User', { - pattern = 'visual_multi_start', - callback = function() - -- vim.cmd('NoiceDisable') - vim.lsp.inlay_hint.enable(false) - end, - group = visual_multi_group, -}) -vim.api.nvim_create_autocmd('User', { - pattern = 'visual_multi_exit', - callback = function() - -- vim.cmd('NoiceEnable') - vim.lsp.inlay_hint.enable(true) - end, - group = visual_multi_group, -}) - --- ╭─────────────────────────────────────────────────────────╮ --- │ MESSAGE IF MACRO IS STOPPED │ --- ╰─────────────────────────────────────────────────────────╯ -local macro_group = vim.api.nvim_create_augroup('MacroRecording', { clear = true }) -vim.api.nvim_create_autocmd('RecordingLeave', { - group = macro_group, - callback = function() - -- Display a message when macro recording stops - print('Macro recording stopped') - end, -}) +vim.api.nvim_create_user_command('WriteNoFormat', function() + -- Temporarily disable the autoformat autocmd + vim.api.nvim_del_augroup_by_name('nvim2k_autoformat') + vim.cmd('write') + -- Re-enable the autoformat autocmd + enable_autoformat() +end, {}) diff --git a/lua/core/functions.lua b/lua/core/functions.lua index b2a1bce..9f197ae 100644 --- a/lua/core/functions.lua +++ b/lua/core/functions.lua @@ -10,22 +10,38 @@ vim.api.nvim_create_user_command('ReloadConfig', function() vim.notify('Nvim configuration reloaded!', vim.log.levels.INFO) end, {}) +local function copy_to_clipboard(content, message) + vim.fn.setreg('+', content) + vim.notify('Copied "' .. content .. '" to the clipboard!', vim.log.levels.INFO) +end + vim.api.nvim_create_user_command('CopyRelativePath', function() local path = vim.fn.expand('%') - vim.fn.setreg('+', path) - vim.notify('Copied "' .. path .. '" to the clipboard!') + copy_to_clipboard(path, 'Copied "' .. path .. '" to the clipboard!') end, {}) vim.api.nvim_create_user_command('CopyAbsolutePath', function() local path = vim.fn.expand('%:p') - vim.fn.setreg('+', path) - vim.notify('Copied "' .. path .. '" to the clipboard!') + copy_to_clipboard(path, 'Copied "' .. path .. '" to the clipboard!') +end, {}) + +vim.api.nvim_create_user_command('CopyRelativePathWithLine', function() + local path = vim.fn.expand('%') + local line = vim.fn.line('.') + local result = path .. ':' .. line + copy_to_clipboard(result, 'Copied "' .. result .. '" to the clipboard!') +end, {}) + +vim.api.nvim_create_user_command('CopyAbsolutePathWithLine', function() + local path = vim.fn.expand('%:p') + local line = vim.fn.line('.') + local result = path .. ':' .. line + copy_to_clipboard(result, 'Copied "' .. result .. '" to the clipboard!') end, {}) vim.api.nvim_create_user_command('CopyFileName', function() local path = vim.fn.expand('%:t') - vim.fn.setreg('+', path) - vim.notify('Copied "' .. path .. '" to the clipboard!') + copy_to_clipboard(path, 'Copied "' .. path .. '" to the clipboard!') end, {}) -- Switch to git root or file parent dir diff --git a/lua/core/keys.lua b/lua/core/keys.lua index afa7a0f..a45545a 100644 --- a/lua/core/keys.lua +++ b/lua/core/keys.lua @@ -18,18 +18,6 @@ vim.g.maplocalleader = ' ' map({ 'n', 'v' }, '/', 'gcc', { desc = 'Comment toggle', remap = true }) map({ 'v', 'x' }, '/', 'gc', { desc = 'Comment toggle', remap = true }) --- save file -map({ 'x', 'i', 'n', 's' }, '', 'w', { desc = 'Save File' }) - --- Shortcut for surrounding a word (inner) with a ' -map('n', 'S', '') -- Don't keep S mapping -map('n', 'Sq', "Siw'", { desc = "Wrap word with '", remap = true }) -map('n', 'Sp', 'SiW(', { desc = 'Wrap word with ()', remap = true }) -map('n', 'Sb', 'Saw}', { desc = 'Wrap word with {}', remap = true }) - --- Remove all text -map('n', 'r', '%d+', { desc = 'General | Remove All Text', silent = true }) - -- Able to use semicolon in normal mode map('n', ';', ':', { desc = '; Command mode' }) @@ -79,6 +67,12 @@ map({ 'v', 'x' }, 'K', ":move '<-2gv-gv", opts) -- Clear search, diff update and redraw map({ 'i', 'n' }, '', 'noh', { desc = 'Escape and clear hlsearch' }) +-- Cursor navigation on insert mode +map('i', '', '', { desc = 'Move Cursor Left' }) +map('i', '', '', { desc = 'Move Cursor Left' }) +map('i', '', '', { desc = 'Move Cursor Left' }) +map('i', '', '', { desc = 'Move Cursor Left' }) + -- Consistent n/N search navigation map('n', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' }) map('x', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' }) @@ -96,59 +90,10 @@ map('i', ',', ',u') map('i', '.', '.u') map('i', ';', ';u') -map('n', 'd', '"_d', { desc = 'Delete without replacing clipboad' }) -map('n', 'x', '"_x', { desc = 'Cut without replacing clipboad' }) -map('n', 'c', '"_c', { desc = 'Change without replacing clipboad' }) -map('v', 'p', '"_dP', { desc = 'Paste without replacing clipboard' }) - -map('n', 'oz', function() - ---@diagnostic disable-next-line: undefined-field - if vim.opt.foldcolumn:get() == '0' then - vim.opt.foldcolumn = '1' - else - vim.opt.foldcolumn = '0' - end -end, { desc = 'Toggle foldcolumn' }) - -map('n', 'op', function() - vim.g.minipairs_disable = not vim.g.minipairs_disable and true or false -end, { desc = 'Toggle mini.pairs' }) - --- -- Indent backward --- vim.keymap.set("n", "<", "<<", { desc = "General | Indent backward", silent = true }) --- --- -- Indent forward --- vim.keymap.set("n", ">", ">>", { desc = "General | Indent forward", silent = true }) --- --- -- Move the line up --- vim.keymap.set("n", "", "m .+1==", { desc = "General | Move the line up", silent = true }) --- --- -- Move the line down --- vim.keymap.set("n", "", "m .-2==", { desc = "General | Move the line down", silent = true }) --- --- -- Move the line up (Insert Mode) --- vim.keymap.set("i", "", ":m .+1==gi", { desc = "General | Move the line up", silent = true }) --- --- -- Move the line down (Insert Mode) --- vim.keymap.set("i", "", ":m .-2==gi", { desc = "General | Move the line down", silent = true }) --- --- -- Better Down (Visual Mode) --- vim.keymap.set("v", "j", "v:count == 0 ? 'gj' : 'j'", { desc = "General | Better Down", expr = true, silent = true }) --- --- -- Better Up (Visual Mode) --- vim.keymap.set("v", "k", "v:count == 0 ? 'gk' : 'k'", { desc = "General | Better Up", expr = true, silent = true }) --- --- -- Better Paste (Visual Mode) --- vim.keymap.set("v", "p", '"_dP', { desc = "General | Better Paste", silent = true }) --- --- -- Indent backward (Visual Mode) --- vim.keymap.set("v", "<", "", ">gv", { desc = "General | Indent forward", silent = true }) --- --- -- Move the selected text up (Visual Mode) --- vim.keymap.set("v", "", "m '>+1gv=gv", { desc = "General | Move the selected text up", silent = true }) --- --- -- Move the selected text down (Visual Mode) --- vim.keymap.set("v", "", "m '<-2gv=gv", { desc = "General | Move the selected text down", silent = true }) +-- Move Lines +vim.keymap.set('n', '', ':m .+1==', { desc = 'Move lines', silent = true }) +vim.keymap.set('v', '', ":m '>+1gv=gv", { desc = 'Move lines', silent = true }) +vim.keymap.set('i', '', ':m .+1==gi', { desc = 'Move lines', silent = true }) +vim.keymap.set('n', '', ':m .-2==', { desc = 'Move lines', silent = true }) +vim.keymap.set('v', '', ":m '<-2gv=gv", { desc = 'Move lines', silent = true }) +vim.keymap.set('i', '', ':m .-2==gi', { desc = 'Move lines', silent = true }) diff --git a/lua/core/options.lua b/lua/core/options.lua index f09d8e1..d1c889b 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -20,12 +20,11 @@ local options = { ignorecase = true, -- ignore case in search patterns inccommand = 'split', -- preview incremental substitute laststatus = 3, - title = true, -- title for context - list = false, - -- listchars = { trail = "", tab = "", nbsp = "_", extends = ">", precedes = "<" }, -- highlight + list = true, + -- listchars = { trail = '', tab = '', nbsp = '_', extends = '>', precedes = '<' }, -- highlight mouse = 'a', -- allow the mouse to be used in neovim number = true, -- set numbered lines - numberwidth = 4, -- set number column width to 3 {default 4} + numberwidth = 4, -- set number column width to 2 {default 4} pumblend = 10, -- Popup blen pumheight = 10, -- pop up menu height relativenumber = true, -- set relative numbered lines @@ -48,6 +47,7 @@ local options = { tabstop = 4, -- insert 2 spaces for a tab termguicolors = true, -- set term gui colors (most terminals support this) timeoutlen = 300, -- time to wait for a mapped sequence to complete (in milliseconds) + title = true, -- window titles undofile = true, -- enable persistent undo undolevels = 10000, updatetime = 50, -- faster completion (4000ms default) diff --git a/lua/lib/icons.lua b/lua/lib/icons.lua index 00bcf56..40a5236 100644 --- a/lua/lib/icons.lua +++ b/lua/lib/icons.lua @@ -39,6 +39,7 @@ return { Color = ' ', Constant = ' ', Constructor = '󰈏 ', + Copilot = ' ', Enum = ' ', EnumMember = ' ', Event = ' ', @@ -97,6 +98,7 @@ return { Dashboard = ' ', Database = ' ', Download = ' ', + Edit = ' ', Edge = '│ ', Electric = ' ', Eye = ' ', diff --git a/lua/lib/util.lua b/lua/lib/util.lua index 3ab34a5..b2f3de1 100644 --- a/lua/lib/util.lua +++ b/lua/lib/util.lua @@ -1,66 +1,66 @@ local util = {} util.get_user_config = function(key, default) - local status_ok, user = pcall(require, "user") - if not status_ok then - return default - end + local status_ok, user = pcall(require, 'user') + if not status_ok then + return default + end - local user_config = user[key] - if user_config == nil then - return default - end - return user_config + local user_config = user[key] + if user_config == nil then + return default + end + return user_config end util.get_root_dir = function() - local bufname = vim.fn.expand("%:p") - if vim.fn.filereadable(bufname) == 0 then - return - end + local bufname = vim.fn.expand('%:p') + if vim.fn.filereadable(bufname) == 0 then + return + end - local parent = vim.fn.fnamemodify(bufname, ":h") - local git_root = vim.fn.systemlist("git -C " .. parent .. " rev-parse --show-toplevel") - if #git_root > 0 and git_root[1] ~= "" then - return git_root[1] - else - return parent - end + local parent = vim.fn.fnamemodify(bufname, ':h') + local git_root = vim.fn.systemlist('git -C ' .. parent .. ' rev-parse --show-toplevel') + if #git_root > 0 and git_root[1] ~= '' then + return git_root[1] + else + return parent + end end util.get_file_type_cmd = function(extension) - local root = util.get_root_dir() + local root = util.get_root_dir() - if extension == "arb" and root then - local gemfile_exists = vim.fn.filereadable(root .. "/Gemfile") == 1 - local pubspec_exists = vim.fn.filereadable(root .. "/pubspec.yaml") == 1 - if gemfile_exists then - return "setfiletype ruby" - end - if pubspec_exists then - return "setfiletype json" - end - end - return "" + if extension == 'arb' and root then + local gemfile_exists = vim.fn.filereadable(root .. '/Gemfile') == 1 + local pubspec_exists = vim.fn.filereadable(root .. '/pubspec.yaml') == 1 + if gemfile_exists then + return 'setfiletype ruby' + end + if pubspec_exists then + return 'setfiletype json' + end + end + return '' end util.is_present = function(bin) - return vim.fn.executable(bin) == 1 + return vim.fn.executable(bin) == 1 end util.telescope_select = function(options, options_desc, select_prompt) - require("telescope.pickers") - .new({}, { - prompt_title = select_prompt, - results_title = options_desc, - finder = require("telescope.finders").new_table({ - results = options, - entry_maker = require("telescope.make_entry").gen_from_file(), - }), - sorter = require("telescope.sorters").get_fzy_sorter(), - previewer = require("telescope.previewers").vim_buffer_cat.new({}), - }) - :find() + require('telescope.pickers') + .new({}, { + prompt_title = select_prompt, + results_title = options_desc, + finder = require('telescope.finders').new_table({ + results = options, + entry_maker = require('telescope.make_entry').gen_from_file(), + }), + sorter = require('telescope.sorters').get_fzy_sorter(), + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + }) + :find() end return util diff --git a/lua/lock.json b/lua/lock.json deleted file mode 100644 index 905b4d6..0000000 --- a/lua/lock.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "LuaSnip": { "branch": "master", "commit": "33b06d72d220aa56a7ce80a0dd6f06c70cd82b9d" }, - "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, - "better-escape.nvim": { "branch": "master", "commit": "199dcc2643dec5d8dbdab4ec672cf405224dcb3b" }, - "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, - "ccc.nvim": { "branch": "main", "commit": "7c639042583c7bdc7ce2e37e5a0e0aa6d0659c6a" }, - "cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" }, - "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, - "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "codeium.vim": { "branch": "main", "commit": "d152e6cd3d814a44f36447bb0d21d51f6787fe9c" }, - "codesnap.nvim": { "branch": "main", "commit": "6400480aa6cc366cbd931146c429aaa64680dab9" }, - "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, - "conform.nvim": { "branch": "master", "commit": "e76afe8f7976071fae308e31bf426f557a8ef339" }, - "dashboard-nvim": { "branch": "master", "commit": "ae309606940d26d8c9df8b048a6e136b6bbec478" }, - "dotfyle-metadata.nvim": { "branch": "main", "commit": "342ef8f3f98f3ccc451c9cf2be74e95149ced05d" }, - "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, - "esqueleto.nvim": { "branch": "main", "commit": "0f79ccafc931f706d175549c1339848eb8fa8470" }, - "fidget.nvim": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" }, - "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, - "flatten.nvim": { "branch": "main", "commit": "e420e531d2ab24aebcf7b3c9fca28e6c5c34964d" }, - "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "hardtime.nvim": { "branch": "main", "commit": "027d6f991927a71bd510a7673ae5bb404ca2a1c7" }, - "hlargs.nvim": { "branch": "main", "commit": "53ec5d8ca6ed012de5545ba83ea1eb3d636b09fb" }, - "inc-rename.nvim": { "branch": "main", "commit": "1871ca49ae6ee3e9ebee37955ba10c7b1425974f" }, - "indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" }, - "key-analyzer.nvim": { "branch": "main", "commit": "15d2663dd5014ef2814f2df1edc04494f2c1ee56" }, - "lazy.nvim": { "branch": "main", "commit": "014d1d6d78df4e58f962158e6e00261d8632612c" }, - "lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" }, - "leap.nvim": { "branch": "main", "commit": "c6bfb191f1161fbabace1f36f578a20ac6c7642c" }, - "leetcode.nvim": { "branch": "master", "commit": "98136532e61f6eb6a51b8130a8bbf73ccdee3d51" }, - "lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, - "lspsaga.nvim": { "branch": "main", "commit": "aa1a9ef63a6baa37b2e59c08c78bdd4b8b22ac6f" }, - "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, - "luvit-meta": { "branch": "main", "commit": "57d464c4acb5c2e66bd4145060f5dc9e96a7bbb7" }, - "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-conform.nvim": { "branch": "main", "commit": "abce2be529f3b4b336c56d0ba6336a9144e0fee6" }, - "mason-lock.nvim": { "branch": "main", "commit": "86614f76c3442fba1c5c8d79aa1efcb3ad69de1c" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "8e46de9241d3997927af12196bd8faa0ed08c29a" }, - "mason-nvim-lint": { "branch": "main", "commit": "910dadb99cb2bf0d5176026c7a4ab1861c4e561f" }, - "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.files": { "branch": "main", "commit": "84efb81e5207ae8c41f54abdafb79c6212fc0971" }, - "mini.icons": { "branch": "main", "commit": "54686be7d58807906cb2c8c2216e0bf9c044f19a" }, - "mini.nvim": { "branch": "main", "commit": "2435d0de00174a45d6b352fefeaa6008ebe9f23b" }, - "modes.nvim": { "branch": "main", "commit": "3188692abf02a8838ec75e59d68c2ce3e4323f5c" }, - "neo-tree.nvim": { "branch": "main", "commit": "ca340e0747a85a05c08a5ba5e183c70c0a355a7c" }, - "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" }, - "neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" }, - "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" }, - "neotest-rspec": { "branch": "main", "commit": "f8c91edc5dd87ca467a624652f365ac217d7cc1c" }, - "nerdy.nvim": { "branch": "main", "commit": "719ed52244b34ea9de08f074e0d22fd67d615640" }, - "noice.nvim": { "branch": "main", "commit": "7b1960c48078a8b2fb44a89db82f4fa637b2d7c8" }, - "nui.nvim": { "branch": "main", "commit": "b1b9b75a2d8041e1c2234f7448c61f8468a4258d" }, - "numb.nvim": { "branch": "master", "commit": "3f7d4a74bd456e747a1278ea1672b26116e0824d" }, - "nvim-cmp": { "branch": "main", "commit": "ca4d3330d386e76967e53b85953c170658255ecb" }, - "nvim-dap": { "branch": "master", "commit": "580d6e526358afd0e4bba053e68fd59cf581a161" }, - "nvim-dap-python": { "branch": "master", "commit": "34282820bb713b9a5fdb120ae8dd85c2b3f49b51" }, - "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, - "nvim-lint": { "branch": "master", "commit": "6b46370d02cd001509a765591a3ffc481b538794" }, - "nvim-lspconfig": { "branch": "master", "commit": "b8b725659fa60d2c5f5bd7459bcfee1d8b34acd5" }, - "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" }, - "nvim-spectre": { "branch": "master", "commit": "08be31c104df3b4b049607694ebb2b6ced4f928b" }, - "nvim-treesitter": { "branch": "master", "commit": "0c26a5c4bc407fdbca545ab25cf6084fd069444b" }, - "nvim-treesitter-context": { "branch": "master", "commit": "3288c5af7d3820d716272f1d05ab661cc540a5d6" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, - "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, - "odoo-snippets": { "branch": "main", "commit": "5e6b7191e3ea60bba00df6cdbc031291b194768d" }, - "onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, - "persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" }, - "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "pomo.nvim": { "branch": "main", "commit": "aa8decc421d89be0f10b1fc6a602cdd269f350ff" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "e9dfb4582b9ca0ab7e987c65999f662242bd6f61" }, - "refactoring.nvim": { "branch": "master", "commit": "2db6d378e873de31d18ade549c2edba64ff1c2e3" }, - "showkeys": { "branch": "main", "commit": "3c62fd88e685fd08f0f2724e1c0856d77dd0d552" }, - "sniprun": { "branch": "master", "commit": "67ac2d84d03f3b857d59571ff5fefb6080dffa2d" }, - "suda.vim": { "branch": "master", "commit": "9adda7d195222d4e2854efb2a88005a120296c47" }, - "telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, - "telescope-symbols.nvim": { "branch": "master", "commit": "a6d0127a53d39b9fc2af75bd169d288166118aec" }, - "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope-undo.nvim": { "branch": "main", "commit": "2971cc9f193ec09e0c5de3563f99cbea16b63f10" }, - "telescope.nvim": { "branch": "master", "commit": "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc" }, - "termim.nvim": { "branch": "main", "commit": "58344167abb97bcef9bf720a762ea653a94e9daa" }, - "toggleterm.nvim": { "branch": "main", "commit": "022ff5594acccc8d90d2e46dc43994f7722ebdf7" }, - "trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" }, - "twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" }, - "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "9e3209190c22953566ae4e6436ad2b4ff4dabb95" }, - "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, - "venv-selector.nvim": { "branch": "regexp", "commit": "e82594274bf7b54387f9a2abe65f74909ac66e97" }, - "vim-alternate": { "branch": "master", "commit": "b3b7d5e9982f228a4d62fbbe2f2fe3e3ae92768c" }, - "vim-be-good": { "branch": "master", "commit": "0ae3de14eb8efc6effe7704b5e46495e91931cc5" }, - "vim-dadbod": { "branch": "master", "commit": "fe5a55e92b2dded7c404006147ef97fb073d8b1b" }, - "vim-dadbod-completion": { "branch": "master", "commit": "04485bfb53a629423233a4178d71cd4f8abf7406" }, - "vim-dadbod-ui": { "branch": "master", "commit": "7f89265a84fc003ccfa500fd99b9fea9db2c75c7" }, - "vim-matchup": { "branch": "master", "commit": "5fb083de1e06fdd134c6ad8d007d4b5576b25ba7" }, - "vim-rainbow-trails": { "branch": "main", "commit": "579ab828f362dcfbe188377eede4f0dba7b73b27" }, - "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" }, - "vim-wakatime": { "branch": "master", "commit": "cf51327a9e08935569614d1cb24e779ee9f45519" }, - "which-key.nvim": { "branch": "main", "commit": "9b365a6428a9633e3eeb34dbef1b791511c54f70" }, - "yanky.nvim": { "branch": "main", "commit": "f9b905994cccf3c55f41af3a0a1f4c76c844e411" }, - "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } -} diff --git a/lua/mason-lock.json b/lua/mason-lock.json deleted file mode 100644 index 43ca87b..0000000 --- a/lua/mason-lock.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "bash-language-server": "5.4.2", - "beautysh": "6.2.1", - "black": "24.10.0", - "clangd": "19.1.0", - "codespell": "2.3.0", - "cspell": "8.15.7", - "css-lsp": "4.10.0", - "djlint": "1.35.4", - "emmet-ls": "0.4.2", - "eslint_d": "14.2.2", - "html-lsp": "4.10.0", - "isort": "5.13.2", - "jdtls": "v1.41.0", - "lua-language-server": "3.12.0", - "markdownlint": "0.42.0", - "phpcs": "3.10.3", - "prettier": "3.3.3", - "prettierd": "0.25.3", - "pylint": "3.3.1", - "pyright": "1.1.387", - "ruff": "0.7.2", - "rust-analyzer": "2024-11-04", - "selene": "0.27.1", - "stylua": "v0.20.0", - "tailwindcss-language-server": "0.0.26", - "taplo": "0.9.3", - "trivy": "v0.57.0", - "typescript-language-server": "4.3.3", - "yaml-language-server": "1.15.0" -} \ No newline at end of file diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua deleted file mode 100644 index 20e499a..0000000 --- a/lua/plugins/autopairs.lua +++ /dev/null @@ -1,55 +0,0 @@ --- autopairs --- https://github.com/windwp/nvim-autopairs - -return { - 'windwp/nvim-autopairs', - event = 'InsertEnter', - enabled = false, - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - local npairs = require('nvim-autopairs') - - npairs.setup({ - -- The string you provided appears to be a pattern or sequence of characters enclosed within [=[[ and ]]=]. - -- This syntax is used in Lua to create long string literals that can span multiple lines. - -- Here's what the pattern [=[[%w%%%'%[%"%.%%$]]=]` represents: - -- - -- %w matches any alphanumeric character (letters and digits) and underscore. - -- %% matches a literal percent sign %. - -- %' matches a literal single quote '. - -- %[ matches a literal opening square bracket [. - -- %" matches a literal double quote ". - -- %. matches a literal period or dot .. - -- %`` matches a literal backtick `` ``. - -- %$ matches a literal dollar sign $. - -- - -- So, this pattern would match any string that contains alphanumeric characters, underscores, percent signs, - -- single quotes, square brackets, double quotes, periods, backticks, and dollar signs. - -- ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=] - - -- Add { and ( to the list so it won't add the pair when we're adding a function around - -- existing text - ignored_next_char = [=[[%w%%%'%[%"%.%`%$%{%(]]=], - fast_wrap = {}, - check_ts = true, - ts_config = { - lua = { 'string' }, -- it will not add a pair on that treesitter node - javascript = { 'template_string' }, - java = false, -- don't check treesitter on java - }, - }) - -- 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()) - - local Rule = require('nvim-autopairs.rule') - local cond = require('nvim-autopairs.conds') - - vim.notify(vim.inspect(npairs.get_rules('"'))) - - npairs.remove_rule('`') - npairs.add_rule(Rule('`', '`'):with_pair(cond.not_before_regex('[%w%p]'))) - end, -} diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua deleted file mode 100644 index 04dc93b..0000000 --- a/lua/plugins/coding.lua +++ /dev/null @@ -1,202 +0,0 @@ ---Coding related -return { - { - 'max397574/better-escape.nvim', - event = 'InsertEnter', - opts = { - k = function() - vim.api.nvim_input('') - local current_line = vim.api.nvim_get_current_line() - if current_line:match('^%s+j$') then - vim.schedule(function() - vim.api.nvim_set_current_line('') - end) - end - end, - }, - }, - { - 'mg979/vim-visual-multi', - event = 'BufReadPre', - config = function() - vim.g.VM_default_mappings = 0 - vim.g.VM_silent_exit = 1 - vim.g.VM_set_statusline = 0 - vim.g.VM_maps = { - ['Find Under'] = '', - } - vim.g.VM_maps['I BS'] = '' - vim.g.VM_maps['I CtrlC'] = '' - vim.g.VM_maps['I CtrlN'] = '' - end, - }, - { - 'michaelb/sniprun', - build = 'bash ./install.sh', - cmd = 'SnipRun', - config = function() - local sniprun = require('sniprun') - sniprun.setup({ - display = { 'VirtualTextOk', 'VirtualTextErr' }, - show_no_output = { 'Classic', 'TempFloatingWindow' }, - display_options = { - terminal_width = 45, - notification_timeout = 5, - }, - inline_messages = 0, - borders = 'single', - }) - end, - }, - { - 'L3MON4D3/LuaSnip', - event = { 'BufReadPost', 'BufNewFile' }, - dependencies = { - 'rafamadriz/friendly-snippets', - 'mstuttgart/odoo-snippets', - }, - opts = { - history = true, - updateevents = 'TextChanged,TextChangedI', - }, - keys = function() - return {} - end, - config = function() - require('luasnip.loaders.from_vscode').lazy_load() - end, - }, - { - 'altermo/ultimate-autopair.nvim', - event = { 'InsertEnter', 'CmdlineEnter' }, - branch = 'v0.6', --recommended as each new version will have breaking changes - opts = {}, - }, - { - 'hrsh7th/nvim-cmp', - event = { 'InsertEnter', 'CmdlineEnter' }, - dependencies = { - 'hrsh7th/cmp-buffer', -- source for text in buffer - 'hrsh7th/cmp-path', -- source for file system paths - 'hrsh7th/cmp-cmdline', - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-nvim-lua', - 'saadparwaiz1/cmp_luasnip', --for autocomplete - 'hrsh7th/cmp-nvim-lsp-signature-help', - 'onsails/lspkind.nvim', -- vs-code like pictograms - 'L3MON4D3/LuaSnip', -- snippets - 'rafamadriz/friendly-snippets', -- useful snippets - }, - config = function() - require('plugins.configs.cmp') - end, - }, - { - 'Exafunction/codeium.vim', - event = 'InsertEnter', - config = function() - local cmp = require('cmp') - cmp.event:on('menu_opened', function() - vim.g.codeium_manual = true - vim.fn['codeium#Clear']() - end) - cmp.event:on('menu_closed', function() - vim.g.codeium_manual = false - vim.fn['codeium#Complete']() - end) - vim.g.codeium_filetypes = { - TelescopePrompt = false, - DressingInput = false, - ['neo-tree-popup'] = false, - ['dap-repl'] = false, - } - local opts = { expr = true, silent = true } - vim.g.codeium_disable_bindings = 1 - vim.keymap.set('i', '', function() - return vim.fn['codeium#Accept']() - end, opts) - -- vim.keymap.set('n', 'ch', function() - -- return vim.fn['codeium#Chat']() - -- end, { desc = 'Chat with IA (Codeium)' }) - vim.keymap.set('i', '', function() - return vim.fn['codeium#CycleCompletions'](1) - end, opts) - vim.keymap.set('i', '', function() - return vim.fn['codeium#CycleCompletions'](-1) - end, opts) - vim.keymap.set('i', '', function() - return vim.fn['codeium#Clear']() - end, opts) - vim.keymap.set('n', 'cI', 'CodeiumToggle', { desc = 'Toggle IA (Codeium)' }) - end, - }, - { -- Alternate - 'ton/vim-alternate', - lazy = true, - ft = { 'cpp', 'h', 'hpp', 'c' }, - }, - { - 'linux-cultist/venv-selector.nvim', - branch = 'regexp', - cmd = { 'VenvSelect', 'VenvSelectCached' }, - init = function() - vim.keymap.set('n', 'cv', 'VenvSelect', { desc = 'Venv Selector | Select Python venv' }) - end, - opts = {}, - config = function(_, opts) - require('venv-selector').setup(opts) - end, - }, - { - 'nacro90/numb.nvim', - event = 'CmdlineEnter', - config = function() - require('numb').setup({ - show_numbers = true, -- Enable 'number' for the window while peeking - show_cursorline = true, -- Enable 'cursorline' for the window while peeking - hide_relativenumbers = true, -- Enable turning off 'relativenumber' for the window while peeking - number_only = false, -- Peek only when the command is only a number instead of when it starts with a number - centered_peeking = true, -- Peeked line will be centered relative to window - }) - end, - }, - { - 'rachartier/tiny-code-action.nvim', - enabled = false, - -- dev = true, - event = 'LspAttach', - opts = { - backend = 'delta', - }, - - config = function(_, opts) - require('tiny-code-action').setup(opts) - end, - }, - { - 'gbprod/yanky.nvim', - event = 'BufReadPost', - opts = { - highlight = { - timer = 150, - }, - }, - }, - { - 'LudoPinelli/comment-box.nvim', - event = 'BufReadPre', - opts = { - box_width = 70, - }, - }, - { - 'm-demare/hlargs.nvim', - event = { 'BufReadPost', 'BufNewFile' }, - }, - { - 'numToStr/Navigator.nvim', - config = function() - require('Navigator').setup() - end, - }, -} diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua deleted file mode 100644 index ac5e9aa..0000000 --- a/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,35 +0,0 @@ -return { - { - 'navarasu/onedark.nvim', - lazy = false, - priority = 1000, - config = function() - local onedark = require('onedark') - local util = require('lib.util') - - onedark.setup({ - style = 'deep', - transparent = true, - term_colors = false, - ending_tildes = false, - cmp_itemkind_reverse = false, - - toggle_style_key = 'mt', - toggle_style_list = { 'dark', 'darker', 'cool', 'warm', 'warmer', 'deep', 'light' }, - - -- Options are italic, bold, underline, none and combos 'italic,bold' - code_style = { - comments = 'italic', - keywords = 'none', - functions = 'none', - strings = 'none', - variables = 'none', - }, - - lualine = { transparent = true }, - diagnostics = { darker = true, undercurl = true, background = false }, - }) - onedark.load() - end, - }, -} diff --git a/lua/plugins/configs/alpha.lua b/lua/plugins/configs/alpha.lua deleted file mode 100644 index 405ec4b..0000000 --- a/lua/plugins/configs/alpha.lua +++ /dev/null @@ -1,94 +0,0 @@ -local alpha = require('alpha') -local dashboard = require('alpha.themes.dashboard') - -dashboard.section.header.val = { - [[ ]], - [[  ]], - [[ ████ ██████ █████ ██ ]], - [[ ███████████ █████  ]], - [[ █████████ ███████████████████ ███ ███████████ ]], - [[ █████████ ███ █████████████ █████ ██████████████ ]], - [[ █████████ ██████████ █████████ █████ █████ ████ █████ ]], - [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], - [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], - [[ ]], -} -dashboard.section.header.opts.hl = 'AlphaHeader' - -local function button(sc, txt, leader_txt, keybind, keybind_opts) - local sc_after = sc:gsub('%s', ''):gsub(leader_txt, '') - - local opts = { - position = 'center', - shortcut = sc, - cursor = 5, - width = 36, - align_shortcut = 'right', - hl_shortcut = 'AlphaShortcut', - } - - if nil == keybind then - keybind = sc_after - end - - keybind_opts = vim.F.if_nil(keybind_opts, { noremap = true, silent = true, nowait = true }) - opts.keymap = { 'n', sc_after, keybind, keybind_opts } - - local function on_press() - local key = vim.api.nvim_replace_termcodes(sc_after .. '', true, false, true) - vim.api.nvim_feedkeys(key, 't', false) - end - - return { - type = 'button', - val = txt, - on_press = on_press, - opts = opts, - } -end - -local leader = ' ' -dashboard.section.buttons.val = { - button('space f f', ' Find File ', leader, ':Telescope find_files'), - button('space f h', '󰗹 Find Hidden File ', leader, ':Telescope find_files hidden=true no_ignore=true'), - button('space f o', '󱋡 Recent File ', leader, ':Telescope oldfiles'), - button('space f w', '󱀽 Find Word ', leader, ':Telescope live_grep'), - button('space f n', '󱇧 New File ', leader, ':ene startinsert '), - button('space n', ' Settings', leader, ':e $MYVIMRC | :cd %:p:h '), - button('space l', '󰒲 Lazy', leader, ':Lazy'), - button('space q', ' Quit', leader, ':qa'), -} -dashboard.section.buttons.opts.hl = 'String' - -local function footer() - local stats = require('lazy').stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return '  Have fun with Neovim' .. ' 󱐋 Neovim loaded ' .. stats.count .. ' plugins in ' .. ms .. 'ms' -end - -dashboard.section.footer.val = footer() -dashboard.section.footer.opts.hl = 'AlphaFooter' - -local head_butt_padding = 2 -local occu_height = #dashboard.section.header.val + 2 * #dashboard.section.buttons.val + head_butt_padding -local header_padding = math.max(0, math.ceil((vim.fn.winheight('$') - occu_height) * 0.40)) -local foot_butt_padding = 1 - -dashboard.config.layout = { - { type = 'padding', val = header_padding }, - dashboard.section.header, - { type = 'padding', val = head_butt_padding }, - dashboard.section.buttons, - { type = 'padding', val = foot_butt_padding }, - dashboard.section.footer, -} - -alpha.setup(dashboard.opts) - -vim.api.nvim_create_autocmd('User', { - pattern = 'LazyVimStarted', - callback = function() - dashboard.section.footer.val = footer() - pcall(vim.cmd.AlphaRedraw) - end, -}) diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua deleted file mode 100644 index 46ff4d2..0000000 --- a/lua/plugins/configs/cmp.lua +++ /dev/null @@ -1,84 +0,0 @@ -local cmp = require("cmp") -local luasnip = require("luasnip") -local lspkind = require("lspkind") -require("luasnip/loaders/from_vscode").lazy_load() - -cmp.setup({ - completion = { - completeopt = "menu,menuone,preview,noselect", - }, - window = { -- making ui stuff for completion bordered - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - -- configure lspkind for vs-code like pictograms in completion menu - formatting = { - format = lspkind.cmp_format({ - maxwidth = 50, - ellipsis_char = "...", - }), - }, - snippet = { -- configure how nvim-cmp interacts with snippet engine - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = { - [""] = cmp.mapping.select_prev_item(), -- previous suggestion - [""] = cmp.mapping.select_next_item(), -- next suggestion - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), -- show completion suggestions - [""] = cmp.config.disable, - [""] = cmp.mapping({ -- close completion window - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expandable() then - luasnip.expand() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }, - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "cmdline" }, - }, - }), - -- cmp.setup.cmdline("/", { - -- mapping = cmp.mapping.preset.cmdline(), - -- sources = { - -- { name = "buffer" }, - -- }, - -- }), - -- sources for autocompletion - sources = { - { name = "nvim_lsp" }, - { name = "nvim_lsp_signature_help" }, -- parameter hints - { name = "luasnip" }, -- snippets - { name = "buffer" }, -- text within current buffer - { name = "path" }, -- file system paths - { name = "codeium" }, -- AI for autocompletion - -- { name = "calc" }, --for maths calculations - }, -}) diff --git a/lua/plugins/configs/dashboard.lua b/lua/plugins/configs/dashboard.lua deleted file mode 100644 index 391b0bc..0000000 --- a/lua/plugins/configs/dashboard.lua +++ /dev/null @@ -1,72 +0,0 @@ -local dashboard = require('dashboard') -local icons = require('lib.icons') - -dashboard.setup({ - theme = 'hyper', - disable_move = false, - shortcut_type = 'letter', - change_to_vcs_root = true, - hide = { - statusline = true, - tabline = false, - winbar = false, - }, - config = { - week_header = { - enable = true, - }, - packages = { enable = true }, - project = { enable = true, limit = 8 }, - mru = { limit = 8 }, - shortcut = { - { - desc = icons.ui.Package .. 'Mason', - group = '@property', - action = 'Mason', - key = 'm', - }, - { - desc = icons.ui.Sleep .. 'Lazy', - group = '@property', - action = 'Lazy', - key = 'l', - }, - { - desc = icons.documents.OpenFolder .. 'Files', - group = 'Label', - action = 'Telescope find_files', - key = 'f', - }, - { - desc = icons.ui.Search .. 'Search', - group = 'Label', - action = 'Telescope live_grep', - key = 'g', - }, - { - desc = icons.ui.Note .. 'Todo', - group = 'Label', - action = 'Tdo', - key = 'd', - }, - { - desc = icons.ui.Power, - group = 'Action', - action = 'quit', - key = 'q', - }, - }, - footer = { '', icons.ui.Heart .. ' Happiness is a state of mind. ' .. icons.ui.Heart }, - }, -}) - --- Show dashboard when lazy closes -if vim.o.filetype == 'lazy' then - vim.cmd.close() - vim.api.nvim_create_autocmd('User', { - pattern = 'DashboardLoaded', - callback = function() - require('lazy').show() - end, - }) -end diff --git a/lua/plugins/configs/telescope.lua b/lua/plugins/configs/telescope.lua deleted file mode 100644 index d3bdd81..0000000 --- a/lua/plugins/configs/telescope.lua +++ /dev/null @@ -1,67 +0,0 @@ -local telescope = require('telescope') -local fb_actions = require('telescope').extensions.file_browser.actions -telescope.setup({ - file_ignore_patterns = { '%.git/.' }, - defaults = { - preview = { - treesitter = false, - }, - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - case_mode = 'smart_case', -- or "ignore_case" or "respect_case" - }, - file_browser = { - theme = 'ivy', - hijack_netrw = true, - mapping = { - ['i'] = { - [''] = fb_actions.create, - [''] = fb_actions.rename, - [''] = fb_actions.remove, - [''] = fb_actions.toggle_hidden, - }, - ['n'] = { - [''] = fb_actions.create, - [''] = require('telescope-undo.actions').yank_additions, - [''] = require('telescope-undo.actions').yank_deletions, - [''] = require('telescope-undo.actions').restore, - }, - }, - }, - }, - borderchars = { - prompt = { '─', '│', '─', '│', '╭', '╮', '╯', '╰' }, - results = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, - }, -}) -telescope.load_extension('ui-select') -telescope.load_extension('file_browser') --- telescope.load_extension("refactoring") -telescope.load_extension('notify') -telescope.load_extension('undo') diff --git a/lua/plugins/configs/zen&twilight.lua b/lua/plugins/configs/zen&twilight.lua deleted file mode 100644 index e5f707c..0000000 --- a/lua/plugins/configs/zen&twilight.lua +++ /dev/null @@ -1,41 +0,0 @@ -local twilight = require('twilight') - -twilight.setup({ - dimming = { alpha = 0.45, color = { 'Normal', '#ffffff' }, inactive = false }, - context = 9, - treesitter = true, - expand = { 'function', 'method', 'table', 'if_statement', 'element' }, - exclude = {}, -}) - -local zen = require('zen-mode') - -zen.setup({ - window = { - backdrop = 0.95, - width = 180, - height = 1, - options = { - signcolumn = 'no', - number = false, - relativenumber = false, - cursorline = false, - cursorcolumn = false, - foldcolumn = '0', - list = false, - }, - }, - plugins = { - options = { enabled = true, ruler = true, showcmd = true }, - twilight = { enabled = true }, - gitsigns = { enabled = true }, - tmux = { enabled = true }, - kitty = { enabled = false, font = '+4' }, - }, - on_open = function(win) - vim.o.laststatus = 0 - end, - on_close = function() - vim.o.laststatus = 2 - end, -}) diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua deleted file mode 100644 index d6f5842..0000000 --- a/lua/plugins/conform.lua +++ /dev/null @@ -1,146 +0,0 @@ --- Define conform.nvim formatting servers here -local formatting_servers = { - 'prettier', - 'isort', - 'uncrustify', - 'black', - 'stylua', - 'shfmt', - 'php-cs-fixer', - 'google-java-formatter', - 'codespell', - 'autoflake', - 'djlint', -} - -return { - 'stevearc/conform.nvim', - dependencies = { 'zapling/mason-conform.nvim' }, - event = { 'BufReadPre', 'BufNewFile' }, - cmd = { 'ConformInfo' }, - keys = { - { - 'cfF', - function() - require('conform').format({ async = true, lsp_format = 'fallback' }) - end, - mode = '', - desc = 'Format Buffer', - }, - { - 'cff', - function() - if vim.b.disable_autoformat then - vim.cmd('FormatEnable!') - vim.notify('Formatting enabled') - else - vim.cmd('FormatDisable!') - vim.notify('Formatting disabled') - end - end, - mode = '', - desc = 'Toggle Format on save', - }, - }, - config = function() - local conform = require('conform') - require('mason-conform').setup({ - ensure_installed = formatting_servers, - automatic_installation = true, - }) - conform.setup({ - notify_on_error = true, - formatters_by_ft = { - cpp = { 'uncrustify' }, - c = { 'uncrustify' }, - -- Conform can also run multiple formatters sequentially - -- You can use a sub-list to tell conform to run *until* a formatter is found. - javascript = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true }, - typescript = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true }, - javascriptreact = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true }, - typescriptreact = { 'eslint_d', 'prettierd', 'prettier', stop_after_first = true }, - css = { 'prettierd', 'prettier', stop_after_first = true }, - html = { 'prettierd', 'prettier', stop_after_first = true }, - json = { 'prettierd', 'prettier', stop_after_first = true }, - yaml = { 'prettierd', 'prettier', stop_after_first = true }, - markdown = { 'prettierd', 'prettier', stop_after_first = true }, - lua = { 'stylua' }, - python = { 'isort', 'black' }, - php = { 'php-cs-fixer' }, - htmldjango = { 'djlint' }, - java = { 'google-java-formatter' }, - graphql = { 'prettierd', 'prettier', stop_after_first = true }, - liquid = { 'prettierd', 'prettier', stop_after_first = true }, - bash = { 'beautysh' }, - sh = { 'beautysh' }, - -- yaml = {'yamlfix'}, - ['*'] = { 'codespell' }, - ['_'] = { 'trim_whitespace' }, - }, - formatters = { - prettier = { - javascript = { - args = { '--single-quote' }, - }, - }, - eslint_d = { - require_cwd = true, - }, - yamlfix = { - env = { - YAMLFIX_SEQUENCE_STYLE = 'block_style', - YAMLFIX_preserve_quotes = 'true', - }, - }, - }, - -- support a global format disable - format_on_save = function(bufnr) - -- Disable with a global or buffer-local variable - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { - c = true, - cpp = true, - liquid = true, - } - local lsp_format_opt - if disable_filetypes[vim.bo[bufnr].filetype] then - lsp_format_opt = 'never' - else - lsp_format_opt = 'fallback' - end - return { - timeout_ms = 2000, - lsp_format = lsp_format_opt, - } - end, - }) - - -- From: https://github.com/stevearc/conform.nvim/blob/master/doc/recipes.md#command-to-toggle-format-on-save - vim.api.nvim_create_user_command('FormatDisable', function(args) - if args.bang then - -- FormatDisable! will disable formatting just for this buffer - vim.b.disable_autoformat = true - else - vim.g.disable_autoformat = true - end - end, { - desc = 'Disable autoformat-on-save', - bang = true, - }) - vim.api.nvim_create_user_command('FormatEnable', function(args) - if args.bang then - vim.b.disable_autoformat = false - else - vim.g.disable_autoformat = false - end - end, { - desc = 'Re-enable autoformat-on-save', - bang = true, - }) - end, -} diff --git a/lua/plugins/database.lua b/lua/plugins/database.lua deleted file mode 100644 index f3f11cf..0000000 --- a/lua/plugins/database.lua +++ /dev/null @@ -1,44 +0,0 @@ -return { - { - 'tpope/vim-dadbod', - dependencies = { - 'kristijanhusak/vim-dadbod-ui', - 'kristijanhusak/vim-dadbod-completion', - }, - config = function() - local function db_completion() - require('plugins.completion.cmp').setup.buffer({ - sources = { { name = 'vim-dadbod-completion' } }, - }) - end - - vim.g.db_ui_save_location = vim.fn.stdpath('config') .. require('plenary.path').path.sep .. 'db_ui' - - vim.api.nvim_create_autocmd('FileType', { - pattern = { - 'sql', - }, - command = [[setlocal omnifunc=vim_dadbod_completion#omni]], - }) - - vim.api.nvim_create_autocmd('FileType', { - pattern = { - 'sql', - 'mysql', - 'plsql', - }, - callback = function() - vim.schedule(db_completion) - end, - }) - end, - cmd = { - 'DBUIToggle', - 'DBUI', - 'DBUIAddConnection', - 'DBUIFindBuffer', - 'DBUIRenameBuffer', - 'DBUILastQueryInfo', - }, - }, -} diff --git a/lua/plugins/debug.lua b/lua/plugins/debug.lua deleted file mode 100644 index 5345fd9..0000000 --- a/lua/plugins/debug.lua +++ /dev/null @@ -1,147 +0,0 @@ -return { - { - 'mfussenegger/nvim-dap', - dependencies = { - -- Creates a beautiful debugger UI - 'rcarriga/nvim-dap-ui', - -- Required dependency for nvim-dap-ui - 'nvim-neotest/nvim-nio', - }, - cmd = { 'DapUIToggle', 'DapToggleRepl', 'DapToggleBreakpoint' }, - config = function() - local dap = require('dap') - local dapui = require('dapui') - - dapui.setup({ - icons = { expanded = ' ', collapsed = ' ' }, - mappings = { - expand = { '', '<2-LeftMouse>' }, - open = 'o', - remove = 'd', - edit = 'e', - repl = 'r', - toggle = 't', - }, - expand_lines = vim.fn.has('nvim-0.7'), - layouts = { - { - elements = { - { id = 'scopes', size = 0.25 }, - 'breakpoints', - 'stacks', - 'watches', - }, - size = 40, - position = 'right', - }, - { - elements = { - 'repl', - 'console', - }, - size = 0.25, - position = 'bottom', - }, - }, - floating = { - max_height = nil, - max_width = nil, - border = 'rounded', - mappings = { - close = { 'q', '' }, - }, - }, - windows = { indent = 1 }, - render = { - max_type_length = nil, - }, - }) - - vim.fn.sign_define( - 'DapBreakpoint', - { text = ' ', texthl = 'DiagnosticSignError', linehl = '', numhl = '' } - ) - - 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 - - dap.adapters.python = { - type = 'executable', - command = '/usr/bin/python', - args = { '-m', 'debugpy.adapter' }, - } - - dap.configurations.python = { - { - type = 'python', - request = 'launch', - name = 'Launch file', - - program = '${file}', - pythonPath = function() - local cwd = vim.fn.getcwd() - if 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 '/usr/bin/python' - end - end, - }, - } - -- local dap_utils = require 'user.plugins.configs.dap.utils' - local BASH_DEBUG_ADAPTER_BIN = vim.fn.stdpath('data') - .. '/mason/packages/bash-debug-adapter/bash-debug-adapter' - local BASHDB_DIR = vim.fn.stdpath('data') .. '/mason/packages/bash-debug-adapter/extension/bashdb_dir' - - dap.adapters.sh = { - type = 'executable', - command = BASH_DEBUG_ADAPTER_BIN, - } - dap.configurations.sh = { - { - name = 'Launch Bash debugger', - type = 'sh', - request = 'launch', - program = '${file}', - cwd = '${fileDirname}', - pathBashdb = BASHDB_DIR .. '/bashdb', - pathBashdbLib = BASHDB_DIR, - pathBash = 'bash', - pathCat = 'cat', - pathMkfifo = 'mkfifo', - pathPkill = 'pkill', - env = {}, - args = {}, - -- showDebugOutput = true, - -- trace = true, - }, - } - - vim.api.nvim_create_user_command('DapUIToggle', function() - require('dapui').toggle() - end, {}) - end, - }, - { - 'mfussenegger/nvim-dap-python', - ft = 'python', - dependencies = { - 'mfussenegger/nvim-dap', - 'rcarriga/nvim-dap-ui', - 'nvim-neotest/nvim-nio', - }, - config = function(_, _) - local path = '~/.local/share/nvim/mason/packages/debugpy/venv/bin/python' - require('dap-python').setup(path) - end, - }, -} diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua deleted file mode 100644 index 22ee424..0000000 --- a/lua/plugins/editor.lua +++ /dev/null @@ -1,180 +0,0 @@ -return { - { - 'lambdalisue/suda.vim', - cmd = { 'SudaRead', 'SudaWrite' }, - }, - { - 'nvim-neo-tree/neo-tree.nvim', - cmd = { 'Neotree' }, - opts = { - filesystem = { - filtered_items = { - visible = true, - show_hidden_count = true, - hide_dotfiles = false, - hide_gitignored = true, - hide_by_name = { - '.git', - '.DS_Store', - 'thumbs.db', - '.venv', - }, - never_show = {}, - }, - }, - window = { - position = 'right', - width = 35, - }, - }, - }, - { - 'folke/flash.nvim', - enabled = false, - keys = { - { - 's', - mode = { 'n', 'x', 'o' }, - function() - require('flash').jump() - end, - desc = 'Flash', - }, - { - 'S', - mode = { 'n', 'x', 'o' }, - function() - require('flash').treesitter() - end, - desc = 'Flash Treesitter', - }, - }, - config = function() - require('plugins.configs.jump') - end, - }, - { - 'folke/trouble.nvim', - lazy = true, - cmd = { 'Trouble', 'TroubleToggle', 'TroubleRefresh' }, - opts = { - modes = { - lsp = { - win = { position = 'right' }, - }, - }, - }, - }, - { - 'nvim-telescope/telescope.nvim', - cmd = 'Telescope', - version = false, - lazy = true, - dependencies = { - { 'nvim-tree/nvim-web-devicons' }, - { - 'nvim-telescope/telescope-fzf-native.nvim', - build = 'make', - cond = function() - return vim.fn.executable('make') == 1 - end, - }, - { 'nvim-telescope/telescope-ui-select.nvim' }, - { 'nvim-telescope/telescope-symbols.nvim' }, - { 'nvim-telescope/telescope-file-browser.nvim' }, - { 'debugloop/telescope-undo.nvim' }, - }, - config = function() - require('plugins.configs.telescope') - end, - }, - { - 'smjonas/inc-rename.nvim', - cmd = 'IncRename', - config = true, - }, - { - - 'akinsho/toggleterm.nvim', - cmd = { 'ToggleTerm' }, - version = 'v2.*', - config = function() - require('plugins.configs.toggleterm') - end, - }, - { - '2kabhishek/termim.nvim', - cmd = { 'Fterm', 'FTerm', 'Sterm', 'STerm', 'Vterm', 'VTerm' }, - }, - { - 'nvimdev/lspsaga.nvim', - lazy = true, - event = 'LspAttach', - config = function() - local icons = require('lib.icons') - require('lspsaga').setup({ - ui = { - theme = 'round', - border = 'rounded', - devicon = true, - title = true, - winblend = 1, - expand = icons.ui.ArrowOpen, - collapse = icons.ui.ArrowClosed, - preview = icons.ui.List, - code_action = icons.diagnostics.Hint, - diagnostic = icons.ui.Bug, - incoming = icons.ui.Incoming, - outgoing = icons.ui.Outgoing, - hover = icons.ui.Comment, - }, - lightbulb = { - enable = false, - enable_in_insert = true, - sign = true, - sign_priority = 40, - virtual_text = true, - }, - symbol_in_winbar = { - enable = false, - separator = '  ', - hide_keyword = true, - show_file = true, - folder_level = 0, - }, - }) - end, - }, - { - 'HiPhish/rainbow-delimiters.nvim', - event = { 'BufReadPost', 'BufNewFile' }, - config = function() - local rainbow_delimiters = require('rainbow-delimiters') - require('rainbow-delimiters.setup').setup({ - { - strategy = { - [''] = rainbow_delimiters.strategy['global'], - vim = rainbow_delimiters.strategy['local'], - }, - query = { - [''] = 'rainbow-delimiters', - lua = 'rainbow-blocks', - }, - priority = { - [''] = 110, - lua = 210, - }, - highlight = { - 'RainbowDelimiterRed', - 'RainbowDelimiterYellow', - 'RainbowDelimiterBlue', - 'RainbowDelimiterOrange', - 'RainbowDelimiterGreen', - 'RainbowDelimiterViolet', - 'RainbowDelimiterCyan', - }, - }, - }) - end, - }, -} diff --git a/lua/plugins/extra.lua b/lua/plugins/extra.lua deleted file mode 100644 index 012b497..0000000 --- a/lua/plugins/extra.lua +++ /dev/null @@ -1,240 +0,0 @@ -return { - { - 'ggandor/leap.nvim', - -- event = { "BufAdd", "BufNewFile", "BufRead" }, - config = function() - require('leap').add_default_mappings() - end, - }, - { - 'cvigilv/esqueleto.nvim', - event = 'VeryLazy', - opts = { - directories = { - vim.fn.stdpath('config') .. '/templates', - }, - patterns = { - -- File - 'README', - 'LICENSE', - -- Filetype - 'sh', - 'markdown', - 'python', - 'lua', - 'html', - 'vue', - }, - }, - }, - { - 'kawre/leetcode.nvim', - cmd = 'Leet', - build = ':TSUpdate html', - dependencies = { - 'nvim-telescope/telescope.nvim', - 'nvim-lua/plenary.nvim', -- required by telescope - 'MunifTanjim/nui.nvim', - - -- optional - 'nvim-treesitter/nvim-treesitter', - 'rcarriga/nvim-notify', - 'nvim-tree/nvim-web-devicons', - }, - opts = {}, - }, - { - 'epwalsh/pomo.nvim', - cmd = { 'TimerStart', 'TimerStop', 'TimerRepeat' }, - dependencies = { - 'rcarriga/nvim-notify', - }, - opts = { - notifiers = { - { - name = 'Default', - opts = { - sticky = false, - }, - }, - }, - }, - }, - { - 'ThePrimeagen/refactoring.nvim', - config = function() - require('refactoring').setup({ - prompt_func_return_type = { - go = false, - java = false, - cpp = false, - c = false, - h = false, - hpp = false, - cxx = false, - }, - prompt_func_param_type = { - go = false, - java = false, - - cpp = false, - c = false, - h = false, - hpp = false, - cxx = false, - }, - printf_statements = {}, - print_var_statements = {}, - }) - end, - }, - { - 'folke/which-key.nvim', - event = 'VeryLazy', - config = function() - require('plugins.configs.whichkey') - end, - }, - { - 'zapling/mason-lock.nvim', - cmd = { 'MasonLock', 'MasonLockRestore' }, - config = function() - require('mason-lock').setup({ - lockfile_path = vim.fn.stdpath('config') .. '/lua/mason-lock.json', -- (default) - }) - end, - }, - { - 'uga-rosa/ccc.nvim', - cmd = { 'CccHighlighterToggle', 'CccConvert', 'CccPick' }, - config = function() - vim.opt.termguicolors = true - - local ccc = require('ccc') - - ccc.setup({ - highlighter = { - auto_enable = true, - lsp = true, - }, - }) - end, - }, - { - '2kabhishek/nerdy.nvim', - dependencies = { 'stevearc/dressing.nvim' }, - cmd = 'Nerdy', - }, - { - 'folke/persistence.nvim', - event = 'BufReadPre', - opts = { options = vim.opt.sessionoptions:get() }, - }, - { - 'nvim-lua/plenary.nvim', - lazy = true, - }, - { - 'iamcco/markdown-preview.nvim', - build = 'cd app && yarn install', - ft = { 'markdown' }, - }, - { - 'nvim-pack/nvim-spectre', - cmd = 'Spectre', - config = function() - require('plugins.configs.spectre') - end, - }, - { - 'folke/zen-mode.nvim', - dependencies = { - 'folke/twilight.nvim', - }, - config = function() - require('plugins.configs.zen&twilight') - end, - cmd = { 'ZenMode', 'Twilight' }, - }, - { - 'creativenull/dotfyle-metadata.nvim', - cmd = { 'DotfyleGenerate', 'DotfyleOpen' }, - }, - { - 'willothy/flatten.nvim', - priority = 1001, - opts = { - window = { - open = 'alternate', - }, - }, - }, - { - 'wakatime/vim-wakatime', - event = { 'VimEnter' }, - lazy = false, - }, - { -- Codesnap - 'mistricky/codesnap.nvim', - lazy = true, - build = 'make', - opts = { - save_path = '~/Pictures/screenshots/code', - has_breadcrumbs = false, - show_workspace = false, - bg_theme = 'default', - watermark = 'S4NKALP', - code_font_family = 'Iosevka NF', - code_font_size = 12, - }, - cmd = { 'CodeSnap', 'CodeSnapSave', 'CodeSnapHighlight', 'CodeSnapASCII' }, - }, - { - 'mvllow/modes.nvim', - event = { 'BufReadPost', 'BufNewFile' }, - tag = 'v0.2.0', - config = function() - require('modes').setup({ - - colors = { - visual = '#f5c359', - delete = '#c75c6a', - copy = '#78ccc5', - insert = '#c5739a', - }, - line_opacity = 0.15, - set_cursor = true, - set_cursorline = true, - set_number = true, - ignore_filetypes = { 'NvimTree', 'TelescopePrompt' }, - }) - end, - }, - { - 'mbbill/undotree', - - keys = { - { 'mu', 'UndotreeToggle', desc = 'Undotree' }, - }, - }, - { - 'LunarVim/bigfile.nvim', - event = { 'BufEnter', 'WinEnter' }, - opts = { - -- Disables LSP/treesitter, etc for files above 5000 lives (even if they have really long lines) - pattern = function(bufnr, filesize_mib) - if filesize_mib >= 2 then - return true - end - -- you can't use `nvim_buf_line_count` because this runs on BufReadPre - local file_contents = vim.fn.readfile(vim.api.nvim_buf_get_name(bufnr)) - local file_length = #file_contents - if file_length > 5000 then - return true - end - - return false - end, - }, - }, -} diff --git a/lua/plugins/fun.lua b/lua/plugins/fun.lua deleted file mode 100644 index 310f35c..0000000 --- a/lua/plugins/fun.lua +++ /dev/null @@ -1,43 +0,0 @@ -return { - { - 'm4xshen/hardtime.nvim', - config = function() - require('hardtime').setup({ enabled = true }) - end, - cmd = 'Hardtime', - }, - { - 'ThePrimeagen/vim-be-good', - cmd = 'VimBeGood', - }, - { - 'nvchad/showkeys', - cmd = 'ShowkeysToggle', - opts = { - timeout = 1, - maxkeys = 8, - }, - }, - { - 'meznaric/key-analyzer.nvim', - cmd = 'KeyAnalyzer', - opts = {}, - }, - { - 'eandrju/cellular-automaton.nvim', - keys = { - { 'mr', 'CellularAutomaton make_it_rain', desc = 'Make it rain' }, - }, - }, - { - 'tris203/precognition.nvim', - enabled = false, - opts = { - showBlankVirtLine = false, - }, - }, - { - 'sedm0784/vim-rainbow-trails', - cmd = 'RainbowTrails', - }, -} diff --git a/lua/plugins/lang/ai.lua b/lua/plugins/lang/ai.lua new file mode 100644 index 0000000..45f69d4 --- /dev/null +++ b/lua/plugins/lang/ai.lua @@ -0,0 +1,35 @@ +local ai = require('mini.ai') + +ai.setup({ + custom_textobjects = { + o = ai.gen_spec.treesitter({ + a = { '@block.outer', '@conditional.outer', '@loop.outer' }, + i = { '@block.inner', '@conditional.inner', '@loop.inner' }, + }, {}), + f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }, {}), + c = ai.gen_spec.treesitter({ a = '@class.outer', i = '@class.inner' }, {}), + t = { '<([%p%w]-)%f[^<%w][^<>]->.-', '^<.->().*()$' }, + }, + + mappings = { + -- Main textobject prefixes + around = 'a', + inside = 'i', + + -- Next/last variants + around_next = 'an', + inside_next = 'in', + around_last = 'al', + inside_last = 'il', + + -- Move cursor to corresponding edge of `a` textobject + goto_left = 'g[', + goto_right = 'g]', + }, + + -- How to search for object + -- 'cover', 'cover_or_next', 'cover_or_prev','cover_or_nearest', 'next', 'previous', 'nearest'. + search_method = 'cover_or_next', + n_lines = 500, + silent = false, +}) diff --git a/lua/plugins/lang/autopairs.lua b/lua/plugins/lang/autopairs.lua new file mode 100644 index 0000000..79e9671 --- /dev/null +++ b/lua/plugins/lang/autopairs.lua @@ -0,0 +1,22 @@ +local npairs = require('nvim-autopairs') + +npairs.setup({ + check_ts = true, + ts_config = { + lua = { 'string', 'source' }, + javascript = { 'string', 'template_string' }, + java = false, + }, + disable_filetype = { 'TelescopePrompt', 'spectre_panel' }, + fast_wrap = { + map = '', + chars = { '{', '[', '(', '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], '%s+', ''), + offset = 0, + end_key = '$', + keys = 'qwertyuiopzxcvbnmasdfghjkl', + check_comma = true, + highlight = 'PmenuSel', + highlight_grey = 'LineNr', + }, +}) diff --git a/lua/plugins/lang/blink.lua b/lua/plugins/lang/blink.lua new file mode 100644 index 0000000..13e9a1a --- /dev/null +++ b/lua/plugins/lang/blink.lua @@ -0,0 +1,51 @@ +local blink = require('blink.cmp') +local icons = require('lib.icons') + +blink.setup({ + -- 'default', 'super-tab', 'enter' + keymap = { + preset = 'enter', + [''] = { 'select_next', 'snippet_forward', 'fallback' }, + [''] = { 'select_prev', 'snippet_backward', 'fallback' }, + }, + -- 'preselect', 'manual', 'auto_insert' + completion = { + list = { selection = 'auto_insert' }, + menu = { border = 'rounded' }, + documentation = { window = { border = 'rounded' } }, + }, + signature = { window = { border = 'rounded' } }, + appearance = { + -- Sets the fallback highlight groups to nvim-cmp's highlight groups + use_nvim_cmp_as_default = true, + -- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + nerd_font_variant = 'normal', + kind_icons = icons.kind, + }, + sources = { + default = { 'lazydev', 'lsp', 'path', 'snippets', 'buffer', 'copilot' }, + providers = { + copilot = { + name = 'copilot', + module = 'blink-cmp-copilot', + score_offset = 90, + async = true, + transform_items = function(_, items) + local CompletionItemKind = require('blink.cmp.types').CompletionItemKind + local kind_idx = #CompletionItemKind + 1 + CompletionItemKind[kind_idx] = 'Copilot' + for _, item in ipairs(items) do + item.kind = kind_idx + end + return items + end, + }, + lazydev = { + name = 'LazyDev', + module = 'lazydev.integrations.blink', + -- make lazydev completions top priority (see `:h blink.cmp`) + score_offset = 100, + }, + }, + }, +}) diff --git a/lua/plugins/lang/copilot-chat.lua b/lua/plugins/lang/copilot-chat.lua new file mode 100644 index 0000000..31de9a0 --- /dev/null +++ b/lua/plugins/lang/copilot-chat.lua @@ -0,0 +1,92 @@ +local chat = require('CopilotChat') +local icons = require('lib.icons') + +chat.setup({ + debug = false, -- Enable debug logging + proxy = nil, -- [protocol://]host[:port] Use this proxy + allow_insecure = false, -- Allow insecure server connections + model = 'gpt-4o', -- model to use, :CopilotChatModels for available models + agent = 'copilot', -- Default agent to use, see ':CopilotChatAgents' for available agents (can be specified manually in prompt via @). + context = 'buffers', -- Default context to use, 'buffers', 'buffer' or none (can be specified manually in prompt via @). + temperature = 0.1, -- temperature + + question_header = '# ' .. icons.ui.User .. 'User', -- Header to use for user questions + answer_header = '# ' .. icons.ui.Copilot .. 'Copilot', -- Header to use for AI answers + error_header = '## ' .. icons.ui.CopilotError .. 'Error', -- Header to use for errors + separator = ' ', -- Separator to use in chat + + show_folds = true, -- Shows folds for sections in chat + show_help = true, -- Shows help message as virtual lines when waiting for user input + auto_follow_cursor = false, -- Auto-follow cursor in chat + auto_insert_mode = false, -- Automatically enter insert mode when opening window and if auto follow cursor is enabled on new prompt + clear_chat_on_new_prompt = false, -- Clears chat on every new prompt + highlight_selection = true, -- Highlight selection in the source buffer when in the chat window + + chat_autocomplete = true, -- Enable chat autocompletion (when disabled, requires manual `mappings.complete` trigger) + history_path = vim.fn.stdpath('data') .. '/copilot_chat_history', -- Default path to stored history + callback = nil, -- Callback to use when ask response is received + + -- default window options + window = { + layout = 'vertical', -- 'vertical', 'horizontal', 'float', 'replace' + width = 0.45, -- fractional width of parent, or absolute width in columns when > 1 + height = 0.4, -- fractional height of parent, or absolute height in rows when > 1 + -- Options below only apply to floating windows + relative = 'editor', -- 'editor', 'win', 'cursor', 'mouse' + border = 'rounded', -- 'none', single', 'double', 'rounded', 'solid', 'shadow' + row = nil, -- row position of the window, default is centered + col = nil, -- column position of the window, default is centered + title = icons.ui.Copilot .. ' Copilot Chat', -- title of chat window + footer = nil, -- footer of chat window + zindex = 1, -- determines if window is on top or below other floating windows + }, + + -- default mappings + mappings = { + complete = { + insert = '', + }, + close = { + normal = 'q', + insert = '', + }, + reset = { + normal = '', + insert = '', + }, + submit_prompt = { + normal = '', + insert = '', + }, + toggle_sticky = { + detail = 'Makes line under cursor sticky or deletes sticky line.', + normal = 'gr', + }, + accept_diff = { + normal = '', + insert = '', + }, + jump_to_diff = { + normal = 'gj', + }, + quickfix_diffs = { + normal = 'gq', + }, + yank_diff = { + normal = 'gy', + register = '"', + }, + show_diff = { + normal = 'gd', + }, + show_info = { + normal = 'gi', + }, + show_context = { + normal = 'gc', + }, + show_help = { + normal = 'gh', + }, + }, +}) diff --git a/lua/plugins/lang/copilot.lua b/lua/plugins/lang/copilot.lua new file mode 100644 index 0000000..c71f1ea --- /dev/null +++ b/lua/plugins/lang/copilot.lua @@ -0,0 +1,45 @@ +local copilot = require('copilot') + +copilot.setup({ + panel = { + enabled = true, + auto_refresh = false, + keymap = { + jump_prev = '[[', + jump_next = ']]', + accept = '', + refresh = 'gr', + open = '', + }, + layout = { + position = 'bottom', + ratio = 0.4, + }, + }, + suggestion = { + enabled = true, + auto_trigger = false, + debounce = 75, + keymap = { + accept = '', + accept_word = false, + accept_line = false, + next = '', + prev = '', + dismiss = '', + }, + }, + filetypes = { + yaml = true, + markdown = true, + help = true, + gitcommit = true, + gitrebase = true, + hgcommit = true, + svn = true, + cvs = true, + ['.'] = true, + }, + copilot_node_command = 'node', -- Node.js version must be > 16.x + server_opts_overrides = {}, +}) diff --git a/lua/plugins/lang/dap.lua b/lua/plugins/lang/dap.lua new file mode 100644 index 0000000..0d54ed2 --- /dev/null +++ b/lua/plugins/lang/dap.lua @@ -0,0 +1,107 @@ +local dap = require('dap') +local dapui = require('dapui') +local icons = require('lib.icons') + +dapui.setup({ + icons = { expanded = icons.ui.ArrowClosed, collapsed = icons.ui.ArrowOpen }, + mappings = { + expand = { '', '<2-LeftMouse>' }, + open = 'o', + remove = 'd', + edit = 'e', + repl = 'r', + toggle = 't', + }, + expand_lines = vim.fn.has('nvim-0.7'), + layouts = { + { + elements = { + { id = 'scopes', size = 0.25 }, + 'breakpoints', + 'stacks', + 'watches', + }, + size = 40, + position = 'right', + }, + { + elements = { + 'repl', + 'console', + }, + size = 0.25, + position = 'bottom', + }, + }, + floating = { + max_height = nil, + max_width = nil, + border = 'rounded', + mappings = { + close = { 'q', '' }, + }, + }, + windows = { indent = 1 }, + render = { + max_type_length = nil, + }, +}) + +vim.fn.sign_define('DapBreakpoint', { text = icons.ui.Bug, texthl = 'DiagnosticSignError', linehl = '', numhl = '' }) + +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 + +dap.adapters.python = { + type = 'executable', + command = '/usr/bin/python', + args = { '-m', 'debugpy.adapter' }, +} + +dap.configurations.python = { + { + type = 'python', + request = 'launch', + name = 'Launch file', + + program = '${file}', + pythonPath = function() + local cwd = vim.fn.getcwd() + if 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 '/usr/bin/python' + end + end, + }, +} + +dap.adapters.ruby = { + type = 'executable', + command = 'bundle', + args = { 'exec', 'readapt', 'stdio' }, +} + +dap.configurations.ruby = { + { + type = 'ruby', + request = 'launch', + name = 'Rails', + program = 'bundle', + programArgs = { 'exec', 'rails', 's' }, + useBundler = true, + }, +} + +vim.api.nvim_create_user_command('DapUIToggle', function() + require('dapui').toggle() +end, {}) diff --git a/lua/plugins/lang/lspconfig.lua b/lua/plugins/lang/lspconfig.lua new file mode 100644 index 0000000..8c99db1 --- /dev/null +++ b/lua/plugins/lang/lspconfig.lua @@ -0,0 +1,48 @@ +local lspconfig = require('lspconfig') +local icons = require('lib.icons').diagnostics + +local auto_install = require('lib.util').get_user_config('auto_install', true) +local installed_servers = {} +if auto_install then + installed_servers = require('plugins.list').lsp_servers +end + +local default_setup = function(server) + lspconfig[server].setup({ + capabilities = + require('blink.cmp').get_lsp_capabilities() + }) +end + +local signs = { Error = icons.Error, Warn = icons.Warning, Hint = icons.Hint, Info = icons.Information } +for type, icon in pairs(signs) do + local hl = 'DiagnosticSign' .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) +end + +require('mason-lspconfig').setup({ + ensure_installed = installed_servers, + handlers = { + default_setup, + lua_ls = function() + lspconfig.lua_ls.setup({ + capabilities = lsp_capabilities, + settings = { + Lua = { + runtime = { version = 'LuaJIT' }, + diagnostics = { globals = { 'vim' } }, + workspace = { library = { vim.env.VIMRUNTIME } }, + format = { + enable = true, + defaultConfig = { + align_continuous_assign_statement = false, + align_continuous_rect_table_field = false, + align_array_table = false, + }, + }, + }, + }, + }) + end, + }, +}) diff --git a/lua/plugins/lang/lspsaga.lua b/lua/plugins/lang/lspsaga.lua new file mode 100644 index 0000000..892e3b5 --- /dev/null +++ b/lua/plugins/lang/lspsaga.lua @@ -0,0 +1,21 @@ +local lspsaga = require('lspsaga') + +local icons = require('lib.icons') + +lspsaga.setup({ + ui = { + theme = 'round', + border = 'rounded', + devicon = true, + title = true, + winblend = 1, + expand = icons.ui.ArrowOpen, + collapse = icons.ui.ArrowClosed, + preview = icons.ui.List, + code_action = icons.diagnostics.Hint, + diagnostic = icons.ui.Bug, + incoming = icons.ui.Incoming, + outgoing = icons.ui.Outgoing, + hover = icons.ui.Comment, + }, +}) diff --git a/lua/plugins/lang/mason.lua b/lua/plugins/lang/mason.lua new file mode 100644 index 0000000..aa10be6 --- /dev/null +++ b/lua/plugins/lang/mason.lua @@ -0,0 +1,35 @@ +local mason = require('mason') + +local icons = require('lib.icons') +mason.setup({ + -- - "prepend": Use mason binary, "append": Use system binary + PATH = 'append', + + log_level = vim.log.levels.INFO, + max_concurrent_installers = 8, + + ui = { + check_outdated_packages_on_open = true, + border = 'rounded', + width = 0.8, + height = 0.8, + + icons = { + package_installed = icons.ui.Gear, + package_pending = icons.ui.Download, + package_uninstalled = icons.ui.Plus, + }, + + keymaps = { + toggle_package_expand = '', + install_package = 'i', + update_package = 'u', + check_package_version = 'c', + update_all_packages = 'U', + check_outdated_packages = 'C', + uninstall_package = 'x', + cancel_installation = '', + apply_language_filter = '', + }, + }, +}) diff --git a/lua/plugins/lang/neotest.lua b/lua/plugins/lang/neotest.lua new file mode 100644 index 0000000..e5fc2c6 --- /dev/null +++ b/lua/plugins/lang/neotest.lua @@ -0,0 +1,20 @@ +local neotest = require('neotest') + +neotest.setup({ + adapters = { + require('neotest-rspec')({ + rspec_cmd = function() + return vim.tbl_flatten({ + 'bundle', + 'exec', + 'rspec', + }) + end, + }), + require('neotest-jest')({ + jestCommand = 'npx jest --', + jestConfigFile = 'jest.config.js', + }), + require('neotest-python'), + }, +}) diff --git a/lua/plugins/lang/null-ls.lua b/lua/plugins/lang/null-ls.lua new file mode 100644 index 0000000..abb85d3 --- /dev/null +++ b/lua/plugins/lang/null-ls.lua @@ -0,0 +1,51 @@ +local null_ls = require('null-ls') + +local action = null_ls.builtins.code_actions +local comp = null_ls.builtins.completion +local diag = null_ls.builtins.diagnostics +local format = null_ls.builtins.formatting +local hover = null_ls.builtins.hover + +-- Buily in sources: https://github.com/nvimtools/none-ls.nvim/blob/main/doc/BUILTINS.md +null_ls.setup({ + debug = false, + border = 'rounded', + log_level = 'info', + diagnostics_format = '#{c} #{m} (#{s})', + sources = { + action.proselint, -- markdown actions + action.refactoring, + -- action.ts_node_action, -- treesitter node actions, buggy, causes repeated notifications + comp.spell, -- spell completion + comp.tags, -- tags completion + diag.actionlint, -- github action lint + diag.credo, -- elixir diagnostics + diag.golangci_lint, + diag.hadolint, -- docker lint + diag.proselint, -- markdown lint + diag.reek, -- ruby code smell + -- diag.rubocop, -- ruby diagnostics + -- diag.todo_comments, -- causes highlighter errors on J + diag.trail_space, -- trailing space check + diag.vint, -- vim lint + diag.write_good, -- english writing style + format.mix, -- elixir formatter + format.prettier, -- js, md, css, etc formatter + -- format.rubocop, -- ruby formatter + format.shfmt, -- shell formatter + format.stylua, -- lua formatter + hover.dictionary, -- show word dictionary on hover + hover.printenv, -- show env on hover + }, +}) + +local auto_install = require('lib.util').get_user_config('auto_install', true) +local installed_sources = {} +if auto_install then + installed_sources = require('plugins.list').null_ls_sources +end + +require('mason-null-ls').setup({ + ensure_installed = installed_sources, + automatic_installation = auto_install, +}) diff --git a/lua/plugins/lang/refactoring.lua b/lua/plugins/lang/refactoring.lua new file mode 100644 index 0000000..26b4a20 --- /dev/null +++ b/lua/plugins/lang/refactoring.lua @@ -0,0 +1,25 @@ +local refactoring = require('refactoring') + +refactoring.setup({ + prompt_func_return_type = { + go = false, + java = false, + cpp = false, + c = false, + h = false, + hpp = false, + cxx = false, + }, + prompt_func_param_type = { + go = false, + java = false, + + cpp = false, + c = false, + h = false, + hpp = false, + cxx = false, + }, + printf_statements = {}, + print_var_statements = {}, +}) diff --git a/lua/plugins/lang/ror.lua b/lua/plugins/lang/ror.lua new file mode 100644 index 0000000..8c988d4 --- /dev/null +++ b/lua/plugins/lang/ror.lua @@ -0,0 +1,20 @@ +local ror = require('ror') +local icons = require('lib.icons') + +ror.setup({ + test = { + message = { + file = 'Running test file...', + line = 'Running single test...', + }, + coverage = { + up = 'DiffAdd', + down = 'DiffDelete', + }, + notification = { + timeout = false, + }, + pass_icon = icons.ui.Check, + fail_icon = icons.ui.Close, + }, +}) diff --git a/lua/plugins/lang/sniprun.lua b/lua/plugins/lang/sniprun.lua new file mode 100644 index 0000000..711b157 --- /dev/null +++ b/lua/plugins/lang/sniprun.lua @@ -0,0 +1,27 @@ +local sniprun = require('sniprun') +local sniprun_api = require('sniprun.api') + +sniprun.setup({ + display = { 'Api' }, + show_no_output = { 'Classic', 'TempFloatingWindow' }, + + display_options = { + terminal_width = 45, + notification_timeout = 5, + }, + + inline_messages = 0, + borders = 'single', +}) + +local api_listener = function(d) + if d.status == 'ok' then + vim.notify('Output: \n' .. d.message, vim.log.levels.INFO) + elseif d.status == 'error' then + vim.notify('Error: \n' .. d.message, vim.log.levels.ERROR) + else + vim.notify('Sniprun: ' .. d.message, vim.log.levels.INFO) + end +end + +sniprun_api.register_listener(api_listener) diff --git a/lua/plugins/lang/surround.lua b/lua/plugins/lang/surround.lua new file mode 100644 index 0000000..73e4478 --- /dev/null +++ b/lua/plugins/lang/surround.lua @@ -0,0 +1,25 @@ +local surround = require('mini.surround') + +surround.setup({ + custom_surroundings = nil, + mappings = { + add = 'gsa', + delete = 'gsd', + find = 'gsf', + find_left = 'gsF', + highlight = 'gsh', + replace = 'gsr', + update_n_lines = 'gsn', + + suffix_last = 'l', -- Suffix to search with "prev" method + suffix_next = 'n', -- Suffix to search with "next" method + }, + + -- How to search for surrounding + -- 'cover', 'cover_or_next', 'cover_or_prev','cover_or_nearest', 'next', 'previous', 'nearest'. + search_method = 'cover_or_nearest', + highlight_duration = 500, + n_lines = 20, + respect_selection_type = false, + silent = false, +}) diff --git a/lua/plugins/lang/textobjects.lua b/lua/plugins/lang/textobjects.lua new file mode 100644 index 0000000..c335926 --- /dev/null +++ b/lua/plugins/lang/textobjects.lua @@ -0,0 +1,116 @@ +local textobjects = { + select = { + enable = true, + lookahead = true, + + keymaps = { + ['a='] = { query = '@assignment.outer', desc = 'Select outer part of an assignment' }, + ['i='] = { query = '@assignment.inner', desc = 'Select inner part of an assignment' }, + ['al='] = { query = '@assignment.lhs', desc = 'Select left hand side of an assignment' }, + ['ar='] = { + query = '@assignment.rhs', + desc = 'Select right hand side of an assignment', + }, + + ['a:'] = { query = '@property.outer', desc = 'Select outer part of an object property' }, + ['i:'] = { query = '@property.inner', desc = 'Select inner part of an object property' }, + ['l:'] = { query = '@property.lhs', desc = 'Select left part of an object property' }, + ['r:'] = { query = '@property.rhs', desc = 'Select right part of an object property' }, + + ['aa'] = { + query = '@parameter.outer', + desc = 'Select outer part of a parameter/argument', + }, + ['ia'] = { + query = '@parameter.inner', + desc = 'Select inner part of a parameter/argument', + }, + + ['ai'] = { query = '@conditional.outer', desc = 'Select outer part of a conditional' }, + ['ii'] = { query = '@conditional.inner', desc = 'Select inner part of a conditional' }, + + ['al'] = { query = '@loop.outer', desc = 'Select outer part of a loop' }, + ['il'] = { query = '@loop.inner', desc = 'Select inner part of a loop' }, + + ['af'] = { query = '@call.outer', desc = 'Select outer part of a function call' }, + ['if'] = { query = '@call.inner', desc = 'Select inner part of a function call' }, + + ['am'] = { + query = '@function.outer', + desc = 'Select outer part of a method/function definition', + }, + ['im'] = { + query = '@function.inner', + desc = 'Select inner part of a method/function definition', + }, + + ['ac'] = { query = '@class.outer', desc = 'Select outer part of a class' }, + ['ic'] = { query = '@class.inner', desc = 'Select inner part of a class' }, + }, + }, + swap = { + enable = true, + swap_next = { + ['rna'] = '@parameter.inner', -- swap object property with next + ['rn:'] = '@property.outer', -- swap parameters/argument with next + ['rnm'] = '@function.outer', -- swap function with next + }, + swap_previous = { + ['rpa'] = '@parameter.inner', -- swap parameters/argument with prev + ['rp:'] = '@property.outer', -- swap object property with prev + ['rpm'] = '@function.outer', -- swap function with previous + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']c'] = { query = '@class.outer', desc = 'Next class start' }, + [']f'] = { query = '@call.outer', desc = 'Next function call start' }, + [']i'] = { query = '@conditional.outer', desc = 'Next conditional start' }, + [']l'] = { query = '@loop.outer', desc = 'Next loop start' }, + [']m'] = { query = '@function.outer', desc = 'Next method/function def start' }, + [']z'] = { query = '@fold', query_group = 'folds', desc = 'Next fold' }, + -- You can pass a query group to use query from `queries//.scm file in your runtime path. + -- Above example nvim-treesitter's folds.scm`. They also provide locals.scm, highlights.scm and indent.scm. + }, + goto_next_end = { + [']C'] = { query = '@class.outer', desc = 'Next class end' }, + [']F'] = { query = '@call.outer', desc = 'Next function call end' }, + [']I'] = { query = '@conditional.outer', desc = 'Next conditional end' }, + [']L'] = { query = '@loop.outer', desc = 'Next loop end' }, + [']M'] = { query = '@function.outer', desc = 'Next method/function def end' }, + [']Z'] = { query = '@fold', query_group = 'folds', desc = 'Next fold end' }, + }, + goto_previous_start = { + ['[c'] = { query = '@class.outer', desc = 'Prev class start' }, + ['[f'] = { query = '@call.outer', desc = 'Prev function call start' }, + ['[i'] = { query = '@conditional.outer', desc = 'Prev conditional start' }, + ['[l'] = { query = '@loop.outer', desc = 'Prev loop start' }, + ['[m'] = { query = '@function.outer', desc = 'Prev method/function def start' }, + ['[z'] = { query = '@fold', query_group = 'folds', desc = 'Prev fold' }, + }, + goto_previous_end = { + ['[C'] = { query = '@class.outer', desc = 'Prev class end' }, + ['[F'] = { query = '@call.outer', desc = 'Prev function call end' }, + ['[I'] = { query = '@conditional.outer', desc = 'Prev conditional end' }, + ['[L'] = { query = '@loop.outer', desc = 'Prev loop end' }, + ['[M'] = { query = '@function.outer', desc = 'Prev method/function def end' }, + ['[Z'] = { query = '@fold', query_group = 'folds', desc = 'Prev fold end' }, + }, + }, +} + +local ts_repeat_move = require('nvim-treesitter.textobjects.repeatable_move') + +-- vim way: ; goes to the direction you were moving. +vim.keymap.set({ 'n', 'x', 'o' }, ';', ts_repeat_move.repeat_last_move) +vim.keymap.set({ 'n', 'x', 'o' }, ',', ts_repeat_move.repeat_last_move_opposite) + +-- Optionally, make builtin f, F, t, T also repeatable with ; and , +vim.keymap.set({ 'n', 'x', 'o' }, 'f', ts_repeat_move.builtin_f) +vim.keymap.set({ 'n', 'x', 'o' }, 'F', ts_repeat_move.builtin_F) +vim.keymap.set({ 'n', 'x', 'o' }, 't', ts_repeat_move.builtin_t) +vim.keymap.set({ 'n', 'x', 'o' }, 'T', ts_repeat_move.builtin_T) + +return textobjects diff --git a/lua/plugins/lang/treesitter.lua b/lua/plugins/lang/treesitter.lua new file mode 100644 index 0000000..8d3d9d1 --- /dev/null +++ b/lua/plugins/lang/treesitter.lua @@ -0,0 +1,84 @@ +local treesitter = require('nvim-treesitter.configs') +local textobjects = require('plugins.lang.textobjects') + +local auto_install = require('lib.util').get_user_config('auto_install', true) +local installed_parsers = {} +if auto_install then + installed_parsers = require('plugins.list').ts_parsers +end + +treesitter.setup({ + ensure_installed = installed_parsers, + sync_install = false, + ignore_install = {}, + auto_install = true, + + textobjects = textobjects, + autopairs = { enable = true }, + endwise = { enable = true }, + autotag = { enable = true }, + matchup = { enable = true }, + indent = { enable = true }, + + highlight = { + enable = true, + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + additional_vim_regex_highlighting = false, + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = false, + node_decremental = '', + }, + }, + + textsubjects = { + enable = true, + prev_selection = ',', + keymaps = { + ['.'] = { 'textsubjects-smart', desc = 'Select the current text subject' }, + ['a;'] = { + 'textsubjects-container-outer', + desc = 'Select outer container (class, function, etc.)', + }, + ['i;'] = { + 'textsubjects-container-inner', + desc = 'Select inside containers (classes, functions, etc.)', + }, + }, + }, + + refactor = { + highlight_definitions = { + enable = true, + clear_on_cursor_move = true, + }, + highlight_current_scope = { enable = true }, + smart_rename = { + enable = true, + keymaps = { + smart_rename = 'rr', + }, + }, + navigation = { + enable = true, + keymaps = { + goto_definition = 'rd', + list_definitions = 'rl', + list_definitions_toc = 'rh', + goto_next_usage = 'rj', + goto_previous_usage = 'rk', + }, + }, + }, +}) diff --git a/lua/core/lazy.lua b/lua/plugins/lazy.lua similarity index 92% rename from lua/core/lazy.lua rename to lua/plugins/lazy.lua index 226b06c..cfd4752 100644 --- a/lua/core/lazy.lua +++ b/lua/plugins/lazy.lua @@ -17,14 +17,15 @@ if not status_ok then end local icons = require('lib.icons') +local plugins = require('plugins.list').plugins lazy.setup({ root = vim.fn.stdpath('data') .. '/lazy', defaults = { lazy = true }, - spec = 'plugins', - lockfile = vim.fn.stdpath('config') .. '/lua/lock.json', + spec = plugins, + lockfile = vim.fn.stdpath('config') .. '/lua/plugins/lock.json', concurrency = 8, - dev = { path = '~/Projects/GitHub/', patterns = {}, fallback = false }, + dev = { path = '~/Projects/2KAbhishek/', patterns = {"2kabhishek"}, fallback = true }, install = { missing = true, colorscheme = { 'onedark' } }, git = { diff --git a/lua/plugins/lint.lua b/lua/plugins/lint.lua deleted file mode 100644 index 9b1f46e..0000000 --- a/lua/plugins/lint.lua +++ /dev/null @@ -1,105 +0,0 @@ --- Define nvim-lint linters here -local linting_servers = { - 'eslint_d', - 'cspell', - -- 'ruff', - -- 'mypy', - 'trivy', - 'phpcs', - 'markdownlint', - 'pylint', - -- 'shellcheck', -} - -return { - 'mfussenegger/nvim-lint', - dependencies = { - 'rshkarin/mason-nvim-lint', - }, - event = { 'BufReadPre', 'BufNewFile' }, - - config = function() - local lint = require('lint') - require('mason-nvim-lint').setup({ - ensure_installed = linting_servers, - automatic_installation = true, - }) - - lint.linters_by_ft = { - lua = { 'selene' }, - javascript = { 'eslint_d' }, - typescript = { 'eslint_d' }, - javascriptreact = { 'eslint_d' }, - typescriptreact = { 'eslint_d' }, - python = { 'pylint' }, - markdown = { 'markdownlint' }, - java = { 'trivy' }, - php = { 'phpcs' }, - -- bash = { 'shellcheck' }, - } - - -- Run pylint in the venv - -- https://gist.github.com/Norbiox/652befc91ca0f90014aec34eccee27b2 - lint.linters.pylint.cmd = 'python' - lint.linters.pylint.args = { - '-m', - 'pylint', - '-f', - 'json', - '--from-stdin', - function() - return vim.api.nvim_buf_get_name(0) - end, - } - -- To allow other plugins to add linters to require('lint').linters_by_ft, - -- instead set linters_by_ft like this: - -- lint.linters_by_ft = lint.linters_by_ft or {} - -- lint.linters_by_ft['markdown'] = { 'markdownlint' } - -- - -- However, note that this will enable a set of default linters, - -- which will cause errors unless these tools are available: - -- { - -- clojure = { "clj-kondo" }, - -- dockerfile = { "hadolint" }, - -- inko = { "inko" }, - -- janet = { "janet" }, - -- json = { "jsonlint" }, - -- markdown = { "vale" }, - -- rst = { "vale" }, - -- ruby = { "ruby" }, - -- terraform = { "tflint" }, - -- text = { "vale" } - -- } - -- - -- You can disable the default linters by setting their filetypes to nil: - -- lint.linters_by_ft['clojure'] = nil - -- lint.linters_by_ft['dockerfile'] = nil - -- lint.linters_by_ft['inko'] = nil - -- lint.linters_by_ft['janet'] = nil - -- lint.linters_by_ft['json'] = nil - -- lint.linters_by_ft['markdown'] = nil - -- lint.linters_by_ft['rst'] = nil - -- lint.linters_by_ft['ruby'] = nil - -- lint.linters_by_ft['terraform'] = nil - -- lint.linters_by_ft['text'] = nil - - local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) - vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { - group = lint_augroup, - callback = function() - if not vim.g.disable_linting then - if not vim.b.disable_linting then - lint.try_lint() - end - end - end, - }) - - vim.keymap.set('n', 'cl', function() - vim.b.disable_linting = not (vim.b.disable_linting == true) - end, { desc = 'Toggle linting for file' }) - vim.keymap.set('n', 'cL', function() - vim.g.disable_linting = not (vim.g.disable_linting == true) - end, { desc = 'Toggle linting for all files' }) - end, -} diff --git a/lua/plugins/list.lua b/lua/plugins/list.lua new file mode 100644 index 0000000..6d32955 --- /dev/null +++ b/lua/plugins/list.lua @@ -0,0 +1,550 @@ +local function load_config(package) + return function() + require('plugins.' .. package) + end +end + +local plugins = { + -- UI + { + 'navarasu/onedark.nvim', + config = load_config('ui.onedark'), + lazy = false, + priority = 1000, + }, + { + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + config = load_config('ui.snacks'), + }, + { + 'nvim-lualine/lualine.nvim', + config = load_config('ui.lualine'), + event = { 'BufReadPost', 'BufNewFile' }, + }, + { + 'stevearc/dressing.nvim', + config = load_config('ui.dressing'), + event = { 'BufReadPost', 'BufNewFile' }, + }, + + -- Language + { + 'mfussenegger/nvim-dap', + dependencies = { + 'rcarriga/nvim-dap-ui', + }, + config = load_config('lang.dap'), + cmd = { 'DapUIToggle', 'DapToggleRepl', 'DapToggleBreakpoint' }, + }, + { + 'nvim-neotest/neotest', + dependencies = { + 'nvim-neotest/nvim-nio', + 'olimorris/neotest-rspec', + 'nvim-neotest/neotest-jest', + 'nvim-neotest/neotest-python', + }, + config = load_config('lang.neotest'), + cmd = 'Neotest', + }, + { + 'michaelb/sniprun', + build = 'bash ./install.sh', + config = load_config('lang.sniprun'), + cmd = 'SnipRun', + }, + { + 'ThePrimeagen/refactoring.nvim', + config = load_config('lang.refactoring'), + }, + { + 'windwp/nvim-autopairs', + config = load_config('lang.autopairs'), + event = 'InsertEnter', + }, + { + 'echasnovski/mini.surround', + version = '*', + config = load_config('lang.surround'), + event = { 'BufReadPost', 'BufNewFile' }, + }, + { + 'echasnovski/mini.ai', + version = '*', + config = load_config('lang.ai'), + event = { 'BufReadPost', 'BufNewFile' }, + }, + + -- Tresitter + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + dependencies = { + 'nvim-treesitter/nvim-treesitter-refactor', + 'nvim-treesitter/nvim-treesitter-textobjects', + 'RRethy/nvim-treesitter-endwise', + 'RRethy/nvim-treesitter-textsubjects', + 'windwp/nvim-ts-autotag', + }, + config = load_config('lang.treesitter'), + event = { 'BufReadPost', 'BufNewFile' }, + }, + -- LSP + { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason-lspconfig.nvim', + 'saghen/blink.cmp', + }, + config = load_config('lang.lspconfig'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'folke/lazydev.nvim', + ft = 'lua', + }, + { + 'nvimdev/lspsaga.nvim', + config = load_config('lang.lspsaga'), + event = 'LspAttach', + }, + { + 'williamboman/mason.nvim', + config = load_config('lang.mason'), + cmd = 'Mason', + }, + { + 'nvimtools/none-ls.nvim', + dependencies = { 'neovim/nvim-lspconfig', 'jay-babu/mason-null-ls.nvim' }, + config = load_config('lang.null-ls'), + event = { 'BufReadPost', 'BufNewFile' }, + }, + + -- Completion + { + 'saghen/blink.cmp', + dependencies = { 'rafamadriz/friendly-snippets', 'giuxtaposition/blink-cmp-copilot' }, + version = '*', + config = load_config('lang.blink'), + opts_extend = { 'sources.default' }, + event = { 'InsertEnter' }, + }, + { + 'zbirenbaum/copilot.lua', + dependencies = { 'giuxtaposition/blink-cmp-copilot' }, + config = load_config('lang.copilot'), + event = 'InsertEnter', + }, + { + 'CopilotC-Nvim/CopilotChat.nvim', + dependencies = { + { 'zbirenbaum/copilot.lua' }, + { 'nvim-lua/plenary.nvim' }, + }, + branch = 'main', + build = 'make tiktoken', -- Only on MacOS or Linux + cmd = { + 'CopilotChat', + 'CopilotChatToggle', + 'CopilotChatDocs', + 'CopilotChatExplain', + 'CopilotChatFix', + 'CopilotChatFixDiagnostic', + 'CopilotChatCommit', + 'CopilotChatCommitStaged', + 'CopilotChatLoad', + 'CopilotChatOptimize', + 'CopilotChatReview', + 'CopilotChatSave', + 'CopilotChatTests', + }, + config = load_config('lang.copilot-chat'), + }, + { + 'Exafunction/codeium.vim', + event = 'InsertEnter', + config = function() + vim.keymap.set('i', '', function() + return vim.fn['codeium#Accept']() + end, { expr = true, silent = true }) + vim.keymap.set('i', '', function() + return vim.fn['codeium#CycleCompletions'](1) + end, { expr = true, silent = true }) + vim.keymap.set('i', '', function() + return vim.fn['codium#CycleCompletions'](-1) + end, { expr = true, silent = true }) + vim.keymap.set('i', '', function() + return vim.fn['codeium#Clear']() + end, { expr = true, silent = true }) + vim.keymap.set('n', 'cI', 'CodeiumToggle', { desc = 'Toggle IA (Codeium)' }) + end, + }, + + -- Tools + + { + 'nvim-neo-tree/neo-tree.nvim', + cmd = { 'Neotree' }, + opts = { + filesystem = { + filtered_items = { + visible = true, + show_hidden_count = true, + hide_dotfiles = false, + hide_gitignored = true, + hide_by_name = { + '.git', + '.DS_Store', + 'thumbs.db', + '.venv', + }, + never_show = {}, + }, + }, + window = { + position = 'right', + width = 35, + }, + }, + }, + { + 'LudoPinelli/comment-box.nvim', + event = 'BufReadPre', + opts = { + box_width = 70, + }, + }, + { + 'mistricky/codesnap.nvim', + lazy = true, + build = 'make', + opts = { + save_path = '~/Pictures/screenshots/code', + has_breadcrumbs = false, + show_workspace = false, + bg_theme = 'default', + watermark = 'S4NKALP', + code_font_family = 'Iosevka NF', + code_font_size = 12, + }, + cmd = { 'CodeSnap', 'CodeSnapSave', 'CodeSnapHighlight', 'CodeSnapASCII' }, + }, + { + 'wakatime/vim-wakatime', + event = { 'VimEnter' }, + lazy = false, + }, + { + 'windwp/nvim-spectre', + config = load_config('tools.spectre'), + cmd = 'Spectre', + }, + { + 'abecodes/tabout.nvim', + config = load_config('tools.tabout'), + event = 'InsertEnter', + }, + { + 'folke/flash.nvim', + config = load_config('tools.flash'), + keys = { + { + 's', + mode = { 'n', 'x', 'o' }, + function() + require('flash').jump() + end, + desc = 'Flash', + }, + { + 'S', + mode = { 'n', 'x', 'o' }, + function() + require('flash').treesitter() + end, + desc = 'Flash Treesitter', + }, + }, + }, + { + 'numToStr/Navigator.nvim', + config = load_config('tools.navigator'), + event = function() + if vim.fn.exists('$TMUX') == 1 then + return 'VeryLazy' + end + end, + }, + { + 'm4xshen/hardtime.nvim', + dependencies = { 'MunifTanjim/nui.nvim', 'nvim-lua/plenary.nvim' }, + config = function() + require('hardtime').setup({ enabled = true }) + end, + cmd = 'Hardtime', + }, + { + 'chrisgrieser/nvim-spider', + config = load_config('tools.spider'), + event = { 'BufReadPost', 'BufNewFile' }, + }, + { + 'folke/which-key.nvim', + config = load_config('tools.which-key'), + event = 'VeryLazy', + }, + { + 'iamcco/markdown-preview.nvim', + build = function() + vim.fn['mkdp#util#install']() + end, + ft = 'markdown', + cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview' }, + }, + { + 'uga-rosa/ccc.nvim', + config = load_config('tools.ccc'), + cmd = { 'CccHighlighterToggle', 'CccConvert', 'CccPick' }, + }, + { + '2kabhishek/termim.nvim', + cmd = { 'Fterm', 'FTerm', 'Sterm', 'STerm', 'Vterm', 'VTerm' }, + }, + { + + 'akinsho/toggleterm.nvim', + cmd = { 'ToggleTerm' }, + version = 'v2.*', + config = load_config('tools.toggleterm'), + }, + { + 'cvigilv/esqueleto.nvim', + event = 'VeryLazy', + opts = { + directories = { + vim.fn.stdpath('config') .. '/templates', + }, + patterns = { + -- File + 'README', + 'LICENSE', + -- Filetype + 'sh', + 'markdown', + 'python', + 'lua', + 'html', + 'vue', + }, + }, + }, + { + 'creativenull/dotfyle-metadata.nvim', + cmd = { 'DotfyleGenerate', 'DotfyleOpen' }, + }, + { + 'kndndrj/nvim-dbee', + dependencies = { + 'MunifTanjim/nui.nvim', + }, + build = function() + -- "curl", "wget", "bitsadmin", "go" + require('dbee').install('curl') + end, + config = load_config('tools.dbee'), + cmd = 'DBToggle', + enabled = false, + }, + { + 'zapling/mason-lock.nvim', + cmd = { 'MasonLock', 'MasonLockRestore' }, + config = function() + require('mason-lock').setup({ + lockfile_path = vim.fn.stdpath('config') .. '/lua/plugins/mason-lock.json', + }) + end, + }, + { + 'epwalsh/pomo.nvim', + cmd = { 'TimerStart', 'TimerStop', 'TimerRepeat' }, + dependencies = { + 'rcarriga/nvim-notify', + }, + opts = { + notifiers = { + { + name = 'Default', + opts = { + sticky = false, + }, + }, + }, + }, + }, + { + 'nvchad/showkeys', + cmd = 'ShowkeysToggle', + opts = { + timeout = 1, + maxkeys = 8, + }, + }, + { + 'ThePrimeagen/vim-be-good', + cmd = 'VimBeGood', + }, + { "tweekmonster/django-plus.vim" }, + + -- Telescope + { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + }, + 'debugloop/telescope-undo.nvim', + 'nvim-telescope/telescope-file-browser.nvim', + }, + config = load_config('tools.telescope'), + cmd = 'Telescope', + }, + { + -- 'chentoast/marks.nvim', + '2kabhishek/markit.nvim', + config = load_config('tools.marks'), + event = { 'BufReadPost', 'BufNewFile' }, + }, + { + '2kabhishek/nerdy.nvim', + dependencies = { 'stevearc/dressing.nvim' }, + cmd = 'Nerdy', + }, + + -- Git + { + 'ruifm/gitlinker.nvim', + config = load_config('tools.gitlinker'), + keys = 'yg', + }, + { + 'lewis6991/gitsigns.nvim', + config = load_config('tools.gitsigns'), + cmd = 'Gitsigns', + event = { 'BufReadPost', 'BufNewFile' }, + }, + { + 'tpope/vim-fugitive', + cmd = 'Git', + }, +} + +local treesitter_parsers = { + 'bash', + 'css', + 'c', + 'dart', + 'elixir', + 'gitcommit', + 'go', + 'html', + 'java', + 'javascript', + 'json', + 'lua', + 'markdown', + 'markdown_inline', -- markdown code blocks + 'python', + 'ruby', + 'rust', + 'scss', + 'typescript', + 'vim', + 'vimdoc', + 'yaml', +} + +local null_ls_sources = { + 'shellcheck', -- bash lint +} + +local lsp_servers = { + 'bashls', + 'jsonls', + 'lua_ls', + 'typos_lsp', -- check typos + 'vimls', + +} + +local util = require('lib.util') + +if util.is_present('npm') then + table.insert(lsp_servers, 'eslint') + table.insert(lsp_servers, 'ts_ls') +end + +if util.is_present('gem') then + local ror_nvim = { + 'weizheheng/ror.nvim', + branch = 'main', + ft = 'ruby', + config = load_config('lang.ror'), + keys = { + { + 'rc', + mode = { 'n' }, + function() + vim.cmd('RorCommands') + end, + desc = 'Rails Commands', + }, + }, + } + local vim_rails = { + 'tpope/vim-rails', + ft = 'ruby', + } + + table.insert(lsp_servers, 'solargraph') + -- table.insert(lsp_servers, 'ruby_lsp') + table.insert(lsp_servers, 'rubocop') + table.insert(plugins, ror_nvim) + table.insert(plugins, vim_rails) +end + +if util.is_present('go') then + table.insert(lsp_servers, 'gopls') +end + +if util.is_present('dart') then + table.insert(lsp_servers, 'dartls') +end + +if util.is_present('java') then + table.insert(lsp_servers, 'jdtls') +end + +if util.is_present('pip') then + table.insert(lsp_servers, 'ruff') + table.insert(lsp_servers, 'pyright') +end + +if util.is_present('mix') then + table.insert(lsp_servers, 'elixirls') +end + +if util.is_present('cargo') then + table.insert(lsp_servers, 'rust_analyzer') +end + +return { + plugins = plugins, + lsp_servers = lsp_servers, + null_ls_sources = null_ls_sources, + ts_parsers = treesitter_parsers, +} diff --git a/lua/plugins/lock.json b/lua/plugins/lock.json new file mode 100644 index 0000000..b722709 --- /dev/null +++ b/lua/plugins/lock.json @@ -0,0 +1,74 @@ +{ + "CopilotChat.nvim": { "branch": "main", "commit": "2ebe591cff06018e265263e71e1dbc4c5aa8281e" }, + "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, + "blink-cmp-copilot": { "branch": "main", "commit": "c5c5cbce5748d21073f1d5348a92ebe6ce63f387" }, + "blink.cmp": { "branch": "main", "commit": "5f442681df24fe705d1ee7ce5b4d435aa4b4dee4" }, + "ccc.nvim": { "branch": "main", "commit": "7c639042583c7bdc7ce2e37e5a0e0aa6d0659c6a" }, + "codeium.vim": { "branch": "main", "commit": "d152e6cd3d814a44f36447bb0d21d51f6787fe9c" }, + "codesnap.nvim": { "branch": "main", "commit": "6400480aa6cc366cbd931146c429aaa64680dab9" }, + "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, + "copilot.lua": { "branch": "master", "commit": "886ee73b6d464b2b3e3e6a7ff55ce87feac423a9" }, + "django-plus.vim": { "branch": "master", "commit": "220cfbc03e89c636606f0f4bc89f8135be5f765e" }, + "dotfyle-metadata.nvim": { "branch": "main", "commit": "342ef8f3f98f3ccc451c9cf2be74e95149ced05d" }, + "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, + "esqueleto.nvim": { "branch": "main", "commit": "0f79ccafc931f706d175549c1339848eb8fa8470" }, + "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, + "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, + "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, + "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, + "hardtime.nvim": { "branch": "main", "commit": "5d9adcbe2f12741de79e435c8b85dca69a3b22e4" }, + "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "lazydev.nvim": { "branch": "main", "commit": "8620f82ee3f59ff2187647167b6b47387a13a018" }, + "lspsaga.nvim": { "branch": "main", "commit": "5fce15331ac6c3a3ec3ac91ab0e85ed82f5cbba0" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "markit.nvim": { "branch": "main", "commit": "6a59bcc5140bed8fcf9cec2cba8d442072b1b76d" }, + "mason-lock.nvim": { "branch": "main", "commit": "86614f76c3442fba1c5c8d79aa1efcb3ad69de1c" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.ai": { "branch": "main", "commit": "40e380a589d07ec2c856940c6422aafe5d949a0d" }, + "mini.surround": { "branch": "main", "commit": "0e67c4bc147f2a15cee94e7c94dcc0e115b9f55e" }, + "neo-tree.nvim": { "branch": "main", "commit": "a9f8943b4c31f8460d25c71e0f463d65e9775f1c" }, + "neotest": { "branch": "master", "commit": "0dccb5ebcf00de245e2060fa17822a9464f5c41a" }, + "neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" }, + "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" }, + "neotest-rspec": { "branch": "main", "commit": "f8c91edc5dd87ca467a624652f365ac217d7cc1c" }, + "nerdy.nvim": { "branch": "main", "commit": "719ed52244b34ea9de08f074e0d22fd67d615640" }, + "none-ls.nvim": { "branch": "main", "commit": "02144ef2b86a816b5dec69783e311bb6feff7d82" }, + "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, + "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, + "nvim-dap": { "branch": "master", "commit": "ffb077e65259f13be096ea6d603e3575a76b214a" }, + "nvim-dap-ui": { "branch": "master", "commit": "e94d98649dccb6a3884b66aabc2e07beb279e535" }, + "nvim-lspconfig": { "branch": "master", "commit": "8b15a1a597a59f4f5306fad9adfe99454feab743" }, + "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, + "nvim-notify": { "branch": "master", "commit": "c3797193536711b5d8983975791c4b11dc35ab3a" }, + "nvim-spectre": { "branch": "master", "commit": "08be31c104df3b4b049607694ebb2b6ced4f928b" }, + "nvim-spider": { "branch": "main", "commit": "2b38e3e95e143313d78ca098eeecda7aebfce925" }, + "nvim-treesitter": { "branch": "master", "commit": "4b222913486ec0a5983efa82b0649a2ab87cf1f0" }, + "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" }, + "nvim-treesitter-refactor": { "branch": "master", "commit": "d8b74fa87afc6a1e97b18da23e762efb032dc270" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "ad8f0a472148c3e0ae9851e26a722ee4e29b1595" }, + "nvim-treesitter-textsubjects": { "branch": "master", "commit": "a8d2844bba925d9450ef7ab215f3b054028288ca" }, + "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, + "onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "pomo.nvim": { "branch": "main", "commit": "aa8decc421d89be0f10b1fc6a602cdd269f350ff" }, + "refactoring.nvim": { "branch": "master", "commit": "2db6d378e873de31d18ade549c2edba64ff1c2e3" }, + "ror.nvim": { "branch": "main", "commit": "9d31ad3953be83ac8dd542725ca4881c861f64a5" }, + "showkeys": { "branch": "main", "commit": "3c62fd88e685fd08f0f2724e1c0856d77dd0d552" }, + "snacks.nvim": { "branch": "main", "commit": "98df370703b3c47a297988f3e55ce99628639590" }, + "sniprun": { "branch": "master", "commit": "67ac2d84d03f3b857d59571ff5fefb6080dffa2d" }, + "tabout.nvim": { "branch": "master", "commit": "9a3499480a8e53dcaa665e2836f287e3b7764009" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, + "telescope-undo.nvim": { "branch": "main", "commit": "2971cc9f193ec09e0c5de3563f99cbea16b63f10" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "termim.nvim": { "branch": "main", "commit": "58344167abb97bcef9bf720a762ea653a94e9daa" }, + "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, + "vim-be-good": { "branch": "master", "commit": "0ae3de14eb8efc6effe7704b5e46495e91931cc5" }, + "vim-fugitive": { "branch": "master", "commit": "174230d6a7f2df94705a7ffd8d5413e27ec10a80" }, + "vim-rails": { "branch": "master", "commit": "d3954dfe3946c9330dc91b4fbf79ccacb2c626c0" }, + "vim-wakatime": { "branch": "master", "commit": "cf51327a9e08935569614d1cb24e779ee9f45519" }, + "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" } +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua deleted file mode 100644 index 1aa8309..0000000 --- a/lua/plugins/lsp.lua +++ /dev/null @@ -1,381 +0,0 @@ -return { - { - 'williamboman/mason.nvim', - cmd = { 'Mason', 'MasonInstall', 'MasonUninstall', 'MasonInstallAll', 'MasonUpdate' }, - config = function() - -- import mason - local mason = require('mason') - - -- enable mason and configure icons - mason.setup({ - ui = { - icons = { - package_installed = '✓', - package_pending = '➜', - package_uninstalled = '✗', - }, - }, - }) - end, - }, - { - -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = 'luvit-meta/library', words = { 'vim%.uv' } }, - }, - }, - }, - { 'Bilal2453/luvit-meta', lazy = true }, - { - -- Main LSP Configuration - 'neovim/nvim-lspconfig', - event = { 'BufReadPre', 'BufNewFile' }, - dependencies = { - -- Automatically install LSPs and related tools to stdpath for Neovim - 'williamboman/mason.nvim', - 'williamboman/mason-lspconfig.nvim', - - -- Useful status updates for LSP. - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, - - -- Allows extra capabilities provided by nvim-cmp - 'hrsh7th/cmp-nvim-lsp', - }, - config = function() - -- Brief aside: **What is LSP?** - -- - -- LSP is an initialism you've probably heard, but might not understand what it is. - -- - -- LSP stands for Language Server Protocol. It's a protocol that helps editors - -- and language tooling communicate in a standardized fashion. - -- - -- In general, you have a "server" which is some tool built to understand a particular - -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers - -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone - -- processes that communicate with some "client" - in this case, Neovim! - -- - -- LSP provides Neovim with features like: - -- - Go to definition - -- - Find references - -- - Autocompletion - -- - Symbol Search - -- - and more! - -- - -- Thus, Language Servers are external tools that must be installed separately from - -- Neovim. This is where `mason` and related plugins come into play. - -- - -- If you're wondering about lsp vs treesitter, you can check out the wonderfully - -- and elegantly composed help section, `:help lsp-vs-treesitter` - - -- This function gets run when an LSP attaches to a particular buffer. - -- That is to say, every time a new file is opened that is associated with - -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this - -- function will be executed to configure the current buffer - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), - callback = function(event) - -- 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. - -- - -- 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 map = function(keys, func, desc, mode) - mode = mode or 'n' - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) - end - - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map('gd', function() - require('telescope.builtin').lsp_definitions() - end, 'Goto definition') - - -- Find references for the word under your cursor. - map('gr', function() - require('telescope.builtin').lsp_references() - end, 'Goto references') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gI', function() - require('telescope.builtin').lsp_implementations() - end, 'Goto implementation') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('cD', function() - require('telescope.builtin').lsp_type_definitions() - end, 'Code Type definition') - - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map('ss', function() - require('telescope.builtin').lsp_document_symbols() - end, 'Document symbols') - - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map('sS', function() - require('telescope.builtin').lsp_dynamic_workspace_symbols() - end, 'Workspace symbols') - - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map('cR', vim.lsp.buf.rename, 'Code: rename') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - -- map('ca', vim.lsp.buf.code_action, 'Code action') - map('ca', vim.lsp.buf.code_action, 'Code action', { 'n', 'x' }) - -- map('ca', function() require('tiny-code-action').code_action() end, 'Code action', { 'n', 'x' }) - - map('vR', 'LspRestart', 'Restart LSP') - - -- Opens a popup that displays documentation about the word under your cursor - -- See `:help K` for why this keymap. - map('K', vim.lsp.buf.hover, 'Hover Documentation') - - -- WARN: This is not Goto Definition, this is Goto Declaration. - -- For example, in C this would take you to the header. - map('gD', vim.lsp.buf.declaration, 'Goto declaration') - - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = - vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds({ group = 'kickstart-lsp-highlight', buffer = event2.buf }) - end, - }) - end - - -- The following code creates a keymap to toggle inlay hints in your - -- code, if the language server you are using supports them - -- - -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - map('vH', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf })) - end, 'Toggle inlay hints') - vim.lsp.inlay_hint.enable() - end - end, - }) - - -- LSP servers and clients are able to communicate to each other what features they support. - -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - - -- Change the Diagnostic symbols in the sign column (gutter) - -- local signs = { Error = '󰅚 ', Warn = '󰀪 ', Info = ' ', Hint = '󰌶 ' } - local signs = { Error = ' ', Warn = ' ', Info = ' ', Hint = '' } - for type, icon in pairs(signs) do - local hl = 'DiagnosticSign' .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' }) - end - - -- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998. - vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { - border = 'rounded', - }) - - -- Enable the following language servers - -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. - -- - -- Add any additional override configuration in the following tables. Available keys are: - -- - cmd (table): Override the default command used to start the server - -- - filetypes (table): Override the default list of associated filetypes for the server - -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. - -- - settings (table): Override the default settings passed when initializing the server. - -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ - - local servers = { - -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- - -- Some languages (like typescript) have entire language plugins that can be useful: - -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, - -- - - lua_ls = { - -- cmd = {...}, - -- filetypes = { ...}, - -- capabilities = {}, - settings = { - Lua = { - workspace = { - checkThirdParty = false, - }, - completion = { - callSnippet = 'Replace', - }, - codeLens = { - enable = true, - }, - doc = { - privateName = { '^_' }, - }, - hint = { - enable = true, - setType = false, - paramType = true, - paramName = 'Disable', - semicolon = 'Disable', - arrayIndex = 'Disable', - }, - -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { - 'vim', - 'it', - 'describe', - 'before_each', - 'after_each', - }, - }, - }, - }, - }, - - -- Bash - bashls = { - filetypes = { 'sh', 'bash' }, - }, - - -- HTML / CSS - html = {}, - cssls = {}, - tailwindcss = {}, - - -- Javascript/Typescript - ts_ls = {}, - - -- Java - jdtls = {}, - - -- Python - pyright = {}, - ruff = {}, - - -- C/C++ - clangd = {}, - - -- Ruby for Shopify - -- ruby_lsp = { - -- init_options = { - -- formatter = 'standard', - -- linters = { 'standard' }, - -- }, - -- }, - - rust_analyzer = { - cargo = { - allFeatures = true, - loadOutDirsFromCheck = true, - buildScripts = { - enable = true, - }, - }, - -- Add clippy lints for Rust. - checkOnSave = true, - procMacro = { - enable = true, - ignored = { - ['async-trait'] = { 'async_trait' }, - ['napi-derive'] = { 'napi' }, - ['async-recursion'] = { 'async_recursion' }, - }, - }, - }, - - -- TOML - taplo = {}, - - -- Shopify - -- theme_check = {}, - - -- Typo is too noisy for me without a simple way to override - -- typos_lsp = {}, - - -- YAML - yamlls = {}, - } - - -- Ensure the servers and tools above are installed - -- To check the current status of installed tools and/or manually install - -- other tools, you can run - -- :Mason - -- - -- You can press `g?` for help in this menu. - - -- You can add other tools here that you want Mason to install - -- for you, so that they are available from within Neovim. - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { - 'pyright', -- Used to format Lua code - }) - - if not vim.g.no_mason_autoinstall then - require('mason-lspconfig').setup({ ensure_installed = ensure_installed }) - end - - require('mason-lspconfig').setup({ - handlers = { - function(server_name) - -- https://github.com/neovim/nvim-lspconfig/pull/3232#issuecomment-2331025714 - -- if server_name == 'tsserver' then server_name = 'ts_ls' end - - local server = servers[server_name] or {} - -- This handles overriding only values explicitly passed - -- by the server configuration above. Useful when disabling - -- certain features of an LSP (for example, turning off formatting for tsserver) - server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) - require('lspconfig')[server_name].setup(server) - end, - }, - }) - - -- Border for LSPInfo - require('lspconfig.ui.windows').default_options.border = 'single' - end, - }, -} diff --git a/lua/plugins/mason-lock.json b/lua/plugins/mason-lock.json new file mode 100644 index 0000000..f79382b --- /dev/null +++ b/lua/plugins/mason-lock.json @@ -0,0 +1,18 @@ +{ + "bash-language-server": "5.4.2", + "eslint-lsp": "4.10.0", + "gopls": "v0.17.1", + "hadolint": "v2.12.0", + "jdtls": "v1.43.0", + "json-lsp": "4.10.0", + "lua-language-server": "3.13.5", + "pyright": "1.1.391", + "rubocop": "1.69.2", + "ruff": "0.8.4", + "rust-analyzer": "2024-12-30", + "shellcheck": "v0.10.0", + "solargraph": "0.50.0", + "typescript-language-server": "4.3.3", + "typos-lsp": "v0.1.32", + "vim-language-server": "2.3.1" +} \ No newline at end of file diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua deleted file mode 100644 index 497a0df..0000000 --- a/lua/plugins/mini.lua +++ /dev/null @@ -1,104 +0,0 @@ -return { - { - 'echasnovski/mini.nvim', - event = 'VeryLazy', - -- event = { "BufReadPost", "BufAdd", "BufNewFile" }, - version = false, - config = function() - require('mini.comment').setup({}) - require('mini.ai').setup({}) - require('mini.cursorword').setup() - require('mini.bracketed').setup({ - file = { suffix = '' }, - window = { suffix = '' }, - quickfix = { suffix = '' }, - yank = { suffix = '' }, - treesitter = { suffix = 'n' }, - }) - local ai = require('mini.ai') - ai.setup({ - n_lines = 500, - custom_textobjects = { - s = ai.gen_spec.treesitter({ -- code block - a = { '@block.outer', '@conditional.outer', '@loop.outer' }, - i = { '@block.inner', '@conditional.inner', '@loop.inner' }, - }), - f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }), -- function - i = require('mini.extra').gen_ai_spec.indent(), - g = require('mini.extra').gen_ai_spec.buffer(), - }, - }) - require('mini.surround').setup({ - mappings = { - add = 'gsa', -- Add surrounding in Normal and Visual modes - delete = 'gsd', -- Delete surrounding - replace = 'gsr', -- Replace surrounding - find = 'gsf', -- Find surrounding (to the right) - find_left = 'gsF', -- Find surrounding (to the left) - highlight = 'gsh', -- Highlight surrounding - update_n_lines = 'gsn', -- Update `n_lines` - }, - keys = { - { 'gz', '', desc = '+surround' }, - }, - }) - require('mini.pairs').setup({ - -- odes = { command = true }, - -- mappings = { - -- ['<'] = { action = 'open', pair = '<>', neigh_pattern = '[^\\].' }, - -- ['>'] = { action = 'close', pair = '<>', neigh_pattern = '[^\\].' }, - -- }, - mappings = { - ['('] = { action = 'open', pair = '()', neigh_pattern = '[^\\][%s)}%]]' }, - ['['] = { action = 'open', pair = '[]', neigh_pattern = '[^\\][%s)}%]]' }, - ['{'] = { action = 'open', pair = '{}', neigh_pattern = '[^\\][%s)}%]]' }, - ['`'] = { neigh_pattern = '[^%a%d\\%-`][%s)}%]]' }, - ['"'] = { neigh_pattern = '[^%a%d\\%-"][%s)}%]]' }, - ["'"] = { neigh_pattern = "[^%a%d\\%-'][%s)}%]]" }, - }, - }) - require('mini.move').setup({ - keys = { - { '', mode = { 'n', 'v' } }, - { '', mode = { 'n', 'v' } }, - { '', mode = { 'n', 'v' } }, - { '', mode = { 'n', 'v' } }, - }, - - mappings = { - left = '', - line_left = '', - right = '', - line_right = '', - down = '', - line_down = '', - up = '', - line_up = '', - }, - }) - end, - }, - { - 'echasnovski/mini.files', - version = false, - keys = { - { '-', "lua require('mini.files').open(vim.api.nvim_buf_get_name(0))", { silent = true } }, - }, - }, - { - 'echasnovski/mini.icons', - opts = {}, - lazy = true, - specs = { - { 'nvim-tree/nvim-web-devicons', enabled = false, optional = true }, - }, - init = function() - package.preload['nvim-web-devicons'] = function() - -- needed since it will be false when loading and mini will fail - package.loaded['nvim-web-devicons'] = {} - require('mini.icons').mock_nvim_web_devicons() - return package.loaded['nvim-web-devicons'] - end - end, - }, -} diff --git a/lua/plugins/test.lua b/lua/plugins/test.lua deleted file mode 100644 index 310bfd3..0000000 --- a/lua/plugins/test.lua +++ /dev/null @@ -1,27 +0,0 @@ -return { - 'nvim-neotest/neotest', - dependencies = { - 'nvim-neotest/nvim-nio', - 'olimorris/neotest-rspec', - 'nvim-neotest/neotest-jest', - 'nvim-neotest/neotest-python', - }, - cmd = 'Neotest', - config = function() - require('neotest').setup({ - status = { virtual_text = true }, - output = { open_on_run = true }, - adapters = { - require('neotest-vitest'), - require('neotest-jest')({ - jestCommand = 'npm test --', - jestConfigFile = 'custom.jest.config.ts', - env = { CI = true }, - cwd = function(path) - return vim.fn.getcwd() - end, - }), - }, - }) - end, -} diff --git a/lua/plugins/tools/ccc.lua b/lua/plugins/tools/ccc.lua new file mode 100644 index 0000000..580a9d3 --- /dev/null +++ b/lua/plugins/tools/ccc.lua @@ -0,0 +1,10 @@ +vim.opt.termguicolors = true + +local ccc = require('ccc') + +ccc.setup({ + highlighter = { + auto_enable = true, + lsp = true, + }, +}) diff --git a/lua/plugins/tools/dbee.lua b/lua/plugins/tools/dbee.lua new file mode 100644 index 0000000..6b883e6 --- /dev/null +++ b/lua/plugins/tools/dbee.lua @@ -0,0 +1,19 @@ +local dbee = require('dbee') + +dbee.setup({ + sources = { + require('dbee.sources').EnvSource:new('NVIM_DB'), + -- require("dbee.sources").MemorySource:new({ + -- { + -- name = "dbname", + -- type = "postgres", + -- url = "postgres://pguser:pguser@localhost:5602/dbname?sslmode=disable" + -- }, + -- }), + -- require("dbee.sources").FileSource:new(vim.fn.stdpath("cache") .. "/dbee/config.json"), + }, +}) + +vim.api.nvim_create_user_command('DBToggle', function() + require('dbee').toggle() +end, {}) diff --git a/lua/plugins/configs/jump.lua b/lua/plugins/tools/flash.lua similarity index 100% rename from lua/plugins/configs/jump.lua rename to lua/plugins/tools/flash.lua diff --git a/lua/plugins/tools/gitlinker.lua b/lua/plugins/tools/gitlinker.lua new file mode 100644 index 0000000..a16dbcd --- /dev/null +++ b/lua/plugins/tools/gitlinker.lua @@ -0,0 +1,24 @@ +local gitlinker = require('gitlinker') + +gitlinker.setup({ + opts = { + remote = nil, + add_current_line_on_normal_mode = true, + action_callback = require('gitlinker.actions').copy_to_clipboard, + print_url = true, + }, + callbacks = { + ['github.com'] = require('gitlinker.hosts').get_github_type_url, + ['gitlab.com'] = require('gitlinker.hosts').get_gitlab_type_url, + ['try.gitea.io'] = require('gitlinker.hosts').get_gitea_type_url, + ['codeberg.org'] = require('gitlinker.hosts').get_gitea_type_url, + ['bitbucket.org'] = require('gitlinker.hosts').get_bitbucket_type_url, + ['try.gogs.io'] = require('gitlinker.hosts').get_gogs_type_url, + ['git.sr.ht'] = require('gitlinker.hosts').get_srht_type_url, + ['git.launchpad.net'] = require('gitlinker.hosts').get_launchpad_type_url, + ['repo.or.cz'] = require('gitlinker.hosts').get_repoorcz_type_url, + ['git.kernel.org'] = require('gitlinker.hosts').get_cgit_type_url, + ['git.savannah.gnu.org'] = require('gitlinker.hosts').get_cgit_type_url, + }, + mappings = 'yg', +}) diff --git a/lua/plugins/tools/gitsigns.lua b/lua/plugins/tools/gitsigns.lua new file mode 100644 index 0000000..ed9c4aa --- /dev/null +++ b/lua/plugins/tools/gitsigns.lua @@ -0,0 +1,63 @@ +local gitsigns = require('gitsigns') +local icons = require('lib.icons') + +gitsigns.setup({ + signs = { + add = { text = icons.ui.SeparatorLight }, + change = { text = icons.ui.SeparatorLight }, + delete = { text = icons.ui.SeparatorLight }, + topdelete = { text = icons.ui.Topline }, + changedelete = { text = icons.ui.SeparatorLight }, + untracked = { text = icons.ui.SeparatorDashed }, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + watch_gitdir = { interval = 1000, follow_files = true }, + attach_to_untracked = true, + current_line_blame = false, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = 'eol', + delay = 0, + ignore_whitespace = false, + }, + current_line_blame_formatter = ', - ', + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, + max_file_length = 40000, + preview_config = { border = 'rounded', style = 'minimal', relative = 'cursor', row = 0, col = 1 }, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + map('n', ']e', function() + if vim.wo.diff then + return ']e' + end + vim.schedule(function() + gs.next_hunk() + end) + return '' + end, { expr = true, desc = 'Next Change' }) + + map('n', '[e', function() + if vim.wo.diff then + return '[e' + end + vim.schedule(function() + gs.prev_hunk() + end) + return '' + end, { expr = true, desc = 'Prev Change' }) + + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk') + end, +}) diff --git a/lua/plugins/tools/marks.lua b/lua/plugins/tools/marks.lua new file mode 100644 index 0000000..04e3d3b --- /dev/null +++ b/lua/plugins/tools/marks.lua @@ -0,0 +1,37 @@ +local marks = require('marks') +local icons = require('lib.icons') + +marks.setup({ + default_mappings = true, + builtin_marks = { '.', '<', '>', '^' }, + cyclic = true, + force_write_shada = false, + sign_priority = { lower = 10, upper = 15, builtin = 8, bookmark = 20 }, + excluded_filetypes = {}, + excluded_buftypes = { 'nofile' }, + -- supports up to 10 bookmark groups + bookmark_1 = { + sign = icons.ui.Flag, + virt_text = 'flag', + annotate = false, + }, + bookmark_2 = { + sign = icons.ui.Eye, + virt_text = 'watch', + annotate = false, + }, + bookmark_3 = { + sign = icons.ui.Star, + virt_text = 'star', + annotate = false, + }, + bookmark_4 = { + sign = icons.ui.Bug, + virt_text = 'bug', + annotate = false, + }, + mappings = { + set = 'M', + toggle_mark = 'm', + }, +}) diff --git a/lua/plugins/tools/navigator.lua b/lua/plugins/tools/navigator.lua new file mode 100644 index 0000000..a16a9d7 --- /dev/null +++ b/lua/plugins/tools/navigator.lua @@ -0,0 +1,8 @@ +local navigator = require('Navigator') + +navigator.setup({ + auto_save = 'current', + disable_on_zoom = false, + mux = 'auto', +}) + diff --git a/lua/plugins/tools/nvim-tree.lua b/lua/plugins/tools/nvim-tree.lua new file mode 100644 index 0000000..37c086e --- /dev/null +++ b/lua/plugins/tools/nvim-tree.lua @@ -0,0 +1,107 @@ +local nvim_tree = require('nvim-tree') +local Snacks = require('snacks') + +local icons = require('lib.icons') + +local function on_attach(bufnr) + local api = require('nvim-tree.api') + + local function opts(desc) + return { + desc = 'nvim-tree: ' .. desc, + buffer = bufnr, + noremap = true, + silent = true, + nowait = true, + } + end + + api.config.mappings.default_on_attach(bufnr) + vim.keymap.set('n', 'Y', api.fs.copy.filename, opts('Copy Name')) + vim.keymap.set('n', 'y', api.fs.copy.relative_path, opts('Copy Relative Path')) + vim.keymap.set('n', 'l', api.node.open.edit, opts('Open')) + vim.keymap.set('n', '', api.node.open.edit, opts('Open')) + vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Close Directory')) + vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split')) + vim.keymap.set('n', 'o', api.node.open.horizontal, opts('Open: Horizontal Split')) +end + +local prev = { new_name = '', old_name = '' } -- Prevents duplicate events +vim.api.nvim_create_autocmd('User', { + pattern = 'NvimTreeSetup', + callback = function() + local events = require('nvim-tree.api').events + events.subscribe(events.Event.NodeRenamed, function(data) + if prev.new_name ~= data.new_name or prev.old_name ~= data.old_name then + data = data + Snacks.rename.on_rename_file(data.old_name, data.new_name) + end + end) + end, +}) + +nvim_tree.setup({ + on_attach = on_attach, + hijack_directories = { enable = true }, + update_cwd = true, + filters = {}, + renderer = { + add_trailing = false, + group_empty = false, + highlight_git = false, + highlight_opened_files = 'none', + root_folder_modifier = ':t', + indent_markers = { + enable = false, + icons = { corner = icons.ui.Corner, edge = icons.ui.Edge, none = icons.ui.Edge }, + }, + icons = { + webdev_colors = true, + git_placement = 'before', + padding = ' ', + symlink_arrow = icons.ui.Arrow, + show = { file = true, folder = true, folder_arrow = true, git = true }, + glyphs = { + default = icons.documents.File, + symlink = icons.documents.SymLink, + folder = { + arrow_open = icons.ui.ArrowOpen, + arrow_closed = icons.ui.ArrowClosed, + default = icons.documents.Folder, + open = icons.documents.OpenFolder, + empty = icons.documents.FolderEmpty, + empty_open = icons.documents.OpenFolderEmpty, + symlink = icons.documents.SymlinkFolder, + symlink_open = icons.documents.SymlinkFolder, + }, + git = { + unstaged = icons.git.Mod, + staged = icons.git.Add, + unmerged = icons.git.Diff, + renamed = icons.git.Rename, + untracked = icons.git.Untrack, + deleted = icons.git.Remove, + ignored = icons.git.Ignore, + }, + }, + }, + }, + diagnostics = { + enable = true, + icons = { + hint = icons.diagnostics.Hint, + info = icons.diagnostics.Information, + warning = icons.diagnostics.Warning, + error = icons.diagnostics.Error, + }, + }, + update_focused_file = { enable = true, update_cwd = true, ignore_list = {} }, + git = { enable = true, ignore = true, timeout = 500 }, + view = { + width = 50, + side = 'left', + adaptive_size = true, + number = true, + relativenumber = true, + }, +}) diff --git a/lua/plugins/configs/spectre.lua b/lua/plugins/tools/spectre.lua similarity index 100% rename from lua/plugins/configs/spectre.lua rename to lua/plugins/tools/spectre.lua diff --git a/lua/plugins/tools/spider.lua b/lua/plugins/tools/spider.lua new file mode 100644 index 0000000..5903072 --- /dev/null +++ b/lua/plugins/tools/spider.lua @@ -0,0 +1,10 @@ +local spider = require('spider') + +spider.setup({ + skipInsignificantPunctuation = true, +}) + +vim.keymap.set({ 'n', 'o', 'x' }, 'w', "lua require('spider').motion('w')", { desc = 'Spider-w' }) +vim.keymap.set({ 'n', 'o', 'x' }, 'e', "lua require('spider').motion('e')", { desc = 'Spider-e' }) +vim.keymap.set({ 'n', 'o', 'x' }, 'b', "lua require('spider').motion('b')", { desc = 'Spider-b' }) +vim.keymap.set({ 'n', 'o', 'x' }, 'ge', "lua require('spider').motion('ge')", { desc = 'Spider-ge' }) diff --git a/lua/plugins/tools/tabout.lua b/lua/plugins/tools/tabout.lua new file mode 100644 index 0000000..465c290 --- /dev/null +++ b/lua/plugins/tools/tabout.lua @@ -0,0 +1,22 @@ +local tabout = require('tabout') + +tabout.setup({ + tabkey = '', + backwards_tabkey = '', + act_as_tab = true, + act_as_shift_tab = true, + default_tab = '', + default_shift_tab = '', + enable_backwards = false, + completion = true, + tabouts = { + { open = "'", close = "'" }, + { open = '"', close = '"' }, + { open = '`', close = '`' }, + { open = '(', close = ')' }, + { open = '[', close = ']' }, + { open = '{', close = '}' }, + }, + ignore_beginning = true, + exclude = { 'markdown' }, +}) diff --git a/lua/plugins/tools/telescope-custom.lua b/lua/plugins/tools/telescope-custom.lua new file mode 100644 index 0000000..a934052 --- /dev/null +++ b/lua/plugins/tools/telescope-custom.lua @@ -0,0 +1,92 @@ +local M = {} + +M.flash = function(prompt_bufnr) + require('flash').jump({ + pattern = '^', + label = { after = { 0, 0 } }, + search = { + mode = 'search', + exclude = { + function(win) + return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= 'TelescopeResults' + end, + }, + }, + action = function(match) + local picker = require('telescope.actions.state').get_current_picker(prompt_bufnr) + picker:set_selection(match.pos[1] - 1) + end, + }) +end + +-- Select multiple files with tab and open them together +M.multi_open = function(prompt_bufnr) + local picker = require('telescope.actions.state').get_current_picker(prompt_bufnr) + local multi = picker:get_multi_selection() + if not vim.tbl_isempty(multi) then + require('telescope.actions').close(prompt_bufnr) + for _, j in pairs(multi) do + if j.path ~= nil then + if j.lnum ~= nil then + vim.cmd(string.format('%s +%s %s', 'edit', j.lnum, j.path)) + else + vim.cmd(string.format('%s %s', 'edit', j.path)) + end + end + end + else + require('telescope.actions').select_default(prompt_bufnr) + end +end + +-- Do glob search by adding 2 spaces before the pattern during live_grep +M.multi_grep = function(opts) + local conf = require('telescope.config').values + local finders = require('telescope.finders') + local make_entry = require('telescope.make_entry') + local pickers = require('telescope.pickers') + + opts = opts or {} + opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.loop.cwd() + opts.pattern = opts.pattern or '%s' + + local custom_grep = finders.new_async_job({ + command_generator = function(prompt) + if not prompt or prompt == '' then + return nil + end + local prompt_split = vim.split(prompt, ' ') + + local args = { 'rg' } + if prompt_split[1] then + table.insert(args, '-e') + table.insert(args, prompt_split[1]) + end + + if prompt_split[2] then + table.insert(args, '-g') + local pattern = prompt_split[2] + table.insert(args, string.format(opts.pattern, pattern)) + end + + return vim.tbl_flatten({ + args, + { '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case' }, + }) + end, + entry_maker = make_entry.gen_from_vimgrep(opts), + cwd = opts.cwd, + }) + + pickers + .new(opts, { + debounce = 100, + prompt_title = 'Multi Grep', + finder = custom_grep, + previewer = conf.grep_previewer(opts), + sorter = require('telescope.sorters').empty(), + }) + :find() +end + +return M diff --git a/lua/plugins/tools/telescope.lua b/lua/plugins/tools/telescope.lua new file mode 100644 index 0000000..45a6811 --- /dev/null +++ b/lua/plugins/tools/telescope.lua @@ -0,0 +1,159 @@ +local telescope = require('telescope') +local actions = require('telescope.actions') +local icons = require('lib.icons') +local flash = require('plugins.tools.telescope-custom').flash +local multi_open = require('plugins.tools.telescope-custom').multi_open + +telescope.setup({ + defaults = { + layout_config = { + height = 0.8, + width = 0.9, + prompt_position = 'top', + bottom_pane = { + height = 0.5, + preview_width = 0.6, + preview_cutoff = 120, + }, + center = { + height = 0.4, + preview_cutoff = 40, + }, + cursor = { + preview_cutoff = 40, + preview_width = 0.6, + }, + horizontal = { + preview_width = 0.6, + preview_cutoff = 120, + }, + vertical = { + preview_cutoff = 40, + }, + }, + prompt_prefix = icons.ui.Telescope .. icons.ui.ChevronRight, + selection_caret = icons.ui.Play, + multi_icon = icons.ui.Check, + path_display = { 'smart' }, + -- path_display = { filename_first = { reverse_directories = false } }, + sorting_strategy = 'ascending', + + mappings = { + i = { + [''] = actions.close, + [''] = actions.cycle_history_next, + [''] = actions.cycle_history_prev, + + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + + [''] = actions.close, + + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + + [''] = multi_open, + [''] = actions.select_horizontal, + [''] = actions.select_vertical, + [''] = actions.select_horizontal, + [''] = actions.select_vertical, + [''] = actions.select_tab, + [''] = flash, + + [''] = actions.preview_scrolling_up, + [''] = actions.preview_scrolling_down, + + [''] = actions.results_scrolling_up, + [''] = actions.results_scrolling_down, + + [''] = actions.toggle_selection + actions.move_selection_worse, + [''] = actions.toggle_selection + actions.move_selection_better, + [''] = actions.send_to_qflist + actions.open_qflist, + [''] = actions.send_selected_to_qflist + actions.open_qflist, + [''] = actions.complete_tag, + }, + + n = { + ['q'] = actions.close, + [''] = actions.close, + [''] = multi_open, + [''] = actions.select_horizontal, + [''] = actions.select_vertical, + [''] = actions.select_tab, + ['s'] = flash, + + [''] = actions.toggle_selection + actions.move_selection_worse, + [''] = actions.toggle_selection + actions.move_selection_better, + [''] = actions.send_to_qflist + actions.open_qflist, + [''] = actions.send_selected_to_qflist + actions.open_qflist, + + ['j'] = actions.move_selection_next, + ['k'] = actions.move_selection_previous, + ['H'] = actions.move_to_top, + ['M'] = actions.move_to_middle, + ['L'] = actions.move_to_bottom, + + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + ['gg'] = actions.move_to_top, + ['G'] = actions.move_to_bottom, + + [''] = actions.preview_scrolling_up, + [''] = actions.preview_scrolling_down, + + [''] = actions.results_scrolling_up, + [''] = actions.results_scrolling_down, + + ['?'] = actions.which_key, + }, + }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', + }, + file_browser = { + theme = 'ivy', + hijack_netrw = true, + mappings = { + ['i'] = { + -- your custom insert mode mappings + }, + ['n'] = { + -- your custom normal mode mappings + }, + }, + }, + undo = { + use_delta = true, + use_custom_command = nil, + side_by_side = true, + vim_diff_opts = { + ctxlen = vim.o.scrolloff * 2, + }, + entry_format = 'state #$ID, $STAT, $TIME', + -- time_format = '%d %b %H:%M', + saved_only = false, + layout_strategy = 'vertical', + layout_config = { + preview_height = 0.7, + }, + mappings = { + i = { + [''] = require('telescope-undo.actions').yank_additions, + [''] = require('telescope-undo.actions').yank_deletions, + [''] = require('telescope-undo.actions').restore, + }, + }, + }, + }, +}) + +telescope.load_extension('fzf') +telescope.load_extension('undo') +telescope.load_extension('marks_nvim') +telescope.load_extension('refactoring') +telescope.load_extension('file_browser') diff --git a/lua/plugins/configs/toggleterm.lua b/lua/plugins/tools/toggleterm.lua similarity index 100% rename from lua/plugins/configs/toggleterm.lua rename to lua/plugins/tools/toggleterm.lua diff --git a/lua/plugins/configs/whichkey.lua b/lua/plugins/tools/which-key.lua similarity index 60% rename from lua/plugins/configs/whichkey.lua rename to lua/plugins/tools/which-key.lua index 2d57190..607d90f 100644 --- a/lua/plugins/configs/whichkey.lua +++ b/lua/plugins/tools/which-key.lua @@ -37,8 +37,21 @@ local setup = { }, } -local n_mappings = { +local normal_mappings = { mode = 'n', + { 'a', group = ' AI' }, + { 'aF', 'CopilotChatFixDiagnostic', desc = 'Fix Diagnostic' }, + { 'aG', 'CopilotChatCommitStaged', desc = 'Commit Staged' }, + { 'ac', 'CopilotChatToggle', desc = 'Copilot Chat' }, + { 'ad', 'CopilotChatDocs', desc = 'Docs' }, + { 'ae', 'CopilotChatExplain', desc = 'Explain' }, + { 'af', 'CopilotChatFix', desc = 'Fix' }, + { 'ag', 'CopilotChatCommit', desc = 'Commit' }, + { 'al', 'CopilotChatLoad', desc = 'Load Chat' }, + { 'ao', 'CopilotChatOptimize', desc = 'Optimize' }, + { 'ar', 'CopilotChatReview', desc = 'Review' }, + { 'as', 'CopilotChatSave', desc = 'Save Chat' }, + { 'at', 'CopilotChatTests', desc = 'Tests' }, { 'b', group = ' Debug' }, { 'bO', 'DapStepOut', desc = 'Out' }, @@ -53,20 +66,21 @@ local n_mappings = { { 'bx', 'DapTerminate', desc = 'Exit' }, { 'c', group = ' Code' }, - { 'a', 'Alternate', desc = 'Toggle Alternate' }, { 'cF', 'retab', desc = 'Fix Tabs' }, { 'cP', 'CccConvert', desc = 'Convert Color' }, { 'cR', 'ReloadConfig', desc = 'Reload Configs' }, { 'cc', 'CccHighlighterToggle', desc = 'Highlight Colors' }, { 'cd', 'RootDir', desc = 'Root Directory' }, - { 'ce', ':g/^\\s*$/d', desc = 'Clean Empty Lines' }, - { 'cf', group = 'Formate File' }, + { 'ce', '%SnipRun', desc = 'Execute File' }, + { 'cf', 'lua vim.lsp.buf.format({async = true})', desc = 'Format File' }, { 'ch', 'Hardtime toggle', desc = 'Hardtime' }, + { 'cl', ':g/^\\s*$/d', desc = 'Clean Empty Lines' }, { 'cm', 'MarkdownPreviewToggle', desc = 'Markdown Preview' }, - { 'cn', 'Telescope notify', desc = 'Notifications' }, + { 'cn', 'lua require("snacks").notifier.show_history()', desc = 'Notifications' }, { 'co', 'Dashboard', desc = 'Dashboard' }, { 'cp', 'CccPick', desc = 'Pick Color' }, { 'cr', 'Telescope reloader', desc = 'Reload Module' }, + { 'cs', 'source %', desc = 'Source File' }, { 'C', group = ' Comment' }, { 'Cb', 'CBccbox', desc = 'Comment Box' }, @@ -77,47 +91,98 @@ local n_mappings = { { 'Cd', 'CBd', desc = 'Delete Comment Style' }, { 'd', group = ' Database' }, - { 'du', 'DBUIToggle', desc = 'Toggle DB UI' }, - { 'db', 'DBUIFindBuffer', desc = 'DB Find buffer' }, - { 'dr', 'DBUIRenameBuffer', desc = 'DB Rename buffer' }, - { 'dl', 'DBUILastQueryInfo', desc = 'DB Last query' }, + { 'dS', 'lua require("dbee").store("json", "buffer", { extra_arg = 0 })', desc = 'To JSON' }, + { 'db', 'DBToggle', desc = 'DB Explorer' }, + { 'dj', 'lua require("dbee").next()', desc = 'DB Next' }, + { 'dk', 'lua require("dbee").prev()', desc = 'DB Prev' }, + { 'ds', 'lua require("dbee").store("csv", "buffer", { extra_arg = 0 })', desc = 'To CSV' }, + { 'dt', 'lua require("dbee").store("table", "buffer", { extra_arg = 0 })', desc = 'To Table' }, { 'e', group = ' Edit' }, { 'ea', 'b#', desc = 'Alternate File' }, - { 'ec', 'e $MYVIMRC', desc = 'Config' }, + + { 'ec', group = 'Edit Configs' }, + { 'eca', 'e ~/dotfiles/zsh/aliases.zsh', desc = 'Shell Aliases' }, { - 'eC', + 'ecc', 'lua require("telescope.builtin").find_files({cwd = vim.fn.stdpath("config")})', - desc = 'Config Dir', + desc = 'Neovim Configs', }, + { + 'ecd', + 'lua require("telescope.builtin").find_files({cwd = vim.fn.expand("$DOTS_DIR")})', + desc = 'Dotfiles', + }, + { 'ecg', 'e ~/.gitconfig', desc = 'Git Config' }, + { 'eck', 'e ~/.config/kitty/kitty.conf', desc = 'Kitty Config' }, + { 'ecn', 'e $MYVIMRC', desc = 'Neovim Init' }, + { 'ecp', 'e ~/dotfiles/nvim/lua/plugins/list.lua', desc = 'Plugin List' }, + { 'ect', 'e ~/dotfiles/tmux/tmux.conf', desc = 'Tmux Config' }, + { 'ee', ':Neotree toggle float', silent = true, desc = 'Float File Explorer' }, { 'eE', ':Neotree toggle left', silent = true, desc = 'Left File Explorer' }, { 'ef', 'Telescope file_browser', desc = 'File Browser' }, + { 'eF', 'gf', desc = 'File Under Cursor' }, { 'em', 'e README.md', desc = 'Readme' }, - { 'en', 'new', desc = 'New File' }, - { 'ex', '!chmod +x %', desc = 'Make Current File Executable' }, - { 'es', 'w', desc = 'Save File' }, - { 'ed', '!rm %', desc = 'Delete File' }, - { 'eD', '!rm %bdelete', desc = 'Delete File and Buffer' }, + { 'en', 'enew', desc = 'New File' }, { 'f', group = ' Find' }, - { 'ff', 'Telescope find_files', desc = 'Find Files (CWD)' }, - { 'fg', 'Telescope live_grep', desc = 'Live Grep' }, - { 'fb', 'Telescope buffers', desc = 'Buffers' }, - { 'fh', 'Telescope help_tags', desc = 'Find Help' }, - { 'fo', 'Telescope oldfiles', desc = 'Old Recent Files' }, - { 'fm', 'Telescope marks', desc = 'Marks' }, - { 'fH', 'Telescope highlights', desc = 'Find Highlight Groups' }, - { 'fG', 'Telescope grep_string', desc = 'Grep String' }, - { 'kk', 'Telescope keymaps', desc = 'Keymaps' }, - { 'kc', 'Telescope commands', desc = 'Commands' }, - { 'kh', 'Telescope command_history', desc = 'Command History' }, - { 'ks', 'Telescope search_history', desc = 'Search History' }, - { 'fd', 'Telescope diagnostics', desc = 'Diagnostics' }, - { 'fu', 'Telescope undo', desc = 'Undo History' }, - { 'fb', 'Telescope buffers', desc = 'Buffers' }, + { 'fa', 'Telescope find_files', desc = 'All Files' }, + { 'fc', 'Telescope git_bcommits', desc = 'File Commits' }, + { 'ff', 'Telescope git_files', desc = 'Find files' }, + { + 'fg', + 'lua require("plugins.tools.telescope-custom").multi_grep()', + desc = 'Find Text', + }, + { 'fj', 'Telescope buffers', desc = 'Buffers' }, + { 'fl', 'Telescope loclist', desc = 'Location List' }, + { 'fm', 'Telescope git_status', desc = 'Modified files' }, + { 'fo', 'Telescope live_grep grep_open_files=true', desc = 'Find in Open Files' }, + { 'fp', 'Telescope resume', desc = 'Last Search' }, + { + 'fP', + 'lua require("telescope.builtin").find_files({cwd = vim.fs.joinpath(vim.fn.stdpath("data"), "lazy")})', + desc = 'Plugin Files', + }, { 'fq', 'Telescope quickfix', desc = 'Quickfix' }, + { 'fr', 'Telescope oldfiles', desc = 'Recent Files' }, { 'fs', 'Telescope current_buffer_fuzzy_find', desc = 'Fuzzy Find in File' }, + { 'ft', 'Telescope', desc = 'Panel' }, + { 'fu', 'Telescope undo', desc = 'Undo History' }, + { 'fw', 'Telescope grep_string', desc = 'Find Word' }, + + { 'g', group = ' Git' }, + { 'gA', 'Gitsigns stage_buffer', desc = 'Stage Buffer' }, + { 'gP', 'Git push', desc = 'Push' }, + { 'gR', 'Gitsigns reset_buffer', desc = 'Reset Buffer' }, + { 'gS', 'Telescope git_stash', desc = 'Stashed Changes' }, + { 'ga', 'Gitsigns stage_hunk', desc = 'Stage Hunk' }, + { 'gb', "lua require('gitsigns').blame_line({full = true})", desc = 'Blame' }, + { 'gB', "lua require('snacks').git.blame_line()", desc = 'Detailed Blame' }, + { 'gc', 'Telescope git_commits', desc = 'Find Commits' }, + { 'gd', 'Gitsigns diffthis HEAD', desc = 'Diff' }, + { 'gf', 'Git', desc = 'Fugitive Panel' }, + { 'gg', 'lua require("snacks").lazygit()', desc = 'Lazygit' }, + { 'gi', 'Gitsigns preview_hunk', desc = 'Hunk Info' }, + { 'gj', 'Gitsigns next_hunk', desc = 'Next Hunk' }, + { 'gk', 'Gitsigns prev_hunk', desc = 'Prev Hunk' }, + { 'gl', 'lua require("snacks").lazygit.log()', desc = 'Lazygit Log' }, + { 'gL', 'Git log', desc = 'Log' }, + { 'go', group = 'Octohub' }, + { 'gp', 'Git pull', desc = 'Pull' }, + { 'gr', 'Gitsigns reset_hunk', desc = 'Reset Hunk' }, + { 'gs', 'Telescope git_branches', desc = 'Switch Branch' }, + { 'gt', group = 'Toggle' }, + { 'gtb', 'Gitsigns toggle_current_line_blame', desc = 'Blame' }, + { 'gtd', 'Gitsigns toggle_deleted', desc = 'Deleted' }, + { 'gtl', 'Gitsigns toggle_linehl', desc = 'Line HL' }, + { 'gtn', 'Gitsigns toggle_numhl', desc = 'Number HL' }, + { 'gts', 'Gitsigns toggle_signs', desc = 'Signs' }, + { 'gtw', 'Gitsigns toggle_word_diff', desc = 'Word Diff' }, + { 'gu', 'Gitsigns undo_stage_hunk', desc = 'Undo Stage Hunk' }, + { 'gv', 'Gitsigns select_hunk', desc = 'Select Hunk' }, + { 'gw', 'lua require("snacks").gitbrowse()', desc = 'Git Browse' }, { 'h', group = ' Help' }, { 'hh', 'Telescope help_tags', desc = 'Help Pages' }, @@ -128,7 +193,6 @@ local n_mappings = { { 'i', group = ' Insert' }, { 'iP', 'put %:p', desc = 'Absolute Path' }, { 'id', "put =strftime('## %a, %d %b, %Y, %r')", desc = 'Date' }, - { 'ie', 'Telescope symbols', desc = 'Emojis' }, { 'if', "put =expand('%:t')", desc = 'File Name' }, { 'in', 'Nerdy', desc = 'Nerd Glyphs' }, { 'ip', 'put %', desc = 'Relative Path' }, @@ -167,7 +231,6 @@ local n_mappings = { { 'kh', 'Telescope command_history', desc = 'Command History' }, { 'kk', 'Telescope keymaps', desc = 'Keymaps' }, { 'ks', 'Telescope search_history', desc = 'Search History' }, - { 'kt', 'Screenkey', desc = 'Toggle keys' }, { 'l', group = ' LSP' }, { 'lF', 'Telescope lsp_references layout_strategy=vertical', desc = 'References' }, @@ -193,28 +256,37 @@ local n_mappings = { { 'ls', 'Telescope lsp_document_symbols theme=get_ivy', desc = 'Document Symbols' }, { 'lt', 'Lspsaga peek_type_definition', desc = 'Peek Type Definition' }, - { 'm', group = ' Misc' }, + { 'm', group = ' Marks' }, + { 'm1', "lua require('marks').toggle_bookmark1()", desc = 'Toggle Bookmark 0' }, + { 'm2', "lua require('marks').toggle_bookmark2()", desc = 'Toggle Bookmark 2' }, + { 'm3', "lua require('marks').toggle_bookmark3()", desc = 'Toggle Bookmark 3' }, + { 'm4', "lua require('marks').toggle_bookmark4()", desc = 'Toggle Bookmark 4' }, + { 'mD', "lua require('marks').delete_buf()", desc = 'Delete Buffer' }, + { 'mP', "lua require('marks').preview()", desc = 'Preview' }, { - 'ms', - function() - require('persistence').load() - end, - desc = 'Restore Session', - }, - { - 'ml', - function() - require('persistence').load({ last = true }) - end, - desc = 'Restore Last Session', - }, - { - 'md', - function() - require('persistence').stop() - end, - desc = "Don't Save Current Session", + 'mb', + "lua require('telescope').extensions.marks_nvim.bookmarks_list_all()", + desc = 'Bookmarks', }, + { 'md', "lua require('marks').delete_line()", desc = 'Delete Line' }, + { 'mh', "lua require('marks').next_bookmark()", desc = 'Next Bookmark' }, + { 'mj', "lua require('marks').next()", desc = 'Next' }, + { 'mk', "lua require('marks').prev()", desc = 'Previous' }, + { 'ml', "lua require('marks').prev_bookmark()", desc = 'Previous Bookmark' }, + { 'mm', 'Telescope marks', desc = 'All Marks' }, + { 'mn', group = 'Next Bookmark Group' }, + { 'mn1', "lua require('marks').next_bookmark1()", desc = 'Next Bookmark 1' }, + { 'mn2', "lua require('marks').next_bookmark2()", desc = 'Next Bookmark 2' }, + { 'mn3', "lua require('marks').next_bookmark3()", desc = 'Next Bookmark 3' }, + { 'mn4', "lua require('marks').next_bookmark4()", desc = 'Next Bookmark 4' }, + { 'mp', group = 'Previous Bookmark Group' }, + { 'mp1', "lua require('marks').prev_bookmark1()", desc = 'Previous Bookmark 1' }, + { 'mp2', "lua require('marks').prev_bookmark2()", desc = 'Previous Bookmark 2' }, + { 'mp3', "lua require('marks').prev_bookmark3()", desc = 'Previous Bookmark 3' }, + { 'mp4', "lua require('marks').prev_bookmark4()", desc = 'Previous Bookmark 4' }, + { 'ms', "lua require('marks').set_next()", desc = 'Set Next' }, + { 'mt', "lua require('marks').toggle()", desc = 'Toggle' }, + { 'mx', "lua require('marks').delete_bookmark()", desc = 'Delete Bookmark' }, { 'o', group = ' Options' }, { 'oc', 'Telescope colorscheme', desc = 'Colorscheme' }, @@ -222,21 +294,26 @@ local n_mappings = { { 'on', 'set relativenumber!', desc = 'Relative Numbers' }, { 'oo', 'Telescope vim_options', desc = 'All Options' }, - { 'p', group = ' ScreenShot' }, - { 'py', 'CodeSnap', mode = 'x', desc = 'Save selected code snapshot into clipboard' }, - { 'ps', 'CodeSnapSave', mode = 'x', desc = 'Save selected code snapshot in ~/Pictures' }, - { - 'h', - 'CodeSnapHighlight', - mode = 'x', - desc = 'Highlight and snapshot selected code into clipboard', - }, - { 'pi', 'CodeSnapASCII', mode = 'x', desc = 'Save ASCII code snapshot into clipboard' }, + { 'p', group = ' Packages' }, + { 'pc', 'Lazy check', desc = 'Check' }, + { 'pd', 'Lazy debug', desc = 'Debug' }, + { 'pe', 'lua require("snacks").profiler.scratch()', desc = 'Profiler Scratch' }, + { 'pf', 'lua require("snacks").profiler.pick()', desc = 'Profiler Pick' }, + { 'pi', 'Lazy install', desc = 'Install' }, + { 'pl', 'Lazy log', desc = 'Log' }, + { 'pm', 'Mason', desc = 'Mason' }, + { 'pp', 'Lazy', desc = 'Plugins' }, + { 'pP', 'Lazy profile', desc = 'Profile' }, + { 'pr', 'Lazy restore', desc = 'Restore' }, + { 'ps', 'Lazy sync', desc = 'Sync' }, + { 'pt', 'lua require("snacks").profiler.toggle()', desc = 'Profiler Toggle' }, + { 'pu', 'Lazy update', desc = 'Update' }, + { 'px', 'Lazy clean', desc = 'Clean' }, { 'q', group = ' Quit' }, { 'qa', 'qall', desc = 'Quit All' }, { 'qc', 'bw', desc = 'Close Buffer' }, - { 'qd', 'bdelete', desc = 'Delete Buffer' }, + { 'qd', 'lua require("snacks").bufdelete()', desc = 'Delete Buffer' }, { 'qf', 'qall!', desc = 'Force Quit' }, { 'qo', ':%bdelete|b#|bdelete#', desc = 'Close Others' }, { 'qq', 'q', desc = 'Quit' }, @@ -244,30 +321,6 @@ local n_mappings = { { 'qw', 'wq', desc = 'Write and Quit' }, { 'r', group = ' Refactor' }, - { - 'rc', - function() - local file_name = vim.api.nvim_buf_get_name(0) - local file_type = vim.bo.filetype - - if file_type == 'c' then - vim.cmd(':terminal gcc ' .. file_name .. '; ./a.out ') - elseif file_type == 'python' then - vim.cmd(':terminal python ' .. file_name) - elseif file_type == 'java' then - vim.cmd(':terminal javac ' .. file_name .. '; java ' .. file_name) - elseif file_type == 'lua' then - vim.cmd(':terminal lua ' .. file_name) - -- elseif file_type == 'js' then - -- vim.cmd(':terminal node ' .. file_name) - -- elseif file_type == 'rust' then - -- vim.cmd(':terminal rustc ' .. file_name .. '; ./a.out ') - -- elseif file_type == 'ts' then - -- vim.cmd(':terminal tsc ' .. file_name .. '; node ' .. file_name) - end - end, - desc = 'Code Runner', - }, { 'rR', "lua require('telescope').extensions.refactoring.refactors()", @@ -327,15 +380,8 @@ local n_mappings = { { 'u', group = ' Test' }, { 'uc', 'lua require("neotest").run.run()', desc = 'Run Current Test' }, { 'uf', 'lua require("neotest").run.run(vim.fn.expand("%"))', desc = 'Run Test File' }, - { - 'uo', - 'lua require("neotest").output.open({ enter = true, auto_close = true })', - desc = 'Show Output', - }, - { 'uS', 'lua require("neotest").summary.toggle', desc = 'Toggle Summary' }, - { 'ur', 'lua require("neotest").run.run()', desc = 'Run Nearest Test' }, - { 'us', 'lua require("neotest").run.stop()', desc = 'Stop' }, - { 'uO', 'lua require("neotest").output_panel.toggle', desc = 'Toggle Output Panel' }, + { 'uo', 'Neotest output-panel', desc = 'Test Output' }, + { 'us', 'Neotest summary', desc = 'Test Summary' }, { 'v', group = ' Select' }, { 'vB', 'vab', desc = 'Around Bracket' }, @@ -347,50 +393,60 @@ local n_mappings = { { 'w', group = ' Writing' }, { 'wc', 'set spell!', desc = 'Spellcheck' }, - { 'wF', ':SudaWrite', desc = 'Suda Write' }, + { 'wd', 'lua require("snacks").dim.enable()', desc = 'Dim On' }, + { 'wD', 'lua require("snacks").dim.disable()', desc = 'Dim Off' }, { 'wf', "lua require'utils'.sudo_write()", desc = 'Force Write' }, { 'wj', ']s', desc = 'Next Misspell' }, { 'wk', '[s', desc = 'Prev Misspell' }, + { 'wn', 'WriteNoFormat', desc = 'Write Without Formatting' }, { 'wq', 'wq', desc = 'Write and Quit' }, + { 'wr', '%d+', desc = 'Remove All Text' }, { 'ws', 'Telescope spell_suggest', desc = 'Suggestions' }, - { 'wt', 'Twilight', desc = 'Twilight' }, { 'ww', 'w', desc = 'Write and Quit' }, - { 'wz', 'ZenMode', desc = 'ZenMode' }, + { 'wz', 'lua require("snacks").zen.zen()', desc = 'Zen' }, + { 'wZ', 'lua require("snacks").zen.zoom()', desc = 'Zoom' }, { 'x', 'x', desc = ' Save and Quit' }, - { 'x', group = '󰁨 Diagnostics/Quickfix' }, - { 'xx', 'Trouble diagnostics toggle', desc = 'Diagnostics (Trouble)' }, - { 'xX', 'Trouble diagnostics toggle filter.buf=0', desc = 'Buffer Diagnostics (Trouble)' }, - { 'xs', 'Trouble symbols toggle', desc = 'Symbols (Trouble)' }, - { 'xS', 'Trouble lsp toggle', desc = 'LSP references/definitions/... (Trouble)' }, - { 'xL', 'Trouble loclist toggle', desc = 'Location List (Trouble)' }, - { 'xQ', 'Trouble qflist toggle', desc = 'Quickfix List (Trouble)' }, - { 'y', group = ' Yank' }, - { - 'yp', - function() - require('telescope').extensions.yank_history.yank_history({}) - end, - desc = 'Open Yank History', - }, - + { 'yL', 'CopyAbsolutePathWithLine', desc = 'Absolute Path with Line' }, { 'yP', 'CopyAbsolutePath', desc = 'Absolute Path' }, { 'ya', '%y+', desc = 'Copy Whole File' }, { 'yf', 'CopyFileName', desc = 'File Name' }, { 'yg', 'lua require"gitlinker".get_buf_range_url()', desc = 'Copy Git URL' }, + { 'yl', 'CopyRelativePathWithLine', desc = 'Relative Path with Line' }, { 'yp', 'CopyRelativePath', desc = 'Relative Path' }, } -local v_mappings = { +-- Jump to file mappings +for i = 1, 9 do + table.insert(normal_mappings, { + string.format('f%d', i), + string.format('LualineBuffersJump%d', i), + desc = string.format('File %d', i), + }) +end + +local visual_mappings = { mode = 'v', + { 'a', group = ' AI' }, + { 'aF', 'CopilotChatFixDiagnostic', desc = 'Fix Diagnostic' }, + { 'aG', 'CopilotChatCommitStaged', desc = 'Commit Staged' }, + { 'ac', 'CopilotChatToggle', desc = 'Copilot Chat' }, + { 'ad', 'CopilotChatDocs', desc = 'Docs' }, + { 'ae', 'CopilotChatExplain', desc = 'Explain' }, + { 'af', 'CopilotChatFix', desc = 'Fix' }, + { 'ag', 'CopilotChatCommit', desc = 'Commit' }, + { 'ao', 'CopilotChatOptimize', desc = 'Optimize' }, + { 'ar', 'CopilotChatReview', desc = 'Review' }, + { 'at', 'CopilotChatTests', desc = 'Tests' }, { 'c', group = ' Code' }, + { 'ce', "'<,'>SnipRun", desc = 'Execute Selection' }, { 'cS', ':sort!', desc = 'Sort Desc' }, { 'ci', ':sort i', desc = 'Sort Case Insensitive' }, { 'cs', ':sort', desc = 'Sort Asc' }, { 'cu', ':!uniq', desc = 'Unique' }, - { 'cx', "'<,'>SnipRun", desc = 'Run Code' }, + { 'cx', ':lua', desc = 'Execute Lua' }, { 'C', group = ' Comment' }, { 'Cb', 'CBccbox', desc = 'Comment Box' }, @@ -400,6 +456,11 @@ local v_mappings = { { 'Cc', 'CBcatalog', desc = 'Catalog' }, { 'Cd', 'CBd', desc = 'Delete Comment Style' }, + { 'g', group = ' Git' }, + { 'ga', ":'<,'>Gitsigns stage_hunk", desc = 'Stage Hunk' }, + { 'gr', ":'<,'>Gitsigns reset_hunk", desc = 'Reset Hunk' }, + { 'gu', ":'<,'>Gitsigns undo_stage_hunk", desc = 'Undo Stage Hunk' }, + { 'j', group = ' Jump' }, { 'jN', @@ -426,6 +487,17 @@ local v_mappings = { { 'l', group = ' LSP' }, { 'la', desc = 'Lspsaga range_code_action' }, + { 'p', group = ' ScreenShot' }, + { 'py', 'CodeSnap', mode = 'x', desc = 'Save selected code snapshot into clipboard' }, + { 'ps', 'CodeSnapSave', mode = 'x', desc = 'Save selected code snapshot in ~/Pictures' }, + { + 'ph', + 'CodeSnapHighlight', + mode = 'x', + desc = 'Highlight and snapshot selected code into clipboard', + }, + { 'pi', 'CodeSnapASCII', mode = 'x', desc = 'Save ASCII code snapshot into clipboard' }, + { 'r', group = ' Refactor' }, { 're', @@ -458,7 +530,7 @@ local no_leader_mappings = { { '', 'resize -10', desc = 'Decrease window height' }, { '', 'vertical resize -10', desc = 'Decrease window width' }, { '', 'vertical resize +10', desc = 'Increase window width' }, - { '', 'resize +10which_key.add(no_leader_mappings)', desc = 'Increase window height' }, + { '', 'resize +10', desc = 'Increase window height' }, { '', 'Telescope find_files', desc = 'Find Files' }, { '', 'Fterm lazygit', desc = 'Lazygit' }, @@ -470,8 +542,6 @@ local no_leader_mappings = { { '', 'bprevious', desc = 'Previous Buffer' }, { '', 'bnext', desc = 'Next Buffer' }, - { '', 'bprevious', desc = 'Previous Buffer' }, - { '', 'bnext', desc = 'Next Buffer' }, { 'K', 'Lspsaga hover_doc', desc = 'LSP Hover' }, { 'Q', 'qall!', desc = 'Force Quit!' }, @@ -481,69 +551,32 @@ local no_leader_mappings = { { '[B', 'bfirst', desc = 'First Buffer' }, { '[b', 'bprevious', desc = 'Buffer' }, { '[d', 'Lspsaga diagnostic_jump_prev', desc = 'Diagnostic' }, - { '[e', 'g;', desc = 'Edit' }, { '[g', 'Gitsigns prev_hunk', desc = 'Git Hunk' }, { '[j', '', desc = 'Jump' }, + { '[q', 'cprev', desc = 'Quickfix' }, { ']', group = ' Next' }, { ']B', 'blast', desc = 'Buffer' }, { ']b', 'bnext', desc = 'Buffer' }, { ']d', 'Lspsaga diagnostic_jump_next', desc = 'Diagnostic' }, - { ']e', 'g,', desc = 'Edit' }, { ']g', 'Gitsigns next_hunk', desc = 'Git Hunk' }, { ']j', '', desc = 'Jump' }, + { ']q', 'cnext', desc = 'Quickfix' }, +} - { '', '(YankyCycleForward)' }, - { '', '(YankyCycleBackward)' }, - { 'y', '(YankyYank)', mode = { 'n', 'x' }, desc = 'Yank text' }, - { 'p', '(YankyPutAfter)', mode = { 'n', 'x' }, desc = 'Put yanked text after cursor' }, - { 'P', '(YankyPutBefore)', mode = { 'n', 'x' }, desc = 'Put yanked text before cursor' }, - { 'gp', '(YankyGPutAfter)', mode = { 'n', 'x' }, desc = 'Put yanked text after selection' }, - { 'gP', '(YankyGPutBefore)', mode = { 'n', 'x' }, desc = 'Put yanked text before selection' }, - - { - '', - ':call vm#commands#add_cursor_down(0, v:count1)', - desc = 'Add Cursor Down', - mode = { 'n' }, - noremap = true, - silent = true, - }, - { - '', - ':call vm#commands#add_cursor_up(0, v:count1)', - desc = 'Add Cursor Up', - mode = { 'n' }, - noremap = true, - silent = true, - }, - { - '', - ':call vm#commands#add_cursor_down(0, v:count1)', - desc = 'Add Cursor Down', - mode = { 'n' }, - noremap = true, - silent = true, - }, - { - '', - ':call vm#commands#add_cursor_up(0, v:count1)', - desc = 'Add Cursor Down', - mode = { 'n' }, - noremap = true, - silent = true, - }, - { - '', - ':call vm#commands#ctrln(v:count1)', - desc = 'Multi Edit Next', - mode = { 'n' }, - noremap = true, - silent = true, - }, +local tmux_mappings = { + { '', 'NavigatorLeft', desc = 'Move Left' }, + { '', 'NavigatorDown', desc = 'Move Down' }, + { '', 'NavigatorUp', desc = 'Move Up' }, + { '', 'NavigatorRight', desc = 'Move Right' }, + { '', 'NavigatorPrevious', desc = 'Previous Pane' }, } which_key.setup(setup) -which_key.add(n_mappings) -which_key.add(v_mappings) +which_key.add(normal_mappings) +which_key.add(visual_mappings) which_key.add(no_leader_mappings) + +if vim.fn.exists('$TMUX') == 1 then + which_key.add(tmux_mappings) +end diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua deleted file mode 100644 index 8b6ab50..0000000 --- a/lua/plugins/treesitter.lua +++ /dev/null @@ -1,129 +0,0 @@ -return { - -- Syntax highlightings - { - 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - event = 'VeryLazy', - cmd = { 'TSInstall', 'TSBufEnable', 'TSBufDisable', 'TSModuleInfo' }, - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - { 'windwp/nvim-ts-autotag', ft = { 'html', 'xml', 'tsx' }, opts = {} }, - }, - config = function() - require('nvim-ts-autotag').setup() - require('nvim-treesitter.configs').setup({ - indent = { - enable = true, - disable = { 'ruby' }, - }, - ensure_installed = { - 'vim', - 'vimdoc', - 'markdown', - 'markdown_inline', - 'bash', - 'c', - 'java', - 'javascript', - 'typescript', - 'tsx', - 'json', - 'html', - 'css', - 'scss', - 'lua', - 'luadoc', - 'diff', - 'gitcommit', - 'python', - 'liquid', - }, - auto_install = true, - highlight = { - enable = true, - disable = function(_, buf) - local line_count = vim.api.nvim_buf_line_count(buf) - local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) - - -- vim.notify('stats: ' .. vim.inspect(stats)) - - -- if file is at least 10k and the average bytes per line is > 250, then disable treesitter - if ok and stats and (stats.size > (10 * 1024)) and (stats.size / line_count) > 250 then - vim.notify( - 'Disabling treesitter, bytes: ' - .. stats.size - .. ', lines: ' - .. line_count - .. ', bytes / lines: ' - .. math.floor(stats.size / line_count) - ) - return true - end - return false - end, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = false, - node_decremental = '', - }, - }, - playground = { - enable = true, - disable = {}, - }, - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ['af'] = { query = '@function.outer', desc = 'Select outer part of a function region' }, - ['if'] = { query = '@function.inner', desc = 'Select inner part of a function region' }, - ['ac'] = { query = '@class.outer', desc = 'Select outer part of a class region' }, - ['ic'] = { query = '@class.inner', desc = 'Select inner part of a class region' }, - }, - }, - move = { - enable = true, - -- don't include classes to not conflict with conflicts in a diff - -- (LazyVim has some clever code but i don't think we need it right now) - -- goto_next_start = { [']f'] = '@function.outer', [']c'] = '@class.outer', [']a'] = '@parameter.inner' }, - -- goto_next_end = { [']F'] = '@function.outer', [']C'] = '@class.outer', [']A'] = '@parameter.inner' }, - -- goto_previous_start = { ['[f'] = '@function.outer', ['[c'] = '@class.outer', ['[a'] = '@parameter.inner' }, - -- goto_previous_end = { ['[F'] = '@function.outer', ['[C'] = '@class.outer', ['[A'] = '@parameter.inner' }, - goto_next_start = { [']f'] = '@function.outer', [']a'] = '@parameter.inner' }, - goto_next_end = { [']F'] = '@function.outer', [']A'] = '@parameter.inner' }, - goto_previous_start = { ['[f'] = '@function.outer', ['[a'] = '@parameter.inner' }, - goto_previous_end = { ['[F'] = '@function.outer', ['[A'] = '@parameter.inner' }, - }, - swap = { - enable = true, - swap_next = { - ['xp'] = { query = '@parameter.inner', desc = 'Swap parameter with the next one' }, - }, - swap_previous = { - ['xP'] = { - query = '@parameter.inner', - desc = 'Swap parameter with the previous one', - }, - }, - }, - }, - }) - end, - }, - { - 'nvim-treesitter/nvim-treesitter-context', - event = 'VeryLazy', - config = function() - require('treesitter-context').setup({ mode = 'cursor', max_lines = 3 }) - end, - }, -} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua deleted file mode 100644 index 551666d..0000000 --- a/lua/plugins/ui.lua +++ /dev/null @@ -1,190 +0,0 @@ -return { - { - 'rcarriga/nvim-notify', - event = 'VeryLazy', - keys = { - { - 'mn', - function() - require('notify').dismiss({ silent = true, pending = true }) - end, - desc = 'Dismiss All Notifications', - }, - }, - opts = { - level = 2, - minimum_width = 50, - stages = 'fade', - timeout = 3000, - top_down = true, - render = 'compact', - background_colour = '#000000', - }, - }, - { - 'folke/noice.nvim', - event = 'UIEnter', - dependencies = { - { 'MunifTanjim/nui.nvim', lazy = true }, - 'rcarriga/nvim-notify', - }, - opts = { - cmdline = { - view = 'cmdline', - format = { - cmdline = { icon = '▍' }, - substitute = { - pattern = '^:%%?s/', - icon = ' ', - ft = 'regex', - opts = { border = { text = { top = ' sub (old/new/) ' } } }, - }, - input = { view = 'cmdline_input', icon = '█' }, - }, - }, - routes = { - { - view = 'notify', - filter = { event = 'msg_showmode' }, - }, - { - filter = { - event = 'msg_show', - kind = '', - find = 'written', - }, - opts = { skip = true }, - }, - }, - lsp = { - progress = { - enabled = false, - format = 'lsp_progress', - format_done = 'lsp_progress_done', - throttle = 1000 / 30, - view = 'mini', - }, - override = { - ['vim.lsp.util.convert_input_to_markdown_lines'] = true, - ['vim.lsp.util.stylize_markdown'] = true, - ['cmp.entry.get_documentation'] = true, - }, - hover = { - enabled = true, - silent = false, - view = nil, - opts = {}, - }, - signature = { - enabled = false, - auto_open = { - enabled = true, - trigger = true, - luasnip = true, - throttle = 50, - }, - view = nil, - opts = {}, - }, - message = { - enabled = true, - view = 'notify', - opts = {}, - }, - documentation = { - view = 'hover', - opts = { - lang = 'markdown', - replace = true, - render = 'plain', - format = { '{message}' }, - win_options = { concealcursor = 'n', conceallevel = 3 }, - }, - }, - }, - presets = { - bottom_search = true, - command_palette = false, - long_message_to_split = true, - inc_rename = false, - lsp_doc_border = true, - }, - }, - }, - { - 'andymass/vim-matchup', - -- enabled = false, - event = { 'BufReadPost', 'BufNewFile' }, - config = function() - -- may set any options here - vim.g.matchup_matchparen_offscreen = {} - end, - }, - { - 'stevearc/dressing.nvim', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local dressing = require('dressing') - - dressing.setup({ - win_options = { - winblend = 10, - winhighlight = 'Normal:DressingInputNormalFloat,NormalFloat:DressingInputNormalFloat,FloatBorder:DressingInputFloatBorder', - }, - input = { - enabled = true, - default_prompt = 'Input:', - prompt_align = 'left', - insert_only = true, - start_in_insert = true, - border = 'rounded', - relative = 'cursor', - prefer_width = 40, - width = nil, - max_width = { 140, 0.9 }, - min_width = { 20, 0.2 }, - get_config = nil, - }, - select = { - enabled = true, - backend = { 'telescope', 'fzf_lua', 'fzf', 'nui', 'builtin' }, - trim_prompt = true, - }, - }) - end, - }, - {}, - { - 'nvim-lualine/lualine.nvim', - event = { 'BufReadPost', 'BufNewFile' }, - config = function() - require('plugins.configs.lualine') - end, - }, - -- { - -- "nvim-tree/nvim-web-devicons", - -- config = true, - -- }, - { - 'lukas-reineke/indent-blankline.nvim', - main = 'ibl', - event = { 'BufReadPost', 'BufNewFile' }, - opts = { - exclude = { - filetypes = { 'help', 'alpha', 'dashboard', 'neo-tree', 'Trouble', 'lazy' }, - }, - }, - }, - { - 'nvimdev/dashboard-nvim', - cmd = 'Dashboard', - config = function() - require('plugins.configs.dashboard') - end, - event = function() - if vim.fn.argc() == 0 then - return 'VimEnter' - end - end, - }, -} diff --git a/lua/plugins/ui/dressing.lua b/lua/plugins/ui/dressing.lua new file mode 100644 index 0000000..e6f2ef0 --- /dev/null +++ b/lua/plugins/ui/dressing.lua @@ -0,0 +1,27 @@ +local dressing = require('dressing') + +dressing.setup({ + win_options = { + winblend = 10, + winhighlight = 'Normal:DressingInputNormalFloat,NormalFloat:DressingInputNormalFloat,FloatBorder:DressingInputFloatBorder', + }, + input = { + enabled = true, + default_prompt = 'Input:', + prompt_align = 'left', + insert_only = true, + start_in_insert = true, + border = 'rounded', + relative = 'cursor', + prefer_width = 40, + width = nil, + max_width = { 140, 0.9 }, + min_width = { 20, 0.2 }, + get_config = nil, + }, + select = { + enabled = true, + backend = { 'telescope', 'fzf_lua', 'fzf', 'nui', 'builtin' }, + trim_prompt = true, + }, +}) diff --git a/lua/plugins/configs/lualine.lua b/lua/plugins/ui/lualine.lua similarity index 95% rename from lua/plugins/configs/lualine.lua rename to lua/plugins/ui/lualine.lua index dfb4ce3..20f8209 100644 --- a/lua/plugins/configs/lualine.lua +++ b/lua/plugins/ui/lualine.lua @@ -45,6 +45,9 @@ local conditions = { buffer_is_file = function() return vim.bo.buftype == '' end, + buffer_not_scratch = function() + return string.find(vim.fn.bufname(), 'SCRATCH') == nil + end, hide_in_width = function() return vim.fn.winwidth(0) > 80 end, @@ -63,12 +66,14 @@ local fileformat = { 'fileformat', icons_enabled = true, color = { fg = colors.w local filename = { 'filename', - cond = conditions.buffer_not_empty and conditions.buffer_is_file, + cond = conditions.buffer_not_empty and conditions.buffer_is_file and conditions.buffer_not_scratch, color = { fg = colors.magenta, gui = 'bold' }, } local buffers = { 'buffers', + mode = 2, + cond = conditions.buffer_not_scratch, filetype_names = { TelescopePrompt = icons.ui.Telescope .. 'Telescope', dashboard = icons.ui.Dashboard .. 'Dashboard', @@ -173,7 +178,7 @@ lualine.setup({ -- section_separators = '', theme = 'onedark', disabled_filetypes = { - statusline = { 'neo-tree', 'alpha', 'dashboard', 'lspsagaoutline' }, + 'dashboard', }, }, -- extensions = { 'quickfix', 'man', 'mason', 'lazy', 'toggleterm', 'nvim-tree' }, diff --git a/lua/plugins/ui/onedark.lua b/lua/plugins/ui/onedark.lua new file mode 100644 index 0000000..a475449 --- /dev/null +++ b/lua/plugins/ui/onedark.lua @@ -0,0 +1,25 @@ +local onedark = require('onedark') + +onedark.setup({ + style = 'deep', + transparent = true, + term_colors = false, + ending_tildes = false, + cmp_itemkind_reverse = false, + + toggle_style_key = 'ot', + toggle_style_list = { 'dark', 'darker', 'cool', 'warm', 'warmer', 'deep', 'light' }, + + -- Options are italic, bold, underline, none and combos 'italic,bold' + code_style = { + comments = 'italic', + keywords = 'none', + functions = 'none', + strings = 'none', + variables = 'none', + }, + + lualine = { transparent = true }, + diagnostics = { darker = true, undercurl = true, background = false }, +}) +onedark.load() diff --git a/lua/plugins/ui/snacks.lua b/lua/plugins/ui/snacks.lua new file mode 100644 index 0000000..3da9621 --- /dev/null +++ b/lua/plugins/ui/snacks.lua @@ -0,0 +1,252 @@ +local Snacks = require('snacks') +local icons = require('lib.icons') + +Snacks.setup({ + animate = { + enabled = true, + duration = 20, -- ms per step + easing = 'linear', + fps = 60, + }, + bigfile = { + enabled = true, + notify = true, + size = 100 * 1024, -- 100 KB + }, + bufdelete = { enabled = true }, + dashboard = { + enabled = true, + sections = { + { section = 'header' }, + { + icon = icons.ui.Keyboard, + title = 'Keymaps', + section = 'keys', + indent = 2, + padding = 1, + }, + { + icon = icons.documents.File, + title = 'Recent Files', + section = 'recent_files', + indent = 2, + padding = 1, + }, + { + icon = icons.documents.OpenFolder, + title = 'Projects', + section = 'projects', + indent = 2, + padding = 1, + }, + { section = 'startup' }, + }, + }, + debug = { enabled = true }, + dim = { + enabled = true, + scope = { + min_size = 5, + max_size = 20, + siblings = true, + }, + }, + git = { enabled = true }, + gitbrowse = { enabled = true }, + indent = { + enabled = true, + priority = 1, + char = icons.ui.SeparatorLight, + only_scope = false, + only_current = false, + hl = { + 'SnacksIndent1', + 'SnacksIndent2', + 'SnacksIndent3', + 'SnacksIndent4', + 'SnacksIndent5', + 'SnacksIndent6', + 'SnacksIndent7', + 'SnacksIndent8', + }, + }, + input = { + enabled = true, + icon = icons.ui.Edit, + icon_hl = 'SnacksInputIcon', + icon_pos = 'left', + prompt_pos = 'title', + win = { style = 'input' }, + expand = true, + }, + lazygit = { enabled = true }, + notifier = { + enabled = true, + timeout = 2000, + width = { min = 40, max = 0.4 }, + height = { min = 1, max = 0.6 }, + margin = { top = 0, right = 1, bottom = 0 }, + padding = true, + sort = { 'level', 'added' }, + level = vim.log.levels.TRACE, + icons = { + debug = icons.ui.Bug, + error = icons.diagnostics.Error, + info = icons.diagnostics.Information, + trace = icons.ui.Bookmark, + warn = icons.diagnostics.Warning, + }, + style = 'compact', + top_down = true, + date_format = '%R', + more_format = ' ↓ %d lines ', + refresh = 50, + }, + notify = { enabled = true }, + profiler = { enabled = true }, + quickfile = { enabled = true }, + rename = { enabled = true }, + scope = { + enabled = true, + keys = { + textobject = { + ii = { + min_size = 2, -- minimum size of the scope + edge = false, -- inner scope + cursor = false, + treesitter = { blocks = { enabled = false } }, + desc = 'inner scope', + }, + ai = { + cursor = false, + min_size = 2, -- minimum size of the scope + treesitter = { blocks = { enabled = false } }, + desc = 'full scope', + }, + }, + jump = { + ['[a'] = { + min_size = 1, -- allow single line scopes + bottom = false, + cursor = false, + edge = true, + treesitter = { blocks = { enabled = false } }, + desc = 'jump to top edge of scope', + }, + [']a'] = { + min_size = 1, -- allow single line scopes + bottom = true, + cursor = false, + edge = true, + treesitter = { blocks = { enabled = false } }, + desc = 'jump to bottom edge of scope', + }, + }, + }, + }, + scratch = { + enabled = true, + name = 'SCRATCH', + ft = function() + if vim.bo.buftype == '' and vim.bo.filetype ~= '' then + return vim.bo.filetype + end + return 'markdown' + end, + icon = nil, + root = vim.fn.stdpath('data') .. '/scratch', + autowrite = true, + filekey = { + cwd = true, + branch = true, + count = true, + }, + win = { + width = 120, + height = 40, + bo = { buftype = '', buflisted = false, bufhidden = 'hide', swapfile = false }, + minimal = false, + noautocmd = false, + zindex = 20, + wo = { winhighlight = 'NormalFloat:Normal' }, + border = 'rounded', + title_pos = 'center', + footer_pos = 'center', + + keys = { + ['execute'] = { + '', + function(_) + vim.cmd('%SnipRun') + end, + desc = 'Execute buffer', + mode = { 'n', 'x' }, + }, + }, + }, + win_by_ft = { + lua = { + keys = { + ['source'] = { + '', + function(self) + local name = 'scratch.' .. vim.fn.fnamemodify(vim.api.nvim_buf_get_name(self.buf), ':e') + Snacks.debug.run({ buf = self.buf, name = name }) + end, + desc = 'Source buffer', + mode = { 'n', 'x' }, + }, + ['execute'] = { + 'e', + function(_) + vim.cmd('%SnipRun') + end, + desc = 'Execute buffer', + mode = { 'n', 'x' }, + }, + }, + }, + }, + }, + scroll = { enabled = false }, + statuscolumn = { + enabled = true, + left = { 'mark', 'sign' }, + right = { 'fold', 'git' }, + folds = { + open = false, + git_hl = false, + }, + git = { + patterns = { 'GitSign', 'MiniDiffSign' }, + }, + refresh = 50, + }, + terminal = { enabled = false }, + toggle = { enabled = false }, + win = { enabled = true }, + words = { enabled = false }, + zen = { + enabled = true, + toggles = { + dim = true, + git_signs = false, + mini_diff_signs = false, + -- diagnostics = false, + -- inlay_hints = false, + }, + show = { + statusline = false, + tabline = false, + }, + win = { style = 'zen' }, + zoom = { + toggles = {}, + show = { statusline = true, tabline = true }, + win = { + backdrop = false, + width = 0, + }, + }, + }, +}) diff --git a/selene.toml b/selene.toml deleted file mode 100644 index eac3e9b..0000000 --- a/selene.toml +++ /dev/null @@ -1,4 +0,0 @@ -std = "vim" - -[lints] -mixed_table = "allow"