diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 9938588..2112376 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,28 +1,5 @@ ---- Options -require('DarthMooMancer.plugins') require('DarthMooMancer.opts') -require('DarthMooMancer.colors') +require('DarthMooMancer.plugins') require('DarthMooMancer.keymaps') require('DarthMooMancer.ui') require('DarthMooMancer.lsp') -require('DarthMooMancer.tools') - -vim.api.nvim_create_autocmd('FileType', { - pattern = { - 'c', - 'cpp', - 'rust', - 'lua', - 'typescript', - 'javascript', - 'css', - 'html', - 'python', - 'go', - 'yaml', - }, - callback = function() - vim.treesitter.start() - vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" - end, -}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/colors.lua b/nvim/.config/nvim/lua/DarthMooMancer/colors.lua deleted file mode 100644 index 8bcb81d..0000000 --- a/nvim/.config/nvim/lua/DarthMooMancer/colors.lua +++ /dev/null @@ -1,25 +0,0 @@ -require('kanso').setup({ - transparent = true, - -- foreground = { - -- dark = "saturated", -- Use default colors in dark mode - -- }, - overrides = function(colors) - local theme = colors.theme - return { - Normal = { bg = "none" }, - NormalFloat = { bg = "none" }, - FloatBorder = { bg = "none" }, - FloatTitle = { bg = "none" }, - TelescopeBorder = { fg = theme.ui.special, bg = "none" }, - TelescopePromptBorder = { fg = theme.ui.special, bg = "none" }, - TelescopeResultsBorder = { fg = theme.ui.special, bg = "none" }, - TelescopePreviewBorder = { fg = theme.ui.special, bg = "none" }, - NotifyBackground = { bg = "none" }, - NotifyBorder = { fg = theme.ui.special, bg = "none" }, - NotifyBody = { fg = theme.ui.fg, bg = "none" }, - NotifyTitle = { fg = theme.ui.special, bg = "none" }, - } - end, -}) - -vim.cmd.colorscheme('kanso-zen') diff --git a/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua b/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua index 0791888..8b084f1 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/keymaps.lua @@ -11,36 +11,36 @@ vim.keymap.set('n', '', 'zz') vim.keymap.set('n', 'n', 'nzzzv') vim.keymap.set('n', 'N', 'Nzzzv') vim.keymap.set('x', 'p', [["_dP]]) -local builtin = require('telescope.builtin') vim.keymap.set( 'n', '', - builtin.find_files, - { desc = 'Telescope find files' } + function() Snacks.picker.files() end ) vim.keymap.set( 'n', 'fh', - builtin.help_tags, - { desc = 'Telescope help tags' } + function() Snacks.picker.help() end ) vim.keymap.set( 'n', 'fg', - builtin.live_grep, - { desc = 'Telescope live grep' } + function() Snacks.picker.grep() end ) vim.keymap.set( 'n', 'fm', - builtin.man_pages, - { desc = 'Telescope man_pages' } + function() Snacks.picker.man() end ) vim.keymap.set( 'n', 'xn', - ':Telescope notify', - { desc = 'Telescope notify' } + function() Snacks.picker.notifications() end +) + +vim.keymap.set( + 'n', + 'uu', + function() Snacks.picker.undo() end ) vim.keymap.set('n', 'fs', vim.lsp.buf.document_symbol) @@ -48,7 +48,6 @@ vim.keymap.set('n', 'gd', vim.lsp.buf.definition) vim.keymap.set('n', 'gr', vim.lsp.buf.references) vim.keymap.set('n', 'gR', vim.lsp.buf.rename) vim.keymap.set('n', 'gc', vim.lsp.buf.code_action) -vim.keymap.set('n', 'uu', ':UndotreeToggle') vim.keymap.set('n', '[', 'H', { silent = true, noremap = true }) vim.keymap.set('n', ']', 'K', { silent = true, noremap = true }) vim.keymap.set('n', '[q', ':cprevzz', { desc = 'Previous Quickfix Item' }) @@ -61,8 +60,4 @@ vim.keymap.set('n', '', ':NvimTmuxNavigateDown', { silent = true }) vim.keymap.set('n', '', ':NvimTmuxNavigateUp', { silent = true }) vim.keymap.set('n', '', ':NvimTmuxNavigateRight', { silent = true }) vim.keymap.set('n', 'xx', ':Trouble diagnostics toggle') -vim.keymap.set('n', 'zz', ':ZenMode') -local dropbar_api = require("dropbar.api") -vim.keymap.set("n", ";", dropbar_api.pick, { desc = "Pick symbols in winbar" }) -vim.keymap.set("n", "[;", dropbar_api.goto_context_start, { desc = "Go to start of current context" }) -vim.keymap.set("n", "];", dropbar_api.select_next_context, { desc = "Select next context" }) +vim.keymap.set('n', 'zz', function() Snacks.zen() end) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua b/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua index f40aac9..0dfd3b4 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/lsp.lua @@ -1,53 +1,3 @@ -require('mason').setup() -require('mason-lspconfig').setup({ - ensure_installed = { - 'vtsls', - 'lua_ls', - 'pylsp', - 'gopls', - 'html', - 'cssls', - 'bashls', - }, - automatic_enable = false, -}) - -require('nvim-treesitter').install({ - 'rust', - 'c', - 'cpp', - 'lua', - 'javascript', - 'go', - 'typescript', - 'css', - 'html', - 'python', - 'yaml', -}) - -require('conform').setup({ - formatters_by_ft = { - rust = { 'rustfmt', lsp_format = 'fallback' }, - lua = { 'stylua', lsp_format = 'fallback' }, - javascript = { 'prettier', stop_after_first = true }, - typescript = { 'prettier', stop_after_first = true }, - json = { 'prettier' }, - html = { 'prettier' }, - go = { 'goimports' }, - c = { 'clang-format' }, - cpp = { 'clang-format' }, - css = { 'csskit' }, - dart = { 'dart_format', lsp_format = 'fallback' }, - python = { 'autopep8' }, - ['_'] = { 'trim_whitespace' }, - }, - format_on_save = { - timeout_ms = 2000, - lsp_format = 'fallback', - }, -}) - local capabilities = require('blink.cmp').get_lsp_capabilities() vim.lsp.config('lua_ls', { capabilities = capabilities, diff --git a/nvim/.config/nvim/lua/DarthMooMancer/opts.lua b/nvim/.config/nvim/lua/DarthMooMancer/opts.lua index cd463dc..d361334 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/opts.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/opts.lua @@ -2,29 +2,29 @@ vim.opt.termguicolors = true vim.g.mapleader = ' ' vim.opt.number = true vim.opt.relativenumber = true -vim.opt.tabstop = 8 -- Number of spaces a counts for -vim.opt.shiftwidth = 8 -- Number of spaces for autoindent (>>, <<, etc.) -vim.opt.softtabstop = 8 -- Number of spaces for in insert mode (backspace deletes 4 spaces) +vim.opt.tabstop = 8 -- Number of spaces a counts for +vim.opt.shiftwidth = 8 -- Number of spaces for autoindent (>>, <<, etc.) +vim.opt.softtabstop = 8 -- Number of spaces for in insert mode (backspace deletes 4 spaces) vim.opt.expandtab = true -- Use spaces instead of tabs vim.api.nvim_create_autocmd('FileType', { - callback = function(ev) - local map = { - rust = { ts = 4, sw = 4, sts = 4 }, - lua = { ts = 4, sw = 4, sts = 4 }, - python = { ts = 4, sw = 4, sts = 4 }, - dart = { ts = 2, sw = 2, sts = 2 }, - html = { ts = 2, sw = 2, sts = 2 }, - javascript = { ts = 2, sw = 2, sts = 2 }, - typescript = { ts = 2, sw = 2, sts = 2 }, - } - local ft = map[ev.match] - if ft then - vim.bo[ev.buf].tabstop = ft.ts - vim.bo[ev.buf].shiftwidth = ft.sw - vim.bo[ev.buf].softtabstop = ft.sts - vim.bo[ev.buf].expandtab = ft.et ~= nil and ft.et or true - end - end, + callback = function(ev) + local map = { + rust = { ts = 4, sw = 4, sts = 4 }, + lua = { ts = 4, sw = 4, sts = 4 }, + python = { ts = 4, sw = 4, sts = 4 }, + dart = { ts = 2, sw = 2, sts = 2 }, + html = { ts = 2, sw = 2, sts = 2 }, + javascript = { ts = 2, sw = 2, sts = 2 }, + typescript = { ts = 2, sw = 2, sts = 2 }, + } + local ft = map[ev.match] + if ft then + vim.bo[ev.buf].tabstop = ft.ts + vim.bo[ev.buf].shiftwidth = ft.sw + vim.bo[ev.buf].softtabstop = ft.sts + vim.bo[ev.buf].expandtab = ft.et ~= nil and ft.et or true + end + end, }) vim.opt.autoindent = true -- Copy indent from current line when starting a new line vim.opt.wrap = false @@ -39,27 +39,40 @@ vim.g.netrw_browse_split = 0 vim.g.netrw_banner = 0 vim.g.netrw_liststyle = 3 vim.g.netrw_winsize = 25 -vim.opt.wrapscan = true -- begin search from top of the file when nothng is found -vim.opt.cursorline = true -- enable cursorline +vim.opt.wrapscan = true -- begin search from top of the file when nothng is found +vim.opt.cursorline = true -- enable cursorline vim.opt.cursorlineopt = { 'screenline', 'number' } -- cursorline look vim.opt.foldmethod = 'indent' vim.opt.foldcolumn = '1' vim.opt.foldenable = false -vim.opt.shortmess = 'aF' -- abbreviates messages and prevents file name being echoed when opened -vim.opt.ignorecase = false -- ignore cases when searching -vim.opt.smartcase = true -- However if we use a capital in search string we then consider case-sensitivity, ignorecase is disabled +vim.opt.shortmess = 'aF' -- abbreviates messages and prevents file name being echoed when opened +vim.opt.ignorecase = false -- ignore cases when searching +vim.opt.smartcase = true -- However if we use a capital in search string we then consider case-sensitivity, ignorecase is disabled vim.opt.smartindent = false -- smarter indentation -vim.opt.smarttab = true -- make tab behaviour smarter +vim.opt.smarttab = true -- make tab behaviour smarter vim.opt.laststatus = 3 vim.opt.showmode = false vim.opt.cmdheight = 0 vim.opt.smoothscroll = true vim.opt.spell = true vim.diagnostic.config({ - virtual_text = true, -- This is the magic line - signs = true, -- Shows icons in the gutter - underline = true, - update_in_insert = false, -- Don't clutter the screen while typing - severity_sort = true, + virtual_text = true, -- This is the magic line + signs = true, -- Shows icons in the gutter + underline = true, + update_in_insert = false, -- Don't clutter the screen while typing + severity_sort = true, +}) +vim.o.winborder = 'rounded' +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'text', 'plaintex' }, + callback = function() + -- Enable visual soft-wrapping + vim.opt_local.wrap = true + vim.opt_local.linebreak = true + vim.opt_local.breakindent = true + + -- Remap j/k to visual lines only inside this buffer + vim.keymap.set('n', 'j', 'gj', { buffer = true }) + vim.keymap.set('n', 'k', 'gk', { buffer = true }) + end, }) -vim.o.winborder = "rounded" diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua index b7dc843..de85cbc 100644 --- a/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins.lua @@ -1,43 +1,12 @@ -vim.pack.add({ - -- Themes - { src = 'https://github.com/webhooked/kanso.nvim' }, - - -- The rest - { src = 'https://github.com/mbbill/undotree' }, - { - src = 'https://github.com/nvim-mini/mini.pairs', - version = vim.version.range('*'), - }, - { - src = 'https://github.com/nvim-mini/mini.hipatterns', - version = vim.version.range('*'), - }, - { src = 'https://github.com/nvim-tree/nvim-web-devicons' }, - { src = 'https://github.com/nvim-telescope/telescope.nvim' }, - { - src = 'https://github.com/saghen/blink.cmp', - version = vim.version.range('*'), - }, - { src = 'https://git.moomancer.xyz/DarthMooMancer/polydev.git' }, - { - src = 'https://github.com/nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - }, - { src = 'https://github.com/alexghergh/nvim-tmux-navigation' }, - { src = 'https://github.com/mason-org/mason.nvim' }, - { src = 'https://github.com/mason-org/mason-lspconfig.nvim' }, - { src = 'https://github.com/neovim/nvim-lspconfig' }, - { src = 'https://github.com/stevearc/conform.nvim' }, - { src = 'https://github.com/b0o/incline.nvim' }, - { src = 'https://github.com/windwp/nvim-ts-autotag' }, - { src = 'https://github.com/MunifTanjim/nui.nvim' }, - { src = 'https://github.com/nvim-lua/plenary.nvim' }, - { src = 'https://github.com/folke/noice.nvim' }, - -- { src = 'https://github.com/stevearc/dressing.nvim' }, - { src = 'https://github.com/rcarriga/nvim-notify' }, - { src = 'https://github.com/folke/trouble.nvim' }, - { src = 'https://github.com/brianhuster/live-preview.nvim' }, - { src = 'https://github.com/m4xshen/hardtime.nvim' }, - { src = 'https://github.com/Bekaboo/dropbar.nvim' }, - { src = 'https://github.com/folke/zen-mode.nvim' }, -}) +require('DarthMooMancer.plugins.utils') +require('DarthMooMancer.plugins.blink-cmp') +require('DarthMooMancer.plugins.kanso') +require('DarthMooMancer.plugins.mini-nvim') +require('DarthMooMancer.plugins.polydev') +require('DarthMooMancer.plugins.treesitter') +require('DarthMooMancer.plugins.incline') +require('DarthMooMancer.plugins.mason') +require('DarthMooMancer.plugins.noice') +require('DarthMooMancer.plugins.snacks') +require('DarthMooMancer.plugins.trouble') +require('DarthMooMancer.plugins.conform') diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/blink-cmp.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/blink-cmp.lua new file mode 100644 index 0000000..008a975 --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/blink-cmp.lua @@ -0,0 +1,30 @@ +vim.pack.add({ + { + src = 'https://github.com/saghen/blink.cmp', + version = vim.version.range('*'), + } +}) + +require('blink.cmp').setup({ + completion = { + documentation = { + auto_show = true, + auto_show_delay_ms = 100, + window = { + winhighlight = 'Normal:NormalFloat,FloatBorder:SnacksPickerBorder,CursorLine:Visual,Search:None', + }, + }, + menu = { + draw = { + columns = { + { "label", "label_description", gap = 1 }, + { "kind_icon", "kind", gap = 1 }, + { "source_name", gap = 1 }, + }, + }, + scrollbar = false, + winhighlight = + 'Pmenu:NormalFloat,FloatBorder:SnacksPickerBorder,PmenuSel:Visual,CursorLine:Visual,Search:None', + }, + }, +}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/conform.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/conform.lua new file mode 100644 index 0000000..b08efb6 --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/conform.lua @@ -0,0 +1,23 @@ +vim.pack.add({ 'https://github.com/stevearc/conform.nvim' }) + +require('conform').setup({ + formatters_by_ft = { + rust = { 'rustfmt', lsp_format = 'fallback' }, + lua = { 'stylua', lsp_format = 'fallback' }, + javascript = { 'prettier', stop_after_first = true }, + typescript = { 'prettier', stop_after_first = true }, + json = { 'prettier' }, + html = { 'prettier' }, + go = { 'goimports' }, + c = { 'clang-format' }, + cpp = { 'clang-format' }, + css = { 'csskit' }, + dart = { 'dart_format', lsp_format = 'fallback' }, + python = { 'autopep8' }, + ['_'] = { 'trim_whitespace' }, + }, + format_on_save = { + timeout_ms = 2000, + lsp_format = 'fallback', + }, +}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/incline.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/incline.lua new file mode 100644 index 0000000..04fa131 --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/incline.lua @@ -0,0 +1,50 @@ +vim.pack.add({ + { src = 'https://github.com/b0o/incline.nvim' }, + { src = 'https://github.com/SmiteshP/nvim-navic' }, +}) + +local helpers = require('incline.helpers') +local navic = require('nvim-navic') +local devicons = require('nvim-web-devicons') + +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserNavicAttach', { clear = true }), + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and client.server_capabilities.documentSymbolProvider then + navic.attach(client, args.buf) + end + end, +}) + +require('incline').setup({ + window = { + padding = 0, + margin = { horizontal = 0, vertical = 0 }, + }, + render = function(props) + local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t') + if filename == '' then + filename = '[No Name]' + end + local ft_icon, ft_color = devicons.get_icon_color(filename) + local modified = vim.bo[props.buf].modified + local res = { + ft_icon and { ' ', ft_icon, ' ', guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or '', + ' ', + { filename, gui = modified and 'bold,italic' or 'bold' }, + guibg = "none", + } + if props.focused then + for _, item in ipairs(navic.get_data(props.buf) or {}) do + table.insert(res, { + { ' > ', group = 'NavicSeparator' }, + { item.icon, group = 'NavicIcons' .. item.type }, + { item.name, group = 'NavicText' }, + }) + end + end + table.insert(res, ' ') + return res + end, +}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/kanso.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/kanso.lua new file mode 100644 index 0000000..f8416bb --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/kanso.lua @@ -0,0 +1,19 @@ +vim.pack.add({'https://github.com/webhooked/kanso.nvim' }) + +require('kanso').setup({ + transparent = true, + overrides = function(colors) + local theme = colors.theme + return { + Normal = { bg = "none" }, + NormalFloat = { bg = "none" }, + FloatBorder = { bg = "none" }, + FloatTitle = { bg = "none" }, + SnacksPickerBorder = { fg = theme.ui.special, bg = "none" }, + SnacksPickerTitle = { fg = theme.ui.special, bg = "none" }, + SnacksInputBorder = { fg = theme.ui.special, bg = "none" }, + } + end, +}) + +vim.cmd.colorscheme('kanso-zen') diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/mason.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/mason.lua new file mode 100644 index 0000000..578221f --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/mason.lua @@ -0,0 +1,19 @@ +vim.pack.add({ + { src = 'https://github.com/mason-org/mason.nvim' }, + { src = 'https://github.com/mason-org/mason-lspconfig.nvim' }, + { src = 'https://github.com/neovim/nvim-lspconfig' }, +}) + +require('mason').setup() +require('mason-lspconfig').setup({ + ensure_installed = { + 'vtsls', + 'lua_ls', + 'pylsp', + 'gopls', + 'html', + 'cssls', + 'bashls', + }, + automatic_enable = false, +}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/mini-nvim.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/mini-nvim.lua new file mode 100644 index 0000000..f87a74b --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/mini-nvim.lua @@ -0,0 +1,34 @@ +vim.pack.add({ + { + src = 'https://github.com/nvim-mini/mini.nvim.git', + version = vim.version.range('*') + } +}) + +local hipatterns = require('mini.hipatterns') +hipatterns.setup({ + highlighters = { + -- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE' + fixme = { + pattern = '%f[%w]()FIXME()%f[%W]', + group = 'MiniHipatternsFixme', + }, + hack = { + pattern = '%f[%w]()HACK()%f[%W]', + group = 'MiniHipatternsHack', + }, + todo = { + pattern = '%f[%w]()TODO()%f[%W]', + group = 'MiniHipatternsTodo', + }, + note = { + pattern = '%f[%w]()NOTE()%f[%W]', + group = 'MiniHipatternsNote', + }, + + hex_color = hipatterns.gen_highlighter.hex_color(), + }, +}) + +require('mini.pairs').setup() +-- require('mini.icons').setup() diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/noice.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/noice.lua new file mode 100644 index 0000000..f28dcb7 --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/noice.lua @@ -0,0 +1,20 @@ +vim.pack.add({ + { src = 'https://github.com/folke/noice.nvim' }, + { src = 'https://github.com/MunifTanjim/nui.nvim' }, +}) + +require('noice').setup({ + lsp = { + override = { + ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + ['vim.lsp.util.stylize_markdown'] = true, + }, + }, + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, +}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/polydev.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/polydev.lua new file mode 100644 index 0000000..871078b --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/polydev.lua @@ -0,0 +1,3 @@ +vim.pack.add({'https://git.moomancer.xyz/DarthMooMancer/polydev.git' }) + +require('Polydev').setup() diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/snacks.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/snacks.lua new file mode 100644 index 0000000..223429c --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/snacks.lua @@ -0,0 +1,31 @@ +vim.pack.add({ 'https://github.com/folke/snacks.nvim' }) + +require('snacks').setup({ + notifier = { + enabled = true, + }, + animate = { enabled = true }, + input = { enabled = true }, + picker = { + enabled = true, + prompt = '  ', + + icons = { + ui = { + selected = ' ', + }, + }, + + layout = { + preview = false, + }, + }, + zen = { + enabled = true, + toggles = { + dim = false, + diagnostics = true, + inlay_hints = true, + }, + }, +}) diff --git a/nvim/.config/nvim/lua/DarthMooMancer/plugins/treesitter.lua b/nvim/.config/nvim/lua/DarthMooMancer/plugins/treesitter.lua new file mode 100644 index 0000000..aac992c --- /dev/null +++ b/nvim/.config/nvim/lua/DarthMooMancer/plugins/treesitter.lua @@ -0,0 +1,49 @@ +vim.pack.add({ + { + src = 'https://github.com/nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + }, + { src = 'https://github.com/windwp/nvim-ts-autotag' }, +}) + +require('nvim-treesitter').install({ + 'rust', + 'c', + 'cpp', + 'lua', + 'javascript', + 'go', + 'typescript', + 'css', + 'html', + 'python', + 'yaml', +}) + +require('nvim-ts-autotag').setup({ + opts = { + enable_close = true, -- Auto close tags + enable_rename = true, -- Auto rename pairs of tags + enable_close_on_slash = false, -- Auto close on trailing ttl then - progress[k] = nil - end - end - if next(progress) then - frame = (frame % #spinner_frames) + 1 - vim.schedule(function() - vim.cmd('redrawstatus') - end) - else - progress_timer:stop() - vim.schedule(function() - vim.cmd('redrawstatus') - end) - end - end) - end + if not progress_timer:is_active() then + progress_timer:start(0, 200, function() + local now = vim.loop.now() + for k, v in pairs(progress) do + local ttl = v.done and 2000 or 10000 + if now - v.t > ttl then + progress[k] = nil + end + end + if next(progress) then + frame = (frame % #spinner_frames) + 1 + vim.schedule(function() + vim.cmd('redrawstatus') + end) + else + progress_timer:stop() + vim.schedule(function() + vim.cmd('redrawstatus') + end) + end + end) + end end vim.api.nvim_create_autocmd('LspProgress', { - callback = function(ev) - local d = ev.data - if not d then - return - end - local params = d.params - if not params or not params.token then - return - end - local key = d.client_id .. ':' .. tostring(params.token) - local value = params.value or {} - if value.kind == 'begin' then - progress[key] = { - msg = (value.message or 'working...'):gsub('%%', '%%%%'), - t = vim.loop.now(), - } - start_progress_timer() - elseif value.kind == 'report' then - local msg_parts = {} - if value.message then - msg_parts[#msg_parts + 1] = value.message - end - if value.percentage ~= nil then - msg_parts[#msg_parts + 1] = '(' .. value.percentage .. '%%)' - end - progress[key] = { - msg = table.concat(msg_parts, ' '), - t = vim.loop.now(), - } - elseif value.kind == 'end' then - if progress[key] then - progress[key].done = true - end - vim.cmd('redrawstatus') - end - end, + callback = function(ev) + local d = ev.data + if not d then + return + end + local params = d.params + if not params or not params.token then + return + end + local key = d.client_id .. ':' .. tostring(params.token) + local value = params.value or {} + if value.kind == 'begin' then + progress[key] = { + msg = (value.message or 'working...'):gsub('%%', '%%%%'), + t = vim.loop.now(), + } + start_progress_timer() + elseif value.kind == 'report' then + local msg_parts = {} + if value.message then + msg_parts[#msg_parts + 1] = value.message + end + if value.percentage ~= nil then + msg_parts[#msg_parts + 1] = '(' .. value.percentage .. '%%)' + end + progress[key] = { + msg = table.concat(msg_parts, ' '), + t = vim.loop.now(), + } + elseif value.kind == 'end' then + if progress[key] then + progress[key].done = true + end + vim.cmd('redrawstatus') + end + end, }) vim.api.nvim_create_autocmd({ 'LspAttach', 'LspDetach' }, { - callback = function(args) - local names = {} - for _, c in ipairs(vim.lsp.get_clients({ bufnr = args.buf })) do - table.insert(names, c.name) - end - vim.b[args.buf].lsp_names = #names > 0 - and (' ● ' .. table.concat(names, ', ') .. ' ') - or '' - end, + callback = function(args) + local names = {} + for _, c in ipairs(vim.lsp.get_clients({ bufnr = args.buf })) do + table.insert(names, c.name) + end + vim.b[args.buf].lsp_names = #names > 0 + and (' ● ' .. table.concat(names, ', ') .. ' ') + or '' + end, }) local function lsp_section() - local client_ids = {} - for _, c in - ipairs(vim.lsp.get_clients({ bufnr = vim.api.nvim_get_current_buf() })) - do - client_ids[c.id] = true - end - local latest = nil - for key, p in pairs(progress) do - local cid = tonumber(key:match('^(%d+):')) - if cid and client_ids[cid] then - if not latest or p.t > latest.t then - latest = p - end - end - end - if latest and (not latest.done or (vim.loop.now() - latest.t < 2000)) then - return '%#StatusLspSpinner# ○ ' .. latest.msg .. ' %*' - end - return '%#StatusLsp#' .. (vim.b.lsp_names or '') .. '%*' + local client_ids = {} + for _, c in + ipairs(vim.lsp.get_clients({ bufnr = vim.api.nvim_get_current_buf() })) + do + client_ids[c.id] = true + end + local latest = nil + for key, p in pairs(progress) do + local cid = tonumber(key:match('^(%d+):')) + if cid and client_ids[cid] then + if not latest or p.t > latest.t then + latest = p + end + end + end + if latest and (not latest.done or (vim.loop.now() - latest.t < 2000)) then + return '%#StatusLspSpinner# ○ ' .. latest.msg .. ' %*' + end + return '%#StatusLsp#' .. (vim.b.lsp_names or '') .. '%*' end local diag_cache = {} local function build_diag_string(counts) - local parts = {} - if counts[1] and counts[1] > 0 then - table.insert(parts, '%#StatusDiagError# E' .. counts[1] .. ' %*') - end - if counts[2] and counts[2] > 0 then - table.insert(parts, '%#StatusDiagWarn# W' .. counts[2] .. ' %*') - end - if counts[4] and counts[4] > 0 then - table.insert(parts, '%#StatusDiagHint# H' .. counts[4] .. ' %*') - end - return table.concat(parts) + local parts = {} + if counts[1] and counts[1] > 0 then + table.insert(parts, '%#StatusDiagError# E' .. counts[1] .. ' %*') + end + if counts[2] and counts[2] > 0 then + table.insert(parts, '%#StatusDiagWarn# W' .. counts[2] .. ' %*') + end + if counts[4] and counts[4] > 0 then + table.insert(parts, '%#StatusDiagHint# H' .. counts[4] .. ' %*') + end + return table.concat(parts) end local function update_diag_cache(ev) - diag_cache[ev.buf] = build_diag_string(vim.diagnostic.count(ev.buf)) + diag_cache[ev.buf] = build_diag_string(vim.diagnostic.count(ev.buf)) end vim.api.nvim_create_autocmd( - 'DiagnosticChanged', - { callback = update_diag_cache } + 'DiagnosticChanged', + { callback = update_diag_cache } ) local function update_git_diff() - if vim.bo.buftype ~= '' then - return - end - local file = vim.fn.expand('%:p') - if file == '' then - return - end - vim.system( - { 'git', 'diff', '--numstat', 'HEAD', '--', file }, - { text = true }, - function(out) - if out.code ~= 0 or out.stdout == '' then - vim.b.git_diff = nil - return - end - local added, removed = out.stdout:match('(%d+)%s+(%d+)') - vim.b.git_diff = { - added = tonumber(added) or 0, - removed = tonumber(removed) or 0, - } - end - ) + if vim.bo.buftype ~= '' then + return + end + local file = vim.fn.expand('%:p') + if file == '' then + return + end + vim.system( + { 'git', 'diff', '--numstat', 'HEAD', '--', file }, + { text = true }, + function(out) + if out.code ~= 0 or out.stdout == '' then + vim.b.git_diff = nil + return + end + local added, removed = out.stdout:match('(%d+)%s+(%d+)') + vim.b.git_diff = { + added = tonumber(added) or 0, + removed = tonumber(removed) or 0, + } + end + ) end vim.api.nvim_create_autocmd({ 'BufEnter', 'FocusGained', 'BufWritePost' }, { - callback = update_git_diff, + callback = update_git_diff, }) function _G.__statusline() - local m = vim.fn.mode() - local mode_hl = mode_hl_map[m] or 'StatusModeNormal' - local git = vim.b.git_branch or '' - local cur_buf = vim.api.nvim_get_current_buf() - local parts = { - '%#' .. mode_hl .. '#' .. (mode_map[m] or ' ?? ') .. '%*', - git ~= '' and ('%#StatusGit#  ' .. git .. ' %*') or '', - } - local diff = vim.b.git_diff - if diff and (diff.added > 0 or diff.removed > 0) then - if diff.added > 0 then - table.insert(parts, '%#StatusGitAdded# +' .. diff.added .. ' %*') - end - if diff.removed > 0 then - table.insert( - parts, - '%#StatusGitRemoved# -' .. diff.removed .. ' %*' - ) - end - end - table.insert(parts, lsp_section()) - table.insert(parts, '%=') - local recording = vim.fn.reg_recording() - if recording ~= '' then - table.insert( - parts, - '%#StatusRecording# ● Rec @' .. recording .. ' %*' - ) - end - table.insert( - parts, - diag_cache[cur_buf] or build_diag_string(vim.diagnostic.count(cur_buf)) - ) - table.insert(parts, '%#StatusCursor# %l:%-2c %*') - table.insert(parts, '%#' .. mode_hl .. '# %p%% %*') - return table.concat(parts) + local m = vim.fn.mode() + local mode_hl = mode_hl_map[m] or 'StatusModeNormal' + local git = vim.b.git_branch or '' + local cur_buf = vim.api.nvim_get_current_buf() + local parts = { + '%#' .. mode_hl .. '#' .. (mode_map[m] or ' ?? ') .. '%*', + git ~= '' and ('%#StatusGit#  ' .. git .. ' %*') or '', + } + local diff = vim.b.git_diff + if diff and (diff.added > 0 or diff.removed > 0) then + if diff.added > 0 then + table.insert(parts, '%#StatusGitAdded# +' .. diff.added .. ' %*') + end + if diff.removed > 0 then + table.insert( + parts, + '%#StatusGitRemoved# -' .. diff.removed .. ' %*' + ) + end + end + table.insert(parts, lsp_section()) + table.insert(parts, '%=') + local recording = vim.fn.reg_recording() + if recording ~= '' then + table.insert( + parts, + '%#StatusRecording# ● Rec @' .. recording .. ' %*' + ) + end + table.insert( + parts, + diag_cache[cur_buf] or build_diag_string(vim.diagnostic.count(cur_buf)) + ) + table.insert(parts, '%#StatusCursor# %l:%-2c %*') + table.insert(parts, '%#' .. mode_hl .. '# %p%% %*') + return table.concat(parts) end vim.o.statusline = '%!v:lua.__statusline()' - -require('incline').setup({ - window = { margin = { vertical = 0, horizontal = 1 } }, - hide = { cursorline = true }, - render = function(props) - local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t") - if vim.bo[props.buf].modified then - filename = "[+] " .. filename - end - - local icon, color = require("nvim-web-devicons").get_icon_color(filename) - return { { icon, guifg = color }, { " " }, { filename } } - end, -}) -require('noice').setup({ - lsp = { - override = { - ['vim.lsp.util.convert_input_to_markdown_lines'] = true, - ['vim.lsp.util.stylize_markdown'] = true, - }, - }, - presets = { - bottom_search = true, -- use a classic bottom cmdline for search - command_palette = true, -- position the cmdline and popupmenu together - long_message_to_split = true, -- long messages will be sent to a split - inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help - }, -}) -require('notify').setup({ - background_colour = '#000000', -}) diff --git a/nvim/.config/nvim/nvim-pack-lock.json b/nvim/.config/nvim/nvim-pack-lock.json index d0c9338..ff05451 100644 --- a/nvim/.config/nvim/nvim-pack-lock.json +++ b/nvim/.config/nvim/nvim-pack-lock.json @@ -9,12 +9,8 @@ "rev": "016802de402556da54c36bd7359b441266b01cdd", "src": "https://github.com/stevearc/conform.nvim" }, - "dropbar.nvim": { - "rev": "808ba31cde89aec8833e9789f5e04557cd31c9e1", - "src": "https://github.com/Bekaboo/dropbar.nvim" - }, "hardtime.nvim": { - "rev": "5165840fe680eab46de1fc6dbff48f148fdcf018", + "rev": "721a75b9a0c2eb1fb811d34507708ee315cb04eb", "src": "https://github.com/m4xshen/hardtime.nvim" }, "incline.nvim": { @@ -30,21 +26,16 @@ "src": "https://github.com/brianhuster/live-preview.nvim" }, "mason-lspconfig.nvim": { - "rev": "b5576cd62899a1a478d0e67ef3d378ee55dba82d", + "rev": "b3298993d55fa194279b5eb9dbfb3a43da65cadf", "src": "https://github.com/mason-org/mason-lspconfig.nvim" }, "mason.nvim": { "rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d", "src": "https://github.com/mason-org/mason.nvim" }, - "mini.hipatterns": { - "rev": "607d604e650cdf21d71f863d040c496a1d0cb320", - "src": "https://github.com/nvim-mini/mini.hipatterns", - "version": ">=0.0.0" - }, - "mini.pairs": { - "rev": "4a014143fcb4e9df26198ccb3ecff3b9e77a048c", - "src": "https://github.com/nvim-mini/mini.pairs", + "mini.nvim": { + "rev": "1345d191bb3da9c7b0e977f4387c5761f9bff68d", + "src": "https://github.com/nvim-mini/mini.nvim.git", "version": ">=0.0.0" }, "noice.nvim": { @@ -56,52 +47,40 @@ "src": "https://github.com/MunifTanjim/nui.nvim" }, "nvim-lspconfig": { - "rev": "84b6b6c3f13cb34a6c8a0354b0da4c67d8ccf867", + "rev": "3e8d598d3b5f8338a41699c436e5fa11d2666cf0", "src": "https://github.com/neovim/nvim-lspconfig" }, - "nvim-notify": { - "rev": "8701bece920b38ea289b457f902e2ad184131a5d", - "src": "https://github.com/rcarriga/nvim-notify" + "nvim-navic": { + "rev": "455808fd0fae06e6d70fadfd61432275db8f34ce", + "src": "https://github.com/SmiteshP/nvim-navic" }, "nvim-tmux-navigation": { "rev": "4898c98702954439233fdaf764c39636681e2861", "src": "https://github.com/alexghergh/nvim-tmux-navigation" }, "nvim-treesitter": { - "rev": "5cb0114e6242625db56dd6440e945ed1ece10bc7", + "rev": "910fdf6f49e9dee7e7257c7d11a76b040fdfb9de", "src": "https://github.com/nvim-treesitter/nvim-treesitter" }, "nvim-ts-autotag": { - "rev": "88c1453db4ba7dd24131086fe51fdf74e587d275", + "rev": "d7220b55e16ed3c04e88086256def5d282429493", "src": "https://github.com/windwp/nvim-ts-autotag" }, "nvim-web-devicons": { - "rev": "5f032a85be210cd1c6ac98861eb3b187ff3bd5eb", + "rev": "58447c1fca354bbf184425e4a8d01deecbd6f3c4", "src": "https://github.com/nvim-tree/nvim-web-devicons" }, - "plenary.nvim": { - "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", - "src": "https://github.com/nvim-lua/plenary.nvim" - }, "polydev": { "rev": "2b30e36fade3272081f7166bc0ec614b0b7da1c9", "src": "https://git.moomancer.xyz/DarthMooMancer/polydev.git" }, - "telescope.nvim": { - "rev": "40aedd8a68c78a656a10a8d62d80c54af59420fb", - "src": "https://github.com/nvim-telescope/telescope.nvim" + "snacks.nvim": { + "rev": "882c996cf28183f4d63640de0b4c02ec886d01f2", + "src": "https://github.com/folke/snacks.nvim" }, "trouble.nvim": { "rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a", "src": "https://github.com/folke/trouble.nvim" - }, - "undotree": { - "rev": "6fa6b57cda8459e1e4b2ca34df702f55242f4e4d", - "src": "https://github.com/mbbill/undotree" - }, - "zen-mode.nvim": { - "rev": "8564ce6d29ec7554eb9df578efa882d33b3c23a7", - "src": "https://github.com/folke/zen-mode.nvim" } } }