From f0ebf86684ac579f095b9ca24553b45540ee33c4 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 27 Apr 2024 00:09:57 +0545 Subject: [PATCH] initial --- init.lua | 7 + lua/core/autocmd.lua | 105 +++++ lua/core/functions.lua | 35 ++ lua/core/keymaps.lua | 80 ++++ lua/core/options.lua | 90 ++++ lua/lib/icons.lua | 156 +++++++ lua/lib/util.lua | 51 ++ lua/plugins/lang/ai.lua | 35 ++ lua/plugins/lang/autopairs.lua | 26 ++ lua/plugins/lang/cmp.lua | 105 +++++ lua/plugins/lang/codeium.lua | 4 + lua/plugins/lang/comment.lua | 26 ++ lua/plugins/lang/copilot.lua | 47 ++ lua/plugins/lang/dap.lua | 107 +++++ lua/plugins/lang/lsp-lines.lua | 4 + lua/plugins/lang/lspconfig.lua | 49 ++ lua/plugins/lang/lspsaga.lua | 21 + lua/plugins/lang/mason.lua | 35 ++ lua/plugins/lang/neodev.lua | 15 + lua/plugins/lang/neotest.lua | 19 + lua/plugins/lang/null-ls.lua | 51 ++ lua/plugins/lang/refactoring.lua | 25 + lua/plugins/lang/ror.lua | 20 + lua/plugins/lang/sniprun.lua | 14 + lua/plugins/lang/surround.lua | 25 + lua/plugins/lang/textobjects.lua | 115 +++++ lua/plugins/lang/treesitter.lua | 78 ++++ lua/plugins/lazy.lua | 109 +++++ lua/plugins/list.lua | 539 ++++++++++++++++++++++ lua/plugins/lock.json | 82 ++++ lua/plugins/tools/ccc.lua | 10 + lua/plugins/tools/dbee.lua | 19 + lua/plugins/tools/flash.lua | 15 + lua/plugins/tools/gitlinker.lua | 24 + lua/plugins/tools/gitsigns.lua | 93 ++++ lua/plugins/tools/harpoon.lua | 51 ++ lua/plugins/tools/navigator.lua | 8 + lua/plugins/tools/nvim-tree.lua | 92 ++++ lua/plugins/tools/oil.lua | 24 + lua/plugins/tools/spectre.lua | 125 +++++ lua/plugins/tools/spider.lua | 10 + lua/plugins/tools/tabout.lua | 22 + lua/plugins/tools/telescope-multiopen.lua | 67 +++ lua/plugins/tools/telescope.lua | 163 +++++++ lua/plugins/tools/which-key.lua | 459 ++++++++++++++++++ lua/plugins/ui/dashboard.lua | 82 ++++ lua/plugins/ui/dracula.lua | 69 +++ lua/plugins/ui/dressing.lua | 27 ++ lua/plugins/ui/indentline.lua | 27 ++ lua/plugins/ui/lualine.lua | 196 ++++++++ lua/plugins/ui/notify.lua | 56 +++ lua/plugins/ui/rainbow.lua | 19 + lua/plugins/ui/twilight.lua | 9 + lua/plugins/ui/wilder.lua | 66 +++ lua/plugins/ui/zen-mode.lua | 31 ++ 55 files changed, 3839 insertions(+) create mode 100644 init.lua create mode 100644 lua/core/autocmd.lua create mode 100644 lua/core/functions.lua create mode 100644 lua/core/keymaps.lua create mode 100644 lua/core/options.lua create mode 100644 lua/lib/icons.lua create mode 100644 lua/lib/util.lua create mode 100644 lua/plugins/lang/ai.lua create mode 100644 lua/plugins/lang/autopairs.lua create mode 100644 lua/plugins/lang/cmp.lua create mode 100644 lua/plugins/lang/codeium.lua create mode 100644 lua/plugins/lang/comment.lua create mode 100644 lua/plugins/lang/copilot.lua create mode 100644 lua/plugins/lang/dap.lua create mode 100644 lua/plugins/lang/lsp-lines.lua create mode 100644 lua/plugins/lang/lspconfig.lua create mode 100644 lua/plugins/lang/lspsaga.lua create mode 100644 lua/plugins/lang/mason.lua create mode 100644 lua/plugins/lang/neodev.lua create mode 100644 lua/plugins/lang/neotest.lua create mode 100644 lua/plugins/lang/null-ls.lua create mode 100644 lua/plugins/lang/refactoring.lua create mode 100644 lua/plugins/lang/ror.lua create mode 100644 lua/plugins/lang/sniprun.lua create mode 100644 lua/plugins/lang/surround.lua create mode 100644 lua/plugins/lang/textobjects.lua create mode 100644 lua/plugins/lang/treesitter.lua create mode 100644 lua/plugins/lazy.lua create mode 100644 lua/plugins/list.lua create mode 100644 lua/plugins/lock.json create mode 100644 lua/plugins/tools/ccc.lua create mode 100644 lua/plugins/tools/dbee.lua create mode 100644 lua/plugins/tools/flash.lua create mode 100644 lua/plugins/tools/gitlinker.lua create mode 100644 lua/plugins/tools/gitsigns.lua create mode 100644 lua/plugins/tools/harpoon.lua create mode 100644 lua/plugins/tools/navigator.lua create mode 100644 lua/plugins/tools/nvim-tree.lua create mode 100644 lua/plugins/tools/oil.lua create mode 100644 lua/plugins/tools/spectre.lua create mode 100644 lua/plugins/tools/spider.lua create mode 100644 lua/plugins/tools/tabout.lua create mode 100644 lua/plugins/tools/telescope-multiopen.lua create mode 100644 lua/plugins/tools/telescope.lua create mode 100644 lua/plugins/tools/which-key.lua create mode 100644 lua/plugins/ui/dashboard.lua create mode 100644 lua/plugins/ui/dracula.lua create mode 100644 lua/plugins/ui/dressing.lua create mode 100644 lua/plugins/ui/indentline.lua create mode 100644 lua/plugins/ui/lualine.lua create mode 100644 lua/plugins/ui/notify.lua create mode 100644 lua/plugins/ui/rainbow.lua create mode 100644 lua/plugins/ui/twilight.lua create mode 100644 lua/plugins/ui/wilder.lua create mode 100644 lua/plugins/ui/zen-mode.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..c452478 --- /dev/null +++ b/init.lua @@ -0,0 +1,7 @@ +require('core.options') +require('core.functions') +require('core.keymaps') +require('core.autocmd') +require('plugins.lazy') +-- Add user configs to this module +pcall(require, 'user') diff --git a/lua/core/autocmd.lua b/lua/core/autocmd.lua new file mode 100644 index 0000000..c3097a1 --- /dev/null +++ b/lua/core/autocmd.lua @@ -0,0 +1,105 @@ +local function augroup(name) + return vim.api.nvim_create_augroup('nvim2k_' .. name, { clear = true }) +end + +-- Strip trailing spaces before write +vim.api.nvim_create_autocmd({ 'BufWritePre' }, { + group = augroup('strip_space'), + pattern = { '*' }, + callback = function() + vim.cmd([[ %s/\s\+$//e ]]) + end, +}) + +-- 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 +vim.api.nvim_create_autocmd('TextYankPost', { + group = augroup('highlight_yank'), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- resize splits if window got resized +vim.api.nvim_create_autocmd({ 'VimResized' }, { + group = augroup('resize_splits'), + callback = function() + vim.cmd('tabdo wincmd =') + end, +}) + +-- go to last loc when opening a buffer +vim.api.nvim_create_autocmd('BufReadPost', { + group = augroup('last_loc'), + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local lcount = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= lcount then + pcall(vim.api.nvim_win_set_cursor, 0, mark) + end + end, +}) + +-- close some filetypes with +vim.api.nvim_create_autocmd('FileType', { + group = augroup('close_with_q'), + pattern = { + 'DressingSelect', + 'Jaq', + 'PlenaryTestPopup', + 'fugitive', + 'help', + 'lir', + 'lspinfo', + 'man', + 'notify', + 'qf', + 'spectre_panel', + 'startuptime', + 'tsplayground', + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set('n', 'q', 'close', { buffer = event.buf, silent = true }) + end, +}) + +-- wrap and check for spell in text filetypes +vim.api.nvim_create_autocmd('FileType', { + group = augroup('wrap_spell'), + pattern = { 'gitcommit', 'markdown' }, + callback = function() + vim.opt_local.wrap = true + vim.opt_local.spell = true + end, +}) + +-- 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) + local file = vim.loop.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ':p:h'), 'p') + end, +}) + +-- 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 +vim.api.nvim_create_autocmd('FileType', { + group = augroup('disable_formatoptions'), + pattern = '*', + callback = function() + vim.opt_local.formatoptions:remove({ 'c', 'r', 'o' }) + end, +}) diff --git a/lua/core/functions.lua b/lua/core/functions.lua new file mode 100644 index 0000000..5fe9e22 --- /dev/null +++ b/lua/core/functions.lua @@ -0,0 +1,35 @@ +-- Reload neovim config +vim.api.nvim_create_user_command('ReloadConfig', function() + for name, _ in pairs(package.loaded) do + if name:match('^plugins') then + package.loaded[name] = nil + end + end + + dofile(vim.env.MYVIMRC) + vim.notify('Nvim configuration reloaded!', vim.log.levels.INFO) +end, {}) + +-- Copy relative path +vim.api.nvim_create_user_command('CRpath', function() + local path = vim.fn.expand('%') + vim.fn.setreg('+', path) + vim.notify('Copied "' .. path .. '" to the clipboard!') +end, {}) + +-- Copy absolute path +vim.api.nvim_create_user_command('CApath', function() + local path = vim.fn.expand('%:p') + vim.fn.setreg('+', path) + vim.notify('Copied "' .. path .. '" to the clipboard!') +end, {}) + +-- Switch to git root or file parent dir +vim.api.nvim_create_user_command('RootDir', function() + local root = require('lib.util').get_root_dir() + + if root == '' then + return + end + vim.cmd('lcd ' .. root) +end, {}) diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua new file mode 100644 index 0000000..2ebaa50 --- /dev/null +++ b/lua/core/keymaps.lua @@ -0,0 +1,80 @@ +local function map(mode, lhs, rhs, opts) + opts = opts or {} + opts.silent = opts.silent ~= false + vim.keymap.set(mode, lhs, rhs, opts) +end +local opts = { noremap = true, silent = true } + +-- Space as leader +map('n', '', '', opts) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- Modes +-- normal_mode = "n", insert_mode = "i", visual_mode = "v", +-- visual_block_mode = "x", term_mode = "t", command_mode = "c", + +-- Use jj as escape +map('i', 'jj', '', opts) +map('t', 'JJ', '', opts) + +-- Visual overwrite paste +map({ 'v', 'x' }, 'p', '"_dP', opts) + +-- Do not copy on x +map({ 'v', 'x' }, 'x', '"_x', opts) + +-- Increment/decrement +map({ 'n', 'v', 'x' }, '-', '', opts) +map({ 'n', 'v', 'x' }, '=', '', opts) + +-- Move to line beginning and end +map({ 'n', 'v', 'x' }, 'gl', '$', { desc = 'End of line' }) +map({ 'n', 'v', 'x' }, 'gh', '^', { desc = 'Beginning of line' }) + +-- Center Cursors +map('n', 'J', 'mzJ`z', opts) +map('n', '', 'zz', opts) +map('n', '', 'zz', opts) +map('n', 'n', 'nzzzv', opts) +map('n', 'N', 'Nzzzv', opts) + +-- Better up/down +map('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +map('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) + +-- Move text up and down +map({ 'v', 'x' }, 'J', ":move '>+1gv-gv", opts) +map({ 'v', 'x' }, 'K', ":move '<-2gv-gv", opts) + +-- Clear search, diff update and redraw +map({ 'i', 'n' }, '', 'noh', { desc = 'Escape and clear hlsearch' }) + +-- 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' }) +map('o', 'n', "'Nn'[v:searchforward]", { expr = true, desc = 'Next search result' }) +map('n', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' }) +map('x', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' }) +map('o', 'N', "'nN'[v:searchforward]", { expr = true, desc = 'Prev search result' }) + +-- Better indenting +map('v', '<', '', '>gv') + +-- Add undo breakpoints +map('i', ',', ',u') +map('i', '.', '.u') +map('i', ';', ';u') + +-- Codeium +map('i', '', function () return vim.fn['codeium#Accept']() end, { expr = true, silent = true }) +map('i', '', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true, silent = true }) +map('i', '', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true, silent = true }) +map('i', '', function() return vim.fn['codeium#Clear']() end, { expr = true, silent = true }) + + + +map('n', 'e', function() + require("oil").toggle_float() +end) diff --git a/lua/core/options.lua b/lua/core/options.lua new file mode 100644 index 0000000..7e17c22 --- /dev/null +++ b/lua/core/options.lua @@ -0,0 +1,90 @@ +local options = { + ai = true, + autoindent = true, + autowrite = true, + backspace = 'indent,eol,start', + backup = false, -- creates a backup file + breakindent = true, + clipboard = 'unnamedplus', -- allows neovim to access the system clipboard + cmdheight = 1, -- more space in the neovim command line for displaying messages + completeopt = 'menu,menuone,noselect', -- mostly just for cmp + conceallevel = 0, -- so that `` is visible in markdown files + confirm = true, -- Confirm to save changes before exiting modified buffer + cursorline = true, -- highlight the current line + expandtab = true, -- convert tabs to spaces + fileencoding = 'utf-8', -- the encoding written to a file + formatoptions = 'jlnqt', -- set formatoptions, check help fo-table + grepformat = '%f:%l:%c:%m', + grepprg = 'rg --vimgrep', + hlsearch = true, -- highlight all matches on previous search pattern + ignorecase = true, -- ignore case in search patterns + inccommand = 'split', -- preview incremental substitute + laststatus = 3, + 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 2 {default 4} + pumblend = 10, -- Popup blen + pumheight = 10, -- pop up menu height + relativenumber = true, -- set relative numbered lines + scrolloff = 10, -- is one of my fav + sessionoptions = 'blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal', + shiftround = true, -- Round indent + shiftwidth = 4, -- the number of spaces inserted for each indentation + showcmd = false, + showmode = false, -- we don't need to see things like -- INSERT -- anymore + showtabline = 0, -- always show tabs + si = true, + sidescrolloff = 8, + signcolumn = 'yes', -- always show the sign column, otherwise it would shift the text each time + smartcase = true, -- smart case + smartindent = true, -- make indenting smarter again + smarttab = true, + splitbelow = true, -- force all horizontal splits to go below current window + splitright = true, -- force all vertical splits to go to the right of current window + swapfile = false, -- creates a swapfile + 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) + undofile = true, -- enable persistent undo + undolevels = 10000, + updatetime = 50, -- faster completion (4000ms default) + wildmenu = true, -- wildmenu + wildmode = 'longest:full,full', -- Command-line completion mode + winminwidth = 5, -- Minimum window width + wrap = false, -- display lines as one long line + writebackup = false, -- do not edit backups +} + +vim.cmd([[ + setlocal spell spelllang=en "Set spellcheck language to en + setlocal spell! "Disable spell checks by default + filetype plugin indent on + if has('win32') + let g:python3_host_prog = $HOME . '/scoop/apps/python/current/python.exe' + endif + ]]) + +vim.opt.path:append({ '**' }) + +-- Undercurl +vim.cmd([[let &t_Cs = "\e[4:3m"]]) +vim.cmd([[let &t_Ce = "\e[4:0m"]]) + +vim.opt.shortmess:append({ W = true, I = true, c = true }) + +if vim.fn.has('nvim-0.9.0') == 1 then + vim.opt.splitkeep = 'screen' + vim.opt.shortmess:append({ C = true }) +end + +-- Fix markdown indentation settings +vim.g.markdown_recommended_style = 0 + +for k, v in pairs(options) do + vim.opt[k] = v +end + +vim.cmd('set whichwrap+=<,>,[,],h,l') +vim.cmd([[set iskeyword+=-]]) diff --git a/lua/lib/icons.lua b/lua/lib/icons.lua new file mode 100644 index 0000000..cf664f3 --- /dev/null +++ b/lua/lib/icons.lua @@ -0,0 +1,156 @@ +return { + diagnostics = { + Error = ' ', + Hint = '󰠠 ', + Information = ' ', + Question = ' ', + Warning = ' ', + }, + documents = { + File = ' ', + FileEmpty = ' ', + Files = ' ', + Folder = ' ', + FolderEmpty = ' ', + OpenFolder = ' ', + OpenFolderEmpty = ' ', + SymLink = ' ', + SymlinkFolder = ' ', + Import = ' ', + }, + git = { + Add = ' ', + AddAlt = ' ', + Branch = ' ', + Diff = ' ', + DiffAlt = ' ', + Ignore = '◌ ', + Mod = ' ', + Octoface = ' ', + Remove = ' ', + RemoveAlt = ' ', + Rename = ' ', + Repo = ' ', + Tag = ' ', + Untrack = ' ', + }, + kind = { + Class = ' ', + Color = ' ', + Constant = ' ', + Constructor = '󰈏 ', + Enum = ' ', + EnumMember = ' ', + Event = ' ', + Field = ' ', + File = ' ', + Folder = ' ', + Function = '󰊕 ', + Interface = ' ', + Keyword = ' ', + Method = ' ', + Module = '', + Operator = ' ', + Property = ' ', + Reference = ' ', + Snippet = ' ', + Struct = ' ', + Text = ' ', + TypeParameter = ' ', + Unit = ' ', + Value = ' ', + Variable = ' ', + }, + type = { + Array = ' ', + Boolean = '⏻ ', + Number = ' ', + Object = ' ', + String = ' ', + }, + ui = { + AI = ' ', + Arrow = ' ', + ArrowClosed = ' ', + ArrowLeft = ' ', + ArrowOpen = ' ', + ArrowRight = ' ', + Bluetooth = ' ', + Bookmark = ' ', + Bug = ' ', + Calendar = ' ', + Camera = ' ', + Check = ' ', + ChevronRight = '', + Circle = ' ', + CircleSmall = '● ', + CircleSmallEmpty = '○ ', + Clipboard = ' ', + Close = ' ', + Code = ' ', + Collection = ' ', + Color = ' ', + Command = ' ', + Comment = ' ', + Corner = '└ ', + Dashboard = ' ', + Database = ' ', + Download = ' ', + Edge = '│ ', + Electric = ' ', + Fire = ' ', + Firefox = ' ', + Game = ' ', + Gear = ' ', + GitHub = ' ', + Heart = ' ', + History = ' ', + Home = ' ', + Incoming = ' ', + Keyboard = ' ', + Ligthbulb = '󰌵 ', + List = '', + Lock = ' ', + Minus = '‒ ', + Music = '󰝚 ', + NeoVim = ' ', + NewFile = ' ', + None = ' ', + Note = ' ', + Outgoing = ' ', + Package = ' ', + Paint = ' ', + Pause = ' ', + Pencil = ' ', + Person = ' ', + Pin = ' ', + Play = ' ', + Plug = ' ', + Plus = ' ', + Power = ' ', + PowerlineArrowLeft = '', + PowerlineArrowRight = '', + PowerlineLeftRound = '', + PowerlineRightRound = '', + Project = ' ', + Question = ' ', + Reload = ' ', + Rocket = ' ', + Save = '󰆓 ', + Search = ' ', + Separator = '▊ ', + SignIn = ' ', + SignOut = ' ', + Sleep = '󰒲 ', + Star = ' ', + Table = ' ', + Telescope = ' ', + Terminal = ' ', + Test = ' ', + Time = ' ', + Trash = ' ', + Vim = ' ', + Wifi = ' ', + Windows = ' ', + }, +} diff --git a/lua/lib/util.lua b/lua/lib/util.lua new file mode 100644 index 0000000..52d883f --- /dev/null +++ b/lua/lib/util.lua @@ -0,0 +1,51 @@ +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 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 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() + + 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 +end + +return util 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..ae6231f --- /dev/null +++ b/lua/plugins/lang/autopairs.lua @@ -0,0 +1,26 @@ +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', + }, +}) + +local cmp_autopairs = require('nvim-autopairs.completion.cmp') +local cmp = require('cmp') +cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) diff --git a/lua/plugins/lang/cmp.lua b/lua/plugins/lang/cmp.lua new file mode 100644 index 0000000..e729f47 --- /dev/null +++ b/lua/plugins/lang/cmp.lua @@ -0,0 +1,105 @@ +local cmp = require('cmp') +local luasnip = require('luasnip') + +require('luasnip/loaders/from_vscode').lazy_load() + +local icons = require('lib.icons') +local kind_icons = icons.kind +vim.api.nvim_set_hl(0, 'CmpItemKindCopilot', { fg = '#6CC644' }) + +cmp.setup({ + completion = { + completeopt = 'menu,menuone,preview,noselect', + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping(cmp.mapping.scroll_docs(-1), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(1), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.config.disable, + [''] = cmp.mapping({ + 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' }), + }, + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + expandable_indicator = true, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = kind_icons[vim_item.kind] + + if entry.source.name == 'copilot' then + vim_item.kind = icons.git.Octoface + vim_item.kind_hl_group = 'CmpItemKindCopilot' + end + + vim_item.menu = ({ + codeium = '[Codeium]', + nvim_lsp = '[LSP]', + luasnip = '[Snippet]', + buffer = '[Buffer]', + path = '[Path]', + })[entry.source.name] + return vim_item + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'nvim_lua' }, + { name = 'luasnip', keyword_length = 2 }, + { name = 'buffer', keyword_length = 3 }, + { name = 'codeium'}, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + documentation = { + border = 'rounded', + winhighlight = 'NormalFloat:Pmenu,NormalFloat:Pmenu,CursorLine:PmenuSel,Search:None', + }, + completion = { + border = 'rounded', + winhighlight = 'NormalFloat:Pmenu,NormalFloat:Pmenu,CursorLine:PmenuSel,Search:None', + }, + scrollbar = true, + }, + experimental = { + ghost_text = true, + }, +}) diff --git a/lua/plugins/lang/codeium.lua b/lua/plugins/lang/codeium.lua new file mode 100644 index 0000000..bae659d --- /dev/null +++ b/lua/plugins/lang/codeium.lua @@ -0,0 +1,4 @@ +require('codeium').setup({ + +}) + diff --git a/lua/plugins/lang/comment.lua b/lua/plugins/lang/comment.lua new file mode 100644 index 0000000..3079776 --- /dev/null +++ b/lua/plugins/lang/comment.lua @@ -0,0 +1,26 @@ +local comment = require('mini.comment') + +require('ts_context_commentstring').setup({ + enable_autocmd = false, + -- languages = { typescript = '// %s' }, +}) + +comment.setup({ + options = { + custom_commentstring = function() + return require('ts_context_commentstring.internal').calculate_commentstring() or vim.bo.commentstring + end, + ignore_blank_line = true, + start_of_line = false, + pad_comment_parts = true, + }, + + mappings = { + -- Toggle comment (like `gcip` - comment inner paragraph) for both + comment = 'gc', + comment_line = 'gcc', + comment_visual = 'gc', + -- Define 'comment' textobject (like `dgc` - delete whole comment block) + textobject = 'gc', + }, +}) diff --git a/lua/plugins/lang/copilot.lua b/lua/plugins/lang/copilot.lua new file mode 100644 index 0000000..b5ad496 --- /dev/null +++ b/lua/plugins/lang/copilot.lua @@ -0,0 +1,47 @@ +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 = true, + 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 = {}, +}) + +require('copilot_cmp').setup() 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/lsp-lines.lua b/lua/plugins/lang/lsp-lines.lua new file mode 100644 index 0000000..4e24179 --- /dev/null +++ b/lua/plugins/lang/lsp-lines.lua @@ -0,0 +1,4 @@ +local lsp_lines = require('lsp_lines') + +lsp_lines.setup() +vim.diagnostic.config({ virtual_text = false }) diff --git a/lua/plugins/lang/lspconfig.lua b/lua/plugins/lang/lspconfig.lua new file mode 100644 index 0000000..fbb9dd2 --- /dev/null +++ b/lua/plugins/lang/lspconfig.lua @@ -0,0 +1,49 @@ +local lspconfig = require('lspconfig') +local cmp_lsp = require('cmp_nvim_lsp') +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 lsp_capabilities = cmp_lsp.default_capabilities() +local default_setup = function(server) + lspconfig[server].setup({ + capabilities = 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/neodev.lua b/lua/plugins/lang/neodev.lua new file mode 100644 index 0000000..d316e6c --- /dev/null +++ b/lua/plugins/lang/neodev.lua @@ -0,0 +1,15 @@ +local neodev = require('neodev') + +neodev.setup({ + library = { + enabled = true, + runtime = true, + types = true, + plugins = true, -- installed opt or start plugins in packpath + -- you can also specify the list of plugins to make available as a workspace library + -- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, + }, + setup_jsonls = true, + lspconfig = true, + pathStrict = true, +}) diff --git a/lua/plugins/lang/neotest.lua b/lua/plugins/lang/neotest.lua new file mode 100644 index 0000000..ddbceab --- /dev/null +++ b/lua/plugins/lang/neotest.lua @@ -0,0 +1,19 @@ +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', + }), + }, +}) diff --git a/lua/plugins/lang/null-ls.lua b/lua/plugins/lang/null-ls.lua new file mode 100644 index 0000000..c095176 --- /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 + 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, + 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..8dec6f1 --- /dev/null +++ b/lua/plugins/lang/sniprun.lua @@ -0,0 +1,14 @@ +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', +}) 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..ccc83da --- /dev/null +++ b/lua/plugins/lang/textobjects.lua @@ -0,0 +1,115 @@ +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 = { + [']f'] = { query = '@call.outer', desc = 'Next function call start' }, + [']m'] = { query = '@function.outer', desc = 'Next method/function def start' }, + [']c'] = { query = '@class.outer', desc = 'Next class start' }, + [']i'] = { query = '@conditional.outer', desc = 'Next conditional start' }, + [']l'] = { query = '@loop.outer', desc = 'Next loop start' }, + + -- You can pass a query group to use query from `queries//.scm file in your runtime path. + -- Below example nvim-treesitter's `locals.scm` and `folds.scm`. They also provide highlights.scm and indent.scm. + [']S'] = { query = '@scope', query_group = 'locals', desc = 'Next scope' }, + [']z'] = { query = '@fold', query_group = 'folds', desc = 'Next fold' }, + }, + goto_next_end = { + [']F'] = { query = '@call.outer', desc = 'Next function call end' }, + [']M'] = { query = '@function.outer', desc = 'Next method/function def end' }, + [']C'] = { query = '@class.outer', desc = 'Next class end' }, + [']I'] = { query = '@conditional.outer', desc = 'Next conditional end' }, + [']L'] = { query = '@loop.outer', desc = 'Next loop end' }, + }, + goto_previous_start = { + ['[f'] = { query = '@call.outer', desc = 'Prev function call start' }, + ['[m'] = { query = '@function.outer', desc = 'Prev method/function def start' }, + ['[c'] = { query = '@class.outer', desc = 'Prev class start' }, + ['[i'] = { query = '@conditional.outer', desc = 'Prev conditional start' }, + ['[l'] = { query = '@loop.outer', desc = 'Prev loop start' }, + }, + goto_previous_end = { + ['[F'] = { query = '@call.outer', desc = 'Prev function call end' }, + ['[M'] = { query = '@function.outer', desc = 'Prev method/function def end' }, + ['[C'] = { query = '@class.outer', desc = 'Prev class end' }, + ['[I'] = { query = '@conditional.outer', desc = 'Prev conditional end' }, + ['[L'] = { query = '@loop.outer', desc = 'Prev loop 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..28efb08 --- /dev/null +++ b/lua/plugins/lang/treesitter.lua @@ -0,0 +1,78 @@ +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 = {}, + 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/plugins/lazy.lua b/lua/plugins/lazy.lua new file mode 100644 index 0000000..db4a45b --- /dev/null +++ b/lua/plugins/lazy.lua @@ -0,0 +1,109 @@ +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + 'git', + 'clone', + '--filter=blob:none', + '--single-branch', + 'https://github.com/folke/lazy.nvim.git', + lazypath, + }) +end +vim.opt.runtimepath:prepend(lazypath) + +local status_ok, lazy = pcall(require, 'lazy') +if not status_ok then + return +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/plugins/lock.json', + concurrency = 8, + dev = { path = '~/Projects/GitHub/', patterns = {}, fallback = false }, + install = { missing = true, colorscheme = { 'dracula' } }, + + git = { + log = { '--since=3 days ago' }, + timeout = 120, + url_format = 'https://github.com/%s.git', + filter = true, + }, + + ui = { + size = { width = 0.9, height = 0.8 }, + wrap = true, + border = 'rounded', + icons = { + cmd = icons.ui.Terminal, + config = icons.ui.Gear, + event = icons.ui.Electric, + ft = icons.documents.File, + init = icons.ui.Rocket, + import = icons.documents.Import, + keys = icons.ui.Keyboard, + lazy = icons.ui.Sleep, + loaded = icons.ui.CircleSmall, + not_loaded = icons.ui.CircleSmallEmpty, + plugin = icons.ui.Package, + runtime = icons.ui.NeoVim, + source = icons.ui.Code, + start = icons.ui.Play, + task = icons.ui.Check, + list = { + icons.ui.CircleSmall, + icons.ui.Arrow, + icons.ui.Star, + icons.ui.Minus, + }, + }, + browser = nil, + throttle = 20, + custom_keys = { + ['l'] = function(plugin) + require('lazy.util').float_term({ 'lazygit', 'log' }, { + cwd = plugin.dir, + }) + end, + + ['t'] = function(plugin) + require('lazy.util').float_term(nil, { + cwd = plugin.dir, + }) + end, + }, + }, + + diff = { cmd = 'git' }, + checker = { enabled = false, concurrency = nil, notify = true, frequency = 3600 }, + change_detection = { enabled = true, notify = true }, + performance = { + cache = { enabled = true }, + reset_packpath = true, + rtp = { + reset = true, + paths = {}, + disabled_plugins = { + 'gzip', + 'tarPlugin', + 'zipPlugin', + 'tohtml', + -- 'tutor', + -- 'matchit', + -- 'matchparen', + -- 'netrwPlugin', + }, + }, + }, + readme = { + root = vim.fn.stdpath('state') .. '/lazy/readme', + files = { 'README.md', 'lua/**/README.md' }, + skip_if_doc_exists = true, + }, + state = vim.fn.stdpath('state') .. '/lazy/state.json', +}) diff --git a/lua/plugins/list.lua b/lua/plugins/list.lua new file mode 100644 index 0000000..9854d55 --- /dev/null +++ b/lua/plugins/list.lua @@ -0,0 +1,539 @@ +local function load_config(package) + return function() + require('plugins.' .. package) + end +end + +local plugins = { + -- UI + { + 'Mofiqul/dracula.nvim', + config = load_config('ui.dracula'), + lazy = false, + priority = 1000, + }, + { + 'nvim-lualine/lualine.nvim', + config = load_config('ui.lualine'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'lukas-reineke/indent-blankline.nvim', + config = load_config('ui.indentline'), + main = 'ibl', + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'HiPhish/rainbow-delimiters.nvim', + config = load_config('ui.rainbow'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'rcarriga/nvim-notify', + config = load_config('ui.notify'), + event = 'VeryLazy', + cmd = 'Notifications', + }, + { + 'stevearc/dressing.nvim', + config = load_config('ui.dressing'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'nvimdev/dashboard-nvim', + config = load_config('ui.dashboard'), + -- Only load when no arguments + event = function() + if vim.fn.argc() == 0 then + return 'VimEnter' + end + end, + cmd = 'Dashboard', + }, + { + 'gelguy/wilder.nvim', + + build = function() + vim.cmd([[silent UpdateRemotePlugins]]) + end, + config = load_config('ui.wilder'), + keys = { ':', '/', '?' }, + }, + { + 'folke/zen-mode.nvim', + dependencies = { + 'folke/twilight.nvim', + config = load_config('ui.twilight'), + }, + config = load_config('ui.zen-mode'), + cmd = { 'ZenMode', 'Twilight' }, + }, + + -- 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', + 'haydenmeade/neotest-jest', + }, + 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.comment', + version = '*', + dependencies = 'JoosepAlviste/nvim-ts-context-commentstring', + config = load_config('lang.comment'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'echasnovski/mini.surround', + version = '*', + config = load_config('lang.surround'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'echasnovski/mini.ai', + version = '*', + config = load_config('lang.ai'), + event = { 'BufReadPre', '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 = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'ckolkey/ts-node-action', + dependencies = { 'nvim-treesitter' }, + }, + -- LSP + { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason-lspconfig.nvim', + 'hrsh7th/cmp-nvim-lsp', + }, + config = load_config('lang.lspconfig'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'folke/neodev.nvim', + ft = { 'lua', 'vim' }, + config = load_config('lang.neodev'), + }, + { + 'nvimdev/lspsaga.nvim', + config = load_config('lang.lspsaga'), + event = 'LspAttach', + }, + { + 'Maan2003/lsp_lines.nvim', + config = load_config('lang.lsp-lines'), + 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 = { 'BufReadPre', 'BufNewFile' }, + }, + + -- Completion + { + 'hrsh7th/nvim-cmp', + dependencies = { + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-nvim-lua', + 'L3MON4D3/LuaSnip', + 'rafamadriz/friendly-snippets', + 'saadparwaiz1/cmp_luasnip', + }, + config = load_config('lang.cmp'), + event = 'InsertEnter', + }, + { + 'Exafunction/codeium.vim', + event = 'BufEnter', + cmd = 'Codeium', + build = 'Codeium Auth:', + dependencies = { + 'nvim-lua/plenary.nvim', + 'hrsh7th/nvim-cmp', + }, + }, + -- Tools + { + 'nvim-tree/nvim-tree.lua', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = load_config('tools.nvim-tree'), + cmd = 'NvimTreeToggle', + }, + { + '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', + }, + { + 'r', + mode = 'o', + function() + require('flash').remote() + end, + desc = 'Remote Flash', + }, + { + 'R', + mode = { 'o', 'x' }, + function() + require('flash').treesitter_search() + end, + desc = 'Treesitter Search', + }, + { + '', + mode = { 'c' }, + function() + require('flash').toggle() + end, + desc = 'Toggle Flash Search', + }, + }, + }, + { + '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 = { 'BufReadPre', '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' }, + }, + { + '2kabhishek/tdo.nvim', + dependencies = 'nvim-telescope/telescope.nvim', + cmd = { 'Tdo', 'TdoEntry', 'TdoNote', 'TdoTodos', 'TdoToggle', 'TdoFind', 'TdoFiles' }, + keys = { '[t', ']t' }, + }, + { + '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, + }, + { + 'stevearc/oil.nvim', + opts = {}, + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = load_config('tools.oil'), + }, + { + 'aurum77/live-server.nvim', + build = function() + require("live_server.util").install() + end, + cmd = { "LiveServer", "LiveServerStart", "LiveServerStop" }, + keys = { + { "", ft = "html", "LiveServer", desc = "Live Server" }, + { "", ft = "html", "LiveServerStop", desc = "Live Server Stop" }, + }, + }, + { + 'Zeioth/compiler.nvim', + cmd = { "CompilerOpen", "CompilerToggleResults", "CompilerRedo" }, + dependencies = { "stevearc/overseer.nvim" }, + opts = {}, + keys = { + { "", "CompilerOpen", desc = "Open Compiler" }, + { "", function() vim.cmd("CompilerStop") vim.cmd("CompilerRedo") end, desc = "Redo Compiler" }, + { "", "CompilerToggleResults", desc = "Toggle Compiler Results" }, + }, + }, + { + 'stevearc/overseer.nvim', + cmd = { + "OverseerOpen", + "OverseerClose", + "OverseerToggle", + "OverseerSaveBundle", + "OverseerLoadBundle", + "OverseerDeleteBundle", + "OverseerRunCmd", + "OverseerRun", + "OverseerInfo", + "OverseerBuild", + "OverseerQuickAction", + "OverseerTaskAction ", + "OverseerClearCache", + }, + opts = { + task_list = { + direction = "bottom", + min_height = 15, + max_height = 15, + default_detail = 1, + }, + }, + }, + + -- Telescope + { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'make', + }, + 'nvim-telescope/telescope-file-browser.nvim', + 'nvim-telescope/telescope-symbols.nvim', + 'molecule-man/telescope-menufacture', + 'debugloop/telescope-undo.nvim', + }, + config = load_config('tools.telescope'), + cmd = 'Telescope', + }, + { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + config = load_config('tools.harpoon'), + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + '2kabhishek/nerdy.nvim', + dependencies = { 'stevearc/dressing.nvim' }, + cmd = 'Nerdy', + }, + + -- Git + { + '2kabhishek/co-author.nvim', + dependencies = { 'stevearc/dressing.nvim' }, + cmd = 'CoAuthor', + }, + { + 'ruifm/gitlinker.nvim', + config = load_config('tools.gitlinker'), + keys = 'gy', + }, + { + 'lewis6991/gitsigns.nvim', + config = load_config('tools.gitsigns'), + cmd = 'Gitsigns', + event = { 'BufReadPre', 'BufNewFile' }, + }, + { + 'tpope/vim-fugitive', + cmd = 'Git', + }, +} + +local ts_parsers = { + 'bash', + 'css', + 'dart', + 'elixir', + 'gitcommit', + 'go', + 'html', + 'java', + 'javascript', + 'json', + 'lua', + 'markdown', + 'markdown_inline', -- markdown code blocks + 'python', + 'ruby', + 'rust', + '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, 'tsserver') +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', 'x', 'o' }, + 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('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_lsp') + table.insert(lsp_servers, 'pylsp') +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 = ts_parsers, +} diff --git a/lua/plugins/lock.json b/lua/plugins/lock.json new file mode 100644 index 0000000..564671c --- /dev/null +++ b/lua/plugins/lock.json @@ -0,0 +1,82 @@ +{ + "LuaSnip": { "branch": "master", "commit": "8f3d3465ba5c7ade0a8adb41eca5736f291a3fa8" }, + "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, + "ccc.nvim": { "branch": "main", "commit": "1283eef5494c092a047baa34ed3e667f3cb2715e" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "co-author.nvim": { "branch": "main", "commit": "62fbb6d6a58339c968bcea92d0f097f4ea1efaa5" }, + "codeium.vim": { "branch": "main", "commit": "31dd2962c81759be007895db6ce089feec397c86" }, + "compiler.nvim": { "branch": "main", "commit": "cb14acd32ba9ea09d01bbe3493aefdc59b68965c" }, + "dashboard-nvim": { "branch": "master", "commit": "6d06924b562de6f0bb136edf1bf549afbf6b7d00" }, + "dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" }, + "dressing.nvim": { "branch": "master", "commit": "5162edb1442a729a885c45455a07e9a89058be2f" }, + "flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, + "friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" }, + "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, + "gitsigns.nvim": { "branch": "main", "commit": "035da036e68e509ed158414416c827d022d914bd" }, + "hardtime.nvim": { "branch": "main", "commit": "eaf4bc31b86419c26ad7b3a142dd36ca545ca2e4" }, + "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, + "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, + "lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" }, + "live-server.nvim": { "branch": "main", "commit": "f6f00a3f541251f0320910bb0d03c4ae14ee6d10" }, + "lsp_lines.nvim": { "branch": "main", "commit": "dbfd8e96ec2696e1ceedcd23fd70e842256e3dea" }, + "lspsaga.nvim": { "branch": "main", "commit": "f20985499cd8ff0fbbfe8e7c770428ef764fc3be" }, + "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "273fdde8ac5e51f3a223ba70980e52bbc09d9f6f" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, + "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" }, + "mini.ai": { "branch": "main", "commit": "ee9446a17c160aba6a04ff22097389c41872c878" }, + "mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, + "mini.surround": { "branch": "main", "commit": "a1b590cc3b676512de507328d6bbab5e43794720" }, + "neodev.nvim": { "branch": "main", "commit": "ce9a2e8eaba5649b553529c5498acb43a6c317cd" }, + "neotest": { "branch": "master", "commit": "f03a78cef74db5638e4312e18b767294a90de8da" }, + "neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" }, + "neotest-rspec": { "branch": "main", "commit": "c1c3f36e1b1a23698534e6326e90876f87b773a4" }, + "nerdy.nvim": { "branch": "main", "commit": "1ad36242f40a8fd95ae5711258540a07a5dabb51" }, + "none-ls.nvim": { "branch": "main", "commit": "e22c380008f36dc8c63b15d5c0f6c2cae46348af" }, + "nui.nvim": { "branch": "main", "commit": "cbd2668414331c10039278f558630ed19b93e69b" }, + "nvim-autopairs": { "branch": "master", "commit": "4f41e5940bc0443fdbe5f995e2a596847215cd2a" }, + "nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" }, + "nvim-dap": { "branch": "master", "commit": "6ae8a14828b0f3bff1721a35a1dfd604b6a933bb" }, + "nvim-dap-ui": { "branch": "master", "commit": "edfa93f60b189e5952c016eee262d0685d838450" }, + "nvim-lspconfig": { "branch": "master", "commit": "2a1999b817050a977c33a5f0ad0cecd9f0e75a6e" }, + "nvim-nio": { "branch": "master", "commit": "5800f585def265d52f1d8848133217c800bcb25d" }, + "nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" }, + "nvim-spectre": { "branch": "master", "commit": "026394a8458d62c6b7b305c076ce675420dbaa4c" }, + "nvim-spider": { "branch": "main", "commit": "828444de406bc7df3b30c8e000ce6f54f0754499" }, + "nvim-tree.lua": { "branch": "master", "commit": "5a18b9827491aa1aea710bc9b85c6b63ed0dad14" }, + "nvim-treesitter": { "branch": "master", "commit": "3ef8d25df2d8eca6f15a6889cb2bc9d4c6101096" }, + "nvim-treesitter-endwise": { "branch": "master", "commit": "156d5782b3a68845f824156e45fc5bb038211e7b" }, + "nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "23b820146956b3b681c19e10d3a8bc0cbd9a1d4c" }, + "nvim-treesitter-textsubjects": { "branch": "master", "commit": "9f9a6b307fb122f13708f78483222abd43b7bb3a" }, + "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "a6382f744f584bbf71d0a563af789af7190aabda" }, + "nvim-web-devicons": { "branch": "master", "commit": "beb6367ab8496c9e43f22e0252735fdadae1872d" }, + "oil.nvim": { "branch": "master", "commit": "f3a31eba24587bc038592103d8f7e64648292115" }, + "overseer.nvim": { "branch": "master", "commit": "89942ad366c8a9bb93f82411de17dc7c644b4e3b" }, + "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "7ef0766b5cd2f5cdf4fcb08886f0a2ebf65981fa" }, + "refactoring.nvim": { "branch": "master", "commit": "d2786877c91aa409c824f27b4ce8a9f560dda60a" }, + "sniprun": { "branch": "master", "commit": "97daa506e2faa3939e0491642103635f9d22cd04" }, + "tabout.nvim": { "branch": "master", "commit": "c442ae7788c30dbd41d259c51df4046cb8269a96" }, + "tdo.nvim": { "branch": "main", "commit": "678d6fdaf9df964cdc516c8a716d5c4c27d79cdc" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "4d5fd21bae12ee6e9a79232e1c377f43c419d0c5" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, + "telescope-menufacture": { "branch": "main", "commit": "79376f887f589a4240267383e8abc0a31861325a" }, + "telescope-symbols.nvim": { "branch": "master", "commit": "a6d0127a53d39b9fc2af75bd169d288166118aec" }, + "telescope-undo.nvim": { "branch": "main", "commit": "d19e2edc8b18d03283bd91f67310ac300ad003ce" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" }, + "termim.nvim": { "branch": "main", "commit": "2dba526e99c32a65db9599cfa90e85db13724a44" }, + "ts-node-action": { "branch": "master", "commit": "e37eb458378de5d994df459a53711b2546abef0f" }, + "twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" }, + "vim-fugitive": { "branch": "master", "commit": "dac8e5c2d85926df92672bf2afb4fc48656d96c7" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, + "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }, + "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } +} \ No newline at end of file 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/tools/flash.lua b/lua/plugins/tools/flash.lua new file mode 100644 index 0000000..7b2a988 --- /dev/null +++ b/lua/plugins/tools/flash.lua @@ -0,0 +1,15 @@ +local flash = require('flash') +local icons = require('lib.icons') + +flash.setup({ + prompt = { + enabled = true, + prefix = { { icons.ui.Separator .. icons.ui.Rocket .. icons.ui.ChevronRight .. ' ', 'FlashPromptIcon' } }, + win_config = { relative = 'editor', width = 1, height = 1, row = 1, col = 0, zindex = 1000 }, + }, + modes = { + char = { + jump_labels = false, + }, + }, +}) diff --git a/lua/plugins/tools/gitlinker.lua b/lua/plugins/tools/gitlinker.lua new file mode 100644 index 0000000..a3ca9d8 --- /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 = 'gy', +}) diff --git a/lua/plugins/tools/gitsigns.lua b/lua/plugins/tools/gitsigns.lua new file mode 100644 index 0000000..b0ed801 --- /dev/null +++ b/lua/plugins/tools/gitsigns.lua @@ -0,0 +1,93 @@ +local gitsigns = require('gitsigns') + +gitsigns.setup({ + signs = { + add = { + hl = 'GitSignsAdd', + text = '│', + numhl = 'GitSignsAddNr', + linehl = 'GitSignsAddLn', + }, + change = { + hl = 'GitSignsChange', + text = '│', + numhl = 'GitSignsChangeNr', + linehl = 'GitSignsChangeLn', + }, + delete = { + hl = 'GitSignsDelete', + text = '_', + numhl = 'GitSignsDeleteNr', + linehl = 'GitSignsDeleteLn', + }, + topdelete = { + hl = 'GitSignsDelete', + text = '‾', + numhl = 'GitSignsDeleteNr', + linehl = 'GitSignsDeleteLn', + }, + changedelete = { + hl = 'GitSignsChange', + text = '~', + numhl = 'GitSignsChangeNr', + linehl = 'GitSignsChangeLn', + }, + }, + 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 = 'single', style = 'minimal', relative = 'cursor', row = 0, col = 1 }, + yadm = { enable = false }, + 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', ']c', function() + if vim.wo.diff then + return ']c' + end + vim.schedule(function() + gs.next_hunk() + end) + return '' + end, { expr = true, desc = 'Next Change' }) + + map('n', '[c', function() + if vim.wo.diff then + return '[c' + end + vim.schedule(function() + gs.prev_hunk() + end) + return '' + end, { expr = true, desc = 'Previous Change' }) + + map({ 'v' }, 'ga', ':Gitsigns stage_hunk', { desc = 'Stage Hunk' }) + map({ 'v' }, 'gr', ':Gitsigns reset_hunk', { desc = 'Reset Hunk' }) + map('n', 'gB', function() + gs.blame_line({ full = true }) + end, { desc = 'Blame With Preview' }) + + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk') + end, +}) diff --git a/lua/plugins/tools/harpoon.lua b/lua/plugins/tools/harpoon.lua new file mode 100644 index 0000000..9322a5f --- /dev/null +++ b/lua/plugins/tools/harpoon.lua @@ -0,0 +1,51 @@ +local harpoon = require('harpoon') +harpoon:setup({}) + +local conf = require('telescope.config').values +local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require('telescope.pickers') + .new({}, { + prompt_title = 'Harpoon', + finder = require('telescope.finders').new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }) + :find() +end + +vim.keymap.set('n', 'ha', function() + harpoon:list():append() +end, { desc = 'Add Mark' }) +vim.keymap.set('n', 'hh', function() + toggle_telescope(harpoon:list()) +end, { desc = 'Telescope Marks' }) +vim.keymap.set('n', 'hm', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) +end, { desc = 'Open UI' }) + +vim.keymap.set('n', '[h', function() + harpoon:list():prev() +end, { desc = 'Prev Mark' }) +vim.keymap.set('n', ']h', function() + harpoon:list():next() +end, { desc = 'Next Mark' }) + +vim.keymap.set('n', 'hk', function() + harpoon:list():prev() +end, { desc = 'Prev Mark' }) +vim.keymap.set('n', 'hj', function() + harpoon:list():next() +end, { desc = 'Next Mark' }) + +for i = 1, 9 do + vim.keymap.set('n', 'h' .. i, function() + harpoon:list():select(i) + end, { desc = 'Mark ' .. i }) +end 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..605ade2 --- /dev/null +++ b/lua/plugins/tools/nvim-tree.lua @@ -0,0 +1,92 @@ +local nvim_tree = require('nvim-tree') + +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 + +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 = 40, + side = 'left', + adaptive_size = true, + number = false, + relativenumber = false, + }, +}) diff --git a/lua/plugins/tools/oil.lua b/lua/plugins/tools/oil.lua new file mode 100644 index 0000000..a058fd6 --- /dev/null +++ b/lua/plugins/tools/oil.lua @@ -0,0 +1,24 @@ + require("oil").setup({ + use_default_keymaps = false, + keymaps = { + ["q"] = "actions.close", + ["g?"] = "actions.show_help", + [""] = "actions.select", + [""] = "actions.select_split", + [""] = "actions.select_vsplit", -- this is used to navigate left + [""] = "actions.select_tab", + [""] = "actions.preview", + [""] = "actions.close", + [""] = "actions.refresh", + ["-"] = "actions.parent", + ["_"] = "actions.open_cwd", + ["`"] = "actions.cd", + ["~"] = "actions.tcd", + ["gs"] = "actions.change_sort", + ["gx"] = "actions.open_external", + ["h"] = "actions.toggle_hidden", + }, + view_options = { + show_hidden = false, + }, + }) diff --git a/lua/plugins/tools/spectre.lua b/lua/plugins/tools/spectre.lua new file mode 100644 index 0000000..6808f38 --- /dev/null +++ b/lua/plugins/tools/spectre.lua @@ -0,0 +1,125 @@ +local spectre = require('spectre') + +spectre.setup({ + color_devicons = true, + highlight = { + ui = 'String', + search = 'DiffChange', + replace = 'DiffDelete', + }, + mapping = { + ['toggle_line'] = { + map = 't', + cmd = "lua require('spectre').toggle_line()", + desc = 'toggle current item', + }, + ['enter_file'] = { + map = '', + cmd = "lua require('spectre.actions').select_entry()", + desc = 'goto current file', + }, + ['send_to_qf'] = { + map = 'Q', + cmd = "lua require('spectre.actions').send_to_qf()", + desc = 'send all item to quickfix', + }, + ['replace_cmd'] = { + map = 'c', + cmd = "lua require('spectre.actions').replace_cmd()", + desc = 'input replace vim command', + }, + ['show_option_menu'] = { + map = 'o', + cmd = "lua require('spectre').show_options()", + desc = 'show option', + }, + ['run_replace'] = { + map = 'R', + cmd = "lua require('spectre.actions').run_replace()", + desc = 'replace all', + }, + ['change_view_mode'] = { + map = 'm', + cmd = "lua require('spectre').change_view()", + desc = 'change result view mode', + }, + ['toggle_ignore_case'] = { + map = 'I', + cmd = "lua require('spectre').change_options('ignore-case')", + desc = 'toggle ignore case', + }, + ['toggle_ignore_hidden'] = { + map = 'H', + cmd = "lua require('spectre').change_options('hidden')", + desc = 'toggle search hidden', + }, + }, + find_engine = { + ['rg'] = { + cmd = 'rg', + args = { + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + }, + options = { + ['ignore-case'] = { + value = '--ignore-case', + icon = '[I]', + desc = 'ignore case', + }, + ['hidden'] = { + value = '--hidden', + desc = 'hidden file', + icon = '[H]', + }, + }, + }, + ['ag'] = { + cmd = 'ag', + args = { + '--vimgrep', + '-s', + }, + options = { + ['ignore-case'] = { + value = '-i', + icon = '[I]', + desc = 'ignore case', + }, + ['hidden'] = { + value = '--hidden', + desc = 'hidden file', + icon = '[H]', + }, + }, + }, + }, + replace_engine = { + ['sed'] = { + cmd = 'sed', + args = nil, + }, + options = { + ['ignore-case'] = { + value = '--ignore-case', + icon = '[I]', + desc = 'ignore case', + }, + }, + }, + default = { + find = { + cmd = 'rg', + options = { 'ignore-case' }, + }, + replace = { + cmd = 'sed', + }, + }, + replace_vim_cmd = 'cdo', + is_open_target_win = true, + is_insert_mode = true, +}) 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-multiopen.lua b/lua/plugins/tools/telescope-multiopen.lua new file mode 100644 index 0000000..44d2a13 --- /dev/null +++ b/lua/plugins/tools/telescope-multiopen.lua @@ -0,0 +1,67 @@ +local actions = require('telescope.actions') +local action_state = require('telescope.actions.state') +local transform_mod = require('telescope.actions.mt').transform_mod + +local function multiopen(prompt_bufnr, method) + local cmd_map = { + vertical = 'vsplit', + horizontal = 'split', + tab = 'tabe', + default = 'edit', + } + local picker = action_state.get_current_picker(prompt_bufnr) + local multi_selection = picker:get_multi_selection() + + if #multi_selection > 0 then + require('telescope.pickers').on_close_prompt(prompt_bufnr) + pcall(vim.api.nvim_set_current_win, picker.original_win_id) + + for i, entry in ipairs(multi_selection) do + local cmd = i == 1 and 'edit' or cmd_map[method] + vim.cmd(string.format('%s %s', cmd, entry.value)) + end + else + actions['select_' .. method](prompt_bufnr) + end +end + +local custom_actions = transform_mod({ + multi_selection_open_vertical = function(prompt_bufnr) + multiopen(prompt_bufnr, 'vertical') + end, + multi_selection_open_horizontal = function(prompt_bufnr) + multiopen(prompt_bufnr, 'horizontal') + end, + multi_selection_open_tab = function(prompt_bufnr) + multiopen(prompt_bufnr, 'tab') + end, + multi_selection_open = function(prompt_bufnr) + multiopen(prompt_bufnr, 'default') + end, +}) + +local function stopinsert(callback) + return function(prompt_bufnr) + vim.cmd.stopinsert() + vim.schedule(function() + callback(prompt_bufnr) + end) + end +end + +local multi_open_mappings = { + i = { + [''] = stopinsert(custom_actions.multi_selection_open_vertical), + [''] = stopinsert(custom_actions.multi_selection_open_horizontal), + [''] = stopinsert(custom_actions.multi_selection_open_tab), + [''] = stopinsert(custom_actions.multi_selection_open), + }, + n = { + [''] = custom_actions.multi_selection_open_vertical, + [''] = custom_actions.multi_selection_open_horizontal, + [''] = custom_actions.multi_selection_open_tab, + [''] = custom_actions.multi_selection_open, + }, +} + +return multi_open_mappings diff --git a/lua/plugins/tools/telescope.lua b/lua/plugins/tools/telescope.lua new file mode 100644 index 0000000..96d7107 --- /dev/null +++ b/lua/plugins/tools/telescope.lua @@ -0,0 +1,163 @@ +local telescope = require('telescope') +local actions = require('telescope.actions') +local multi_open_mappings = require('plugins.tools.telescope-multiopen') +local icons = require('lib.icons') + +local function flash(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 + +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' }, + 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, + + [''] = actions.select_default, + [''] = 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, + [''] = actions.select_default, + [''] = 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, + }, + }, + }, + pickers = { + find_files = { mappings = multi_open_mappings }, + git_files = { mappings = multi_open_mappings }, + oldfiles = { mappings = multi_open_mappings }, + }, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = 'smart_case', + }, + undo = { + use_delta = true, + use_custom_command = nil, + side_by_side = true, + diff_context_lines = vim.o.scrolloff, + entry_format = 'state #$ID, $STAT, $TIME', + -- time_format = '%d %b %H:%M', + mappings = { + i = { + [''] = require('telescope-undo.actions').yank_additions, + [''] = require('telescope-undo.actions').yank_deletions, + [''] = require('telescope-undo.actions').restore, + }, + }, + }, + menufacture = { mappings = { main_menu = { [{ 'i', 'n' }] = '' } } }, + }, +}) + +require('telescope').load_extension('fzf') +require('telescope').load_extension('menufacture') +require('telescope').load_extension('undo') +require('telescope').load_extension('harpoon') +require('telescope').load_extension('notify') +require('telescope').load_extension('refactoring') +require('telescope').load_extension('file_browser') diff --git a/lua/plugins/tools/which-key.lua b/lua/plugins/tools/which-key.lua new file mode 100644 index 0000000..9d77e88 --- /dev/null +++ b/lua/plugins/tools/which-key.lua @@ -0,0 +1,459 @@ +local which_key = require('which-key') +local icons = require('lib.icons') + +local setup = { + plugins = { + marks = true, + registers = true, + spelling = { + enabled = true, + suggestions = 30, + }, + presets = { + operators = true, + motions = true, + text_objects = true, + windows = true, + nav = true, + z = true, + g = true, + }, + }, + key_labels = { + [''] = icons.ui.Rocket, + [''] = '', + [''] = '', + }, + icons = { + breadcrumb = icons.ui.ArrowOpen, + separator = icons.ui.Arrow, + group = '', + }, + popup_mappings = { + scroll_down = '', + scroll_up = '', + }, + window = { + border = 'shadow', + position = 'bottom', + margin = { 0, 0, 0, 0 }, + padding = { 1, 2, 1, 2 }, + winblend = 10, + }, + layout = { + height = { min = 4, max = 24 }, + width = { min = 20, max = 50 }, + spacing = 3, + align = 'center', + }, + ignore_missing = false, + hidden = { '', '', '', '', '^:', '^ ', '^call ', '^lua ' }, + show_help = true, + show_keys = true, + triggers = 'auto', + triggers_nowait = { + -- marks + '`', + "'", + 'g`', + "g'", + -- registers + '"', + '', + -- spelling + 'z=', + }, + triggers_blacklist = { + i = { 'j', 'j' }, + v = { 'j', 'j' }, + }, +} + +local i = { + [' '] = 'Whitespace', + ['"'] = 'Balanced "', + ["'"] = "Balanced '", + ['`'] = 'Balanced `', + ['('] = 'Balanced (', + [')'] = 'Balanced ) including white-space', + ['>'] = 'Balanced > including white-space', + [''] = 'Balanced <', + [']'] = 'Balanced ] including white-space', + ['['] = 'Balanced [', + ['}'] = 'Balanced } including white-space', + ['{'] = 'Balanced {', + ['?'] = 'User Prompt', + _ = 'Underscore', + a = 'Argument', + b = 'Balanced ), ], }', + c = 'Class', + f = 'Function', + o = 'Block, conditional, loop', + q = 'Quote `, ", \'', + t = 'Tag', +} + +local a = vim.deepcopy(i) +for k, v in pairs(a) do + a[k] = v:gsub(' including.*', '') +end + +local ic = vim.deepcopy(i) +local ac = vim.deepcopy(a) + +for key, name in pairs({ n = 'Next', l = 'Last' }) do + i[key] = vim.tbl_extend('force', { name = 'Inside ' .. name .. ' textobject' }, ic) + a[key] = vim.tbl_extend('force', { name = 'Around ' .. name .. ' textobject' }, ac) +end + +local opts = { + mode = 'n', + prefix = '', + buffer = nil, + silent = true, + noremap = true, + nowait = true, +} + +local mappings = { + [','] = { 'b#', icons.ui.History .. 'Recent' }, + q = { 'q', icons.ui.Close .. 'Quit' }, + Q = { 'qa!', icons.ui.Power .. 'Force Quit!' }, + w = { 'w', icons.ui.Save .. 'Save' }, + x = { 'x', icons.ui.Pencil .. 'Write and Quit' }, + c = { + name = icons.ui.NeoVim .. 'Config', + c = { 'CccConvert', 'Convert Color' }, + d = { 'RootDir', 'Root Directory' }, + e = { 'e $MYVIMRC', 'Edit Config' }, + f = { 'lua vim.lsp.buf.format({async = true})', 'Format File' }, + F = { 'retab', 'Fix Tabs' }, + i = { vim.show_pos, 'Inspect Position' }, + l = { ':g/^\\s*$/d', 'Clean Empty Lines' }, + n = { 'set relativenumber!', 'Relative Numbers' }, + p = { 'CccPick', 'Pick Color' }, + r = { 'Telescope reloader', 'Reload Module' }, + R = { 'ReloadConfig', 'Reload Configs' }, + }, + b = { + name = icons.ui.Bug .. 'Debug', + b = { 'DapToggleBreakpoint', 'Breakpoint' }, + c = { 'DapContinue', 'Continue' }, + i = { 'DapStepInto', 'Into' }, + l = { "lua require'dap'.run_last()", 'Last' }, + o = { 'DapStepOver', 'Over' }, + O = { 'DapStepOut', 'Out' }, + r = { 'DapToggleRepl', 'Repl' }, + R = { 'DapRestartFrame', 'Restart Frame' }, + t = { 'DapUIToggle', 'Debugger' }, + x = { 'DapTerminate', 'Exit' }, + }, + d = { + name = icons.ui.Database .. 'Database', + b = { 'DBToggle', 'DB Explorer' }, + j = { 'lua require("dbee").next()', 'DB Next' }, + k = { 'lua require("dbee").prev()', 'DB Prev' }, + s = { 'lua require("dbee").store("csv", "buffer", { extra_arg = 0 })', 'To CSV' }, + S = { 'lua require("dbee").store("json", "buffer", { extra_arg = 0 })', 'To JSON' }, + t = { 'lua require("dbee").store("table", "buffer", { extra_arg = 0 })', 'To Table' }, + }, + E = { + name = icons.documents.OpenFolder .. 'Explorer', + e = { 'NvimTreeToggle', 'File Explorer' }, + f = { 'NvimTreeFindFileToggle', 'Toggle file explorer on current file' }, + r = { 'NvimTreeRefresh', 'Refresh file explorer' }, + }, + f = { + name = icons.ui.Telescope .. 'Find', + b = { 'Telescope buffers', 'Buffers' }, + B = { 'Telescope git_branches', 'Checkout branch' }, + a = { 'lua require("telescope").extensions.menufacture.find_files()', 'All Files' }, + c = { 'Telescope git_bcommits', 'File Commits' }, + C = { 'Telescope git_commits', 'Git Commits' }, + d = { 'Telescope file_browser', 'Browse Folders' }, + e = { 'Oil', 'Dir Editor' }, + f = { 'lua require("telescope").extensions.menufacture.git_files()', 'Find files' }, + g = { 'lua require("telescope").extensions.menufacture.live_grep()', 'Find Text' }, + G = { 'lua require("telescope").extensions.menufacture.grep_string()', 'Find Word' }, + h = { 'Telescope help_tags', 'Help' }, + H = { 'Telescope man_pages', 'Man Pages' }, + k = { 'Telescope commands', 'Commands' }, + K = { 'Telescope keymaps', 'Keymaps' }, + l = { 'Telescope resume', 'Last Search' }, + L = { 'Telescope loclist', 'Location List' }, + n = { 'enew', 'New File' }, + r = { 'Telescope oldfiles', 'Recent Files' }, + p = { 'Telescope', 'Panel' }, + q = { 'Telescope quickfix', 'Quickfix' }, + s = { 'Telescope live_grep grep_open_files=true', 'Find in Open Files' }, + u = { 'Telescope undo', 'Undo History' }, + ['"'] = { 'Telescope registers', 'Registers' }, + ['.'] = { 'Telescope symbols', 'Emojis' }, + [','] = { 'Nerdy', 'Nerd Glyphs' }, + }, + g = { + name = icons.git.Octoface .. 'Git', + a = { 'Gitsigns stage_hunk', 'Stage Hunk' }, + A = { 'Gitsigns stage_buffer', 'Stage Buffer' }, + b = { 'Gitsigns blame_line', 'Blame' }, + c = { 'Git', 'Commit' }, + C = { 'CoAuthor', 'Add Co Author' }, + d = { 'Gitsigns preview_hunk', 'Preview Hunk' }, + D = { 'Gitsigns diffthis HEAD', 'Diff' }, + g = { 'Fterm lazygit', 'Lazygit' }, + j = { 'Gitsigns next_hunk', 'Next Hunk' }, + k = { 'Gitsigns prev_hunk', 'Prev Hunk' }, + r = { 'Gitsigns reset_hunk', 'Reset Hunk' }, + R = { 'Gitsigns reset_buffer', 'Reset Buffer' }, + s = { 'Telescope git_status', 'Changed files' }, + S = { 'Telescope git_stash', 'Stashed Changes' }, + t = { + name = 'Git Toggle', + b = { 'Gitsigns toggle_current_line_blame', 'Blame' }, + d = { 'Gitsigns toggle_deleted', 'Deleted' }, + l = { 'Gitsigns toggle_linehl', 'Line HL' }, + n = { 'Gitsigns toggle_numhl', 'Number HL' }, + s = { 'Gitsigns toggle_signs', 'Signs' }, + w = { 'Gitsigns toggle_word_diff', 'Word Diff' }, + }, + u = { 'Gitsigns undo_stage_hunk', 'Undo Stage Hunk' }, + v = { 'Gitsigns select_hunk', 'Select Hunk' }, + }, + h = { name = icons.ui.Bookmark .. 'Harpoon' }, + l = { + name = icons.ui.Gear .. 'LSP', + a = { 'Lspsaga code_action', 'Code Action' }, + d = { 'Lspsaga peek_definition', 'Peek Definition' }, + D = { 'Lspsaga goto_definition', 'Goto Definition' }, + f = { 'Lspsaga finder', 'Finder' }, + F = { 'Telescope lsp_references', 'References' }, + h = { 'Lspsaga hover_doc', 'Hover' }, + i = { 'Telescope diagnostics', 'Diagnostics' }, + I = { 'Lspsaga show_workspace_diagnostics', 'Workspace Diagnostics' }, + j = { 'Lspsaga diagnostic_jump_next', 'Next Diagnostic' }, + k = { 'Lspsaga diagnostic_jump_prev', 'Prev Diagnostic' }, + l = { "lua require('lsp_lines').toggle()", 'Toggle LSP Lines' }, + L = { 'LspInfo', 'LSP Info' }, + o = { 'Lspsaga outline', 'Outline' }, + p = { 'Telescope lsp_incoming_calls', 'Incoming Calls' }, + P = { 'Telescope lsp_outgoing_calls', 'Outgoing Calls' }, + r = { 'Lspsaga rename', 'Rename' }, + R = { 'Lspsaga project_replace', 'Replace' }, + s = { 'Telescope lsp_document_symbols', 'Document Symbols' }, + S = { 'Telescope lsp_dynamic_workspace_symbols', 'Workspace Symbols' }, + t = { 'Lspsaga peek_type_definition', 'Peek Type Definition' }, + T = { 'Lspsaga goto_type_definition', 'Goto Type Definition' }, + }, + m = { + name = icons.kind.Field .. 'Modes', + c = { 'CccHighlighterToggle', 'Highlight Colors' }, + d = { 'Dashboard', 'Dashboard' }, + h = { 'Hardtime toggle', 'Hardtime' }, + m = { 'MarkdownPreviewToggle', 'Markdown Preview' }, + n = { 'Telescope notify', 'Notifications' }, + r = { '%SnipRun', 'Run File' }, + s = { 'set spell!', 'Spellcheck' }, + z = { 'ZenMode', 'ZenMode' }, + Z = { 'Twilight', 'Twilight' }, + }, + n = { + name = icons.ui.Note .. 'Notes', + d = { 'Tdo', "Today's Todo" }, + e = { 'TdoEntry', "Today's Entry" }, + f = { 'TdoFiles', 'All Notes' }, + g = { 'TdoFind', 'Find Notes' }, + h = { 'Tdo -1', "Yesterday's Todo" }, + j = { "put =strftime('%a %d %b %r')", 'Insert Human Date' }, + J = { "put =strftime('%F')", 'Insert Date' }, + k = { "put =strftime('%r')", 'Insert Human Time' }, + K = { "put =strftime('%F-%H-%M')", 'Insert Time' }, + l = { 'Tdo 1', "Tomorrow's Todo" }, + n = { 'TdoNote', 'New Note' }, + s = { + 'lua require("tdo").run_with("commit " .. vim.fn.expand("%:p")) vim.notify("Committed!")', + 'Commit Note', + }, + t = { 'TdoTodos', 'Incomplete Todos' }, + x = { 'TdoToggle', 'Toggle Todo' }, + }, + p = { + name = icons.ui.Package .. 'Packages', + c = { 'Lazy check', 'Check' }, + d = { 'Lazy debug', 'Debug' }, + p = { 'Lazy', 'Plugins' }, + P = { 'Lazy profile', 'Profile' }, + m = { 'Mason', 'Mason' }, + i = { 'Lazy install', 'Install' }, + l = { 'Lazy log', 'Log' }, + r = { 'Lazy restore', 'Restore' }, + s = { 'Lazy sync', 'Sync' }, + u = { 'Lazy update', 'Update' }, + x = { 'Lazy clean', 'Clean' }, + }, + r = { + name = icons.diagnostics.Hint .. 'Refactor', + b = { "lua require('spectre').open_file_search()", 'Replace Buffer' }, + e = { "lua require('refactoring').refactor('Extract Block')", 'Extract Block' }, + f = { "lua require('refactoring').refactor('Extract Block To File')", 'Extract To File' }, + i = { "lua require('refactoring').refactor('Inline Variable')", 'Inline Variable' }, + n = { '', 'Swap Next' }, + p = { '', 'Swap Previous' }, + r = { '', 'Smart Rename' }, + d = { '', 'Go To Definition' }, + h = { '', 'List Definition Head' }, + l = { '', 'List Definition' }, + j = { '', 'Next Usage' }, + k = { '', 'Previous Usage' }, + R = { "lua require('telescope').extensions.refactoring.refactors()", 'Refactor Commands' }, + S = { "lua require('spectre').open()", 'Replace' }, + s = { [[:%s/\<\>//gI]], 'Replace Word' }, + v = { "lua require('refactoring').refactor('Extract Variable')", 'Extract Variable' }, + w = { "lua require('spectre').open_visual({select_word=true})", 'Replace Word' }, + }, + t = { + name = icons.ui.Terminal .. 'Terminal', + ['`'] = { 'Sterm', 'Horizontal Terminal' }, + n = { 'Sterm node', 'Node' }, + p = { 'Sterm bpython', 'Python' }, + r = { 'Sterm irb', 'Ruby' }, + s = { 'Sterm', 'Horizontal Terminal' }, + t = { 'Fterm', 'Terminal' }, + v = { 'Vterm', 'Vertical Terminal' }, + }, + T = { + name = icons.ui.Test .. 'Test', + f = { 'lua require("neotest").run.run(vim.fn.expand("%"))', 'Run Test' }, + F = { 'lua require("neotest").run.run()', 'Run Current Test' }, + o = { 'Neotest output-panel', 'Test Output' }, + O = { 'Neotest summary', 'Test Summary' }, + }, + s = { + name = icons.ui.Windows .. 'Split', + [','] = { 'NavigatorPrevious', 'Previous Split' }, + ['-'] = { 's', 'Split Below' }, + ['\\'] = { 'v', 'Split Right' }, + c = { 'tabclose', 'Close Tab' }, + d = { 'c', 'Close Window' }, + f = { 'tabfirst', 'First Tab' }, + h = { 'h', 'Move Left' }, + j = { 'j', 'Move Down' }, + k = { 'k', 'Move Up' }, + l = { 'l', 'Move Right' }, + L = { 'tablast', 'Last Tab' }, + o = { 'tabnext', 'Next Tab' }, + O = { 'tabprevious', 'Previous Tab' }, + p = { 'p', 'Previous Window' }, + q = { 'bw', 'Close Current Buf' }, + s = { 'split', 'Horizontal Split File' }, + t = { 'tabnew', 'New Tab' }, + v = { 'vsplit', 'Vertical Split File' }, + W = { "lua require'utils'.sudo_write()", 'Force Write' }, + w = { 'w', 'Write' }, + x = { 'x', 'Write and Quit' }, + }, + y = { + name = icons.ui.Clipboard .. 'Yank', + f = { '%y+', 'Copy Whole File' }, + p = { 'CRpath', 'Copy Relative Path' }, + P = { 'CApath', 'Copy Absolute Path' }, + g = { 'lua require"gitlinker".get_buf_range_url()', 'Copy Git URL' }, + }, +} + +local vopts = { + mode = 'v', + prefix = '', + buffer = nil, + silent = true, + noremap = true, + nowait = true, +} + +local vmappings = { + l = { + name = icons.ui.Gear .. 'LSP', + a = 'Lspsaga range_code_action', + }, + r = { + name = icons.diagnostics.Hint .. 'Refactor', + r = { "lua require('telescope').extensions.refactoring.refactors()", 'Refactor Commands' }, + e = { "lua require('refactoring').refactor('Extract Function')", 'Extract Function' }, + f = { "lua require('refactoring').refactor('Extract Function To File')", 'Extract To File' }, + v = { "lua require('refactoring').refactor('Extract Variable')", 'Extract Variable' }, + i = { "lua require('refactoring').refactor('Inline Variable')", 'Inline Variable' }, + }, + s = { "'<,'>SnipRun", icons.ui.Play .. 'Run Code' }, + q = { 'q', icons.ui.Close .. 'Quit' }, + Q = { 'qa!', icons.ui.Power .. 'Force Quit!' }, + x = { 'x', icons.ui.Pencil .. 'Write and Quit' }, + y = { + name = icons.ui.Clipboard .. 'Yank', + g = { 'lua require"gitlinker".get_buf_range_url()', 'Copy Git URL' }, + }, +} + +local no_leader_opts = { + mode = 'n', + prefix = '', + buffer = nil, + silent = true, + noremap = true, + nowait = true, +} + +local no_leader_mappings = { + [''] = { 'bprevious', 'Previous Buffer' }, + [''] = { 'bnext', 'Next Buffer' }, + + [''] = { 'h', 'Move Left' }, + [''] = { 'j', 'Move Down' }, + [''] = { 'k', 'Move Up' }, + [''] = { 'l', 'Move Right' }, + + [''] = { 'resize +10', 'Increase window height' }, + [''] = { 'resize -10', 'Decrease window height' }, + [''] = { 'vertical resize -10', 'Decrease window width' }, + [''] = { 'vertical resize +10', 'Increase window width' }, + + [''] = { 'Telescope find_files', 'Find Files' }, + [''] = { 'Fterm lazygit', 'Lazygit' }, + + ['['] = { + name = icons.ui.ArrowLeft .. 'Previous', + b = { 'bprevious', 'Buffer' }, + B = { 'bfirst', 'First Buffer' }, + d = { 'Lspsaga diagnostic_jump_prev', 'Diagnostic' }, + e = { 'g;', 'Edit' }, + g = { 'Gitsigns prev_hunk', 'Git Hunk' }, + j = { '', 'Jump' }, + }, + [']'] = { + name = icons.ui.ArrowRight .. 'Next', + b = { 'bnext', 'Buffer' }, + B = { 'blast', 'Buffer' }, + d = { 'Lspsaga diagnostic_jump_next', 'Diagnostic' }, + e = { 'g,', 'Edit' }, + g = { 'Gitsigns next_hunk', 'Git Hunk' }, + j = { '', 'Jump' }, + }, + + K = { 'Lspsaga hover_doc', 'LSP Hover' }, + U = { 'redo', 'Redo' }, +} + +if vim.fn.exists('$TMUX') == 1 then + local tmux_mappings = { + [''] = { 'NavigatorLeft', 'Move Left' }, + [''] = { 'NavigatorDown', 'Move Down' }, + [''] = { 'NavigatorUp', 'Move Up' }, + [''] = { 'NavigatorRight', 'Move Right' }, + [''] = { 'NavigatorPrevious', 'Goto Previous' }, + } + no_leader_mappings = vim.tbl_extend('force', no_leader_mappings, tmux_mappings) +end + +which_key.setup(setup) +which_key.register(mappings, opts) +which_key.register(vmappings, vopts) +which_key.register(no_leader_mappings, no_leader_opts) +which_key.register({ mode = { 'o', 'x' }, i = i, a = a }) diff --git a/lua/plugins/ui/dashboard.lua b/lua/plugins/ui/dashboard.lua new file mode 100644 index 0000000..228d274 --- /dev/null +++ b/lua/plugins/ui/dashboard.lua @@ -0,0 +1,82 @@ +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 = { + header = { '', + + ' ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ', + ' ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ', + ' ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ', + ' ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ', + ' ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ', + ' ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ', + '',}, + week_header = { + enable = false, + append = { '', icons.ui.Circle .. ' Learn, Make, Explore! ' .. icons.ui.Circle }, + }, + 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 = 'lua require("telescope").extensions.menufacture.find_files()', + key = 'f', + }, + { + desc = icons.ui.Search .. 'Search', + group = 'Label', + action = 'lua require("telescope").extensions.menufacture.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/ui/dracula.lua b/lua/plugins/ui/dracula.lua new file mode 100644 index 0000000..2eeb2b7 --- /dev/null +++ b/lua/plugins/ui/dracula.lua @@ -0,0 +1,69 @@ +local dracula = require("dracula") + +dracula.setup({ + colors = { + bg = "#282A36", + fg = "#F8F8F2", + selection = "#44475A", + comment = "#6272A4", + red = "#FF5555", + orange = "#FFB86C", + yellow = "#F1FA8C", + green = "#50fa7b", + purple = "#BD93F9", + cyan = "#8BE9FD", + pink = "#FF79C6", + bright_red = "#FF6E6E", + bright_green = "#69FF94", + bright_yellow = "#FFFFA5", + bright_blue = "#D6ACFF", + bright_magenta = "#FF92DF", + bright_cyan = "#A4FFFF", + bright_white = "#FFFFFF", + menu = "#21222C", + visual = "#3E4452", + gutter_fg = "#4B5263", + nontext = "#3B4048", + }, + -- show the '~' characters after the end of buffers + show_end_of_buffer = true, -- default false + -- use transparent background + transparent_bg = true, -- default false + -- set custom lualine background color + lualine_bg_color = "#44475a", -- default nil + -- set italic comment + italic_comment = true, -- default false + -- overrides the default highlights see `:h synIDattr` + overrides = { + PmenuSel = {link = "lualine_a_insert"}, + TelescopeSelection = {link = "lualine_a_insert"}, + BufferTabpages = {link = "lualine_a_visual"} + -- Nothing = {} -- clear highlight of Nothing + }, + + integrations = { + cmp = true, + fidget = true, + gitsigns = true, + harpoon = true, + indent_blankline = { + enabled = false, + colored_indent_levels = false, + }, + mason = true, + native_lsp = { enabled = true }, + noice = true, + notify = true, + symbols_outline = true, + telescope = true, + treesitter = true, + treesitter_context = true, + }, + }) + + vim.cmd.colorscheme("dracula") + + -- Hide all semantic highlights until upstream issues are resolved (https://github.com/catppuccin/nvim/issues/480) + for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do + vim.api.nvim_set_hl(0, group, {}) + 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/ui/indentline.lua b/lua/plugins/ui/indentline.lua new file mode 100644 index 0000000..41d6845 --- /dev/null +++ b/lua/plugins/ui/indentline.lua @@ -0,0 +1,27 @@ +local highlight = { + 'RainbowRed', + 'RainbowYellow', + 'RainbowBlue', + 'RainbowOrange', + 'RainbowGreen', + 'RainbowViolet', + 'RainbowCyan', +} +local hooks = require('ibl.hooks') +hooks.register(hooks.type.HIGHLIGHT_SETUP, function() + vim.api.nvim_set_hl(0, 'RainbowRed', { fg = '#E06C75' }) + vim.api.nvim_set_hl(0, 'RainbowYellow', { fg = '#E5C07B' }) + vim.api.nvim_set_hl(0, 'RainbowBlue', { fg = '#61AFEF' }) + vim.api.nvim_set_hl(0, 'RainbowOrange', { fg = '#D19A66' }) + vim.api.nvim_set_hl(0, 'RainbowGreen', { fg = '#98C379' }) + vim.api.nvim_set_hl(0, 'RainbowViolet', { fg = '#C678DD' }) + vim.api.nvim_set_hl(0, 'RainbowCyan', { fg = '#56B6C2' }) +end) + +vim.g.rainbow_delimiters = { highlight = highlight } +require('ibl').setup({ + scope = { highlight = highlight }, + exclude = { filetypes = { 'dashboard', 'toggleterm' } }, +}) + +hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) diff --git a/lua/plugins/ui/lualine.lua b/lua/plugins/ui/lualine.lua new file mode 100644 index 0000000..173a542 --- /dev/null +++ b/lua/plugins/ui/lualine.lua @@ -0,0 +1,196 @@ +local lualine = require('lualine') +local icons = require('lib.icons') + +local colors = { + bg = '#202328', + fg = '#bbc2cf', + yellow = '#ECBE7B', + cyan = '#008080', + darkblue = '#081633', + green = '#98be65', + orange = '#FF8800', + violet = '#a9a1e1', + magenta = '#c678dd', + blue = '#51afef', + red = '#ec5f67', +} + +local mode_color = { + n = colors.green, + i = colors.blue, + v = colors.magenta, + [''] = colors.magenta, + V = colors.magenta, + c = colors.yellow, + t = colors.red, + R = colors.orange, + Rv = colors.orange, + no = colors.fg, + s = colors.violet, + S = colors.violet, + [''] = colors.violet, + ic = colors.yellow, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ['r?'] = colors.cyan, + ['!'] = colors.red, +} + +local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 + end, + buffer_is_file = function() + return vim.bo.buftype == '' + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand('%:p:h') + local gitdir = vim.fn.finddir('.git', filepath .. ';') + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, +} +local searchcount = { 'searchcount', color = { fg = colors.fg, gui = 'bold' } } +local selectioncount = { 'selectioncount', color = { fg = colors.fg, gui = 'bold' } } +local progress = { 'progress', color = { fg = colors.fg, gui = 'bold' } } +local filetype = { 'filetype', color = { fg = colors.blue, gui = 'bold' } } +local filesize = { 'filesize', color = { fg = colors.fg, gui = 'bold' }, cond = conditions.buffer_not_empty } +local fileformat = { 'fileformat', icons_enabled = true, color = { fg = colors.white, gui = 'bold' } } + +local filename = { + 'filename', + cond = conditions.buffer_not_empty and conditions.buffer_is_file, + color = { fg = colors.magenta, gui = 'bold' }, +} + +local buffers = { + 'buffers', + filetype_names = { + TelescopePrompt = icons.ui.Telescope .. 'Telescope', + dashboard = icons.ui.Dashboard .. 'Dashboard', + lazy = icons.ui.Sleep .. 'Lazy', + mason = icons.ui.Package .. 'Mason', + NvimTree = icons.documents.OpenFolder .. 'Files', + spectre_panel = icons.ui.Search .. 'Spectre', + }, + use_mode_colors = true, +} + +local branch = { + 'branch', + icon = icons.git.Branch, + fmt = function(str) + return str:sub(1, 32) + end, + color = { fg = colors.green, gui = 'bold' }, +} + +local diff_icons = { + 'diff', + symbols = { added = icons.git.AddAlt, modified = icons.git.DiffAlt, removed = icons.git.RemoveAlt }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.orange }, + removed = { fg = colors.red }, + }, + cond = conditions.hide_in_width, +} + +local diagnostics = { + 'diagnostics', + sources = { 'nvim_lsp', 'nvim_diagnostic', 'nvim_workspace_diagnostic' }, + symbols = { + error = icons.diagnostics.Error, + warn = icons.diagnostics.Warning, + info = icons.diagnostics.Information, + hint = icons.diagnostics.Hint, + }, + diagnostics_color = { + color_error = { fg = colors.red }, + color_warn = { fg = colors.yellow }, + color_info = { fg = colors.blue }, + color_hint = { fg = colors.yellow }, + }, +} + +local lsp = { + function() + local msg = 'No LSP' + local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype') + local clients = vim.lsp.get_active_clients() + if next(clients) == nil then + return msg + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + return client.name + end + end + return msg + end, + icon = icons.ui.Gear, + color = { fg = colors.fg, gui = 'bold' }, +} + +local encoding = { + 'o:encoding', + fmt = string.upper, + cond = conditions.hide_in_width, + color = { fg = colors.green, gui = 'bold' }, +} + +local separator = { + function() + return icons.ui.Separator + end, + color = function() + return { fg = mode_color[vim.fn.mode()] } + end, + padding = { left = 0, right = 0 }, +} + +local function mode(icon) + icon = icon or icons.ui.NeoVim + return { + function() + return icon + end, + color = function() + return { fg = mode_color[vim.fn.mode()] } + end, + padding = { left = 1, right = 0 }, + } +end + +lualine.setup({ + options = { + component_separators = '', + -- section_separators = '', + theme = 'onedark', + disabled_filetypes = { + 'dashboard', + }, + }, + -- extensions = { 'quickfix', 'man', 'mason', 'lazy', 'toggleterm', 'nvim-tree' }, + tabline = { + lualine_a = {}, + lualine_b = { mode(), buffers }, + lualine_c = {}, + lualine_x = { diff_icons, branch }, + lualine_y = { searchcount, selectioncount }, + lualine_z = {}, + }, + sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { separator, mode(icons.ui.Heart), 'location', progress, filename }, + lualine_x = { diagnostics, lsp, filetype, filesize, fileformat, encoding, separator }, + lualine_y = {}, + lualine_z = {}, + }, +}) diff --git a/lua/plugins/ui/notify.lua b/lua/plugins/ui/notify.lua new file mode 100644 index 0000000..a006fe4 --- /dev/null +++ b/lua/plugins/ui/notify.lua @@ -0,0 +1,56 @@ +local notify = require('notify') + +local icons = require('lib.icons') + +notify.setup({ + background_colour = '#000', + fps = 30, + icons = { + DEBUG = icons.ui.Bug, + ERROR = icons.diagnostics.Error, + INFO = icons.diagnostics.Information, + TRACE = icons.ui.Bookmark, + WARN = icons.diagnostics.Warning, + }, + level = 2, + render = 'default', + stages = 'fade_in_slide_out', + timeout = 2000, + top_down = true, + + max_height = function() + return math.floor(vim.o.lines * 0.75) + end, + max_width = function() + return math.floor(vim.o.columns * 0.75) + end, + on_open = function(win) + vim.api.nvim_win_set_config(win, { zindex = 100 }) + end, +}) + +-- Controls noisy notifications +local buffered_messages = { + 'Client %d+ quit', + 'No node found at cursor', +} + +local message_notifications = {} +vim.notify = function(msg, level, opts) + opts = opts or {} + for _, pattern in ipairs(buffered_messages) do + if string.find(msg, pattern) then + if message_notifications[pattern] then + opts.replace = message_notifications[pattern] + end + + opts.on_close = function() + message_notifications[pattern] = nil + end + message_notifications[pattern] = notify.notify(msg, level, opts) + return + end + end + + notify.notify(msg, level, opts) +end diff --git a/lua/plugins/ui/rainbow.lua b/lua/plugins/ui/rainbow.lua new file mode 100644 index 0000000..be4414c --- /dev/null +++ b/lua/plugins/ui/rainbow.lua @@ -0,0 +1,19 @@ +local rainbow_delimiters = require('rainbow-delimiters') + +vim.g.rainbow_delimiters = { + strategy = { + [''] = rainbow_delimiters.strategy['global'], + commonlisp = rainbow_delimiters.strategy['local'], + }, + query = { [''] = 'rainbow-delimiters', lua = 'rainbow-blocks' }, + highlight = { + 'RainbowDelimiterRed', + 'RainbowDelimiterYellow', + 'RainbowDelimiterBlue', + 'RainbowDelimiterOrange', + 'RainbowDelimiterGreen', + 'RainbowDelimiterViolet', + 'RainbowDelimiterCyan', + }, + blacklist = {}, +} diff --git a/lua/plugins/ui/twilight.lua b/lua/plugins/ui/twilight.lua new file mode 100644 index 0000000..a22d4d0 --- /dev/null +++ b/lua/plugins/ui/twilight.lua @@ -0,0 +1,9 @@ +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 = {}, +}) diff --git a/lua/plugins/ui/wilder.lua b/lua/plugins/ui/wilder.lua new file mode 100644 index 0000000..04d298f --- /dev/null +++ b/lua/plugins/ui/wilder.lua @@ -0,0 +1,66 @@ +local wilder = require('wilder') + +wilder.setup({ modes = { ':', '/', '?' } }) + + +wilder.set_option('pipeline', { + wilder.branch( + wilder.cmdline_pipeline({ + fuzzy = 1, + set_pcre2_pattern = 1, + }), + wilder.python_search_pipeline({ + pattern = 'fuzzy', + }) + ), +}) + +local accent = wilder.make_hl('WilderAccent', 'Pmenu', { { a = 1 }, { a = 1 }, { foreground = '#F8F8F2' } }) +local icons = require('lib.icons') + +local popupmenu_renderer = wilder.popupmenu_renderer(wilder.popupmenu_palette_theme({ + border = 'rounded', + max_height = '75%', + min_height = 0, + prompt_position = 'top', + reverse = 0, + empty_message = wilder.popupmenu_empty_message_with_spinner(), + highlighter = wilder.basic_highlighter(), + highlights = { + accent = accent, + }, + left = { + ' ', + wilder.popupmenu_devicons(), + wilder.popupmenu_buffer_flags({ + flags = ' a + ', + icons = { + ['+'] = icons.ui.Pencil, + a = icons.documents.File, + h = icons.documents.FileEmpty, + }, + }), + }, + right = { + ' ', + wilder.popupmenu_scrollbar(), + }, +})) + +local wildmenu_renderer = wilder.wildmenu_renderer({ + highlighter = wilder.basic_highlighter(), + highlights = { accent = accent }, + separator = ' | ', + left = { ' ', wilder.wildmenu_spinner(), ' ' }, + right = { ' ', wilder.wildmenu_index() }, +}) + +wilder.set_option( + 'renderer', + wilder.renderer_mux({ + [':'] = popupmenu_renderer, + ['/'] = popupmenu_renderer, + ['?'] = popupmenu_renderer, + substitute = wildmenu_renderer, + }) +) diff --git a/lua/plugins/ui/zen-mode.lua b/lua/plugins/ui/zen-mode.lua new file mode 100644 index 0000000..a56c449 --- /dev/null +++ b/lua/plugins/ui/zen-mode.lua @@ -0,0 +1,31 @@ +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, +})