diff --git a/init.lua b/init.lua index 7af6ee8..564e366 100644 --- a/init.lua +++ b/init.lua @@ -1,14 +1,14 @@ -require 'config.lazy' -require 'config.autocmd' +require 'config.autocmds' +require 'config.mappings' require 'config.options' +require 'config.lazy' vim.api.nvim_create_autocmd('User', { pattern = 'LazyVimStarted', callback = function() - vim.cmd 'colorscheme neogruber' - require 'config.mappings' + vim.cmd 'colorscheme gruber-darker' require 'feline' - require 'dressing' + -- require 'dressing' require 'NeoSwap' end, }) diff --git a/lua/config/autocmd.lua b/lua/config/autocmds.lua similarity index 64% rename from lua/config/autocmd.lua rename to lua/config/autocmds.lua index 63d152f..6c8b7b4 100644 --- a/lua/config/autocmd.lua +++ b/lua/config/autocmds.lua @@ -1,3 +1,33 @@ +local function augroup(name) + return vim.api.nvim_create_augroup("my_" .. name, { clear = false }) +end + +vim.api.nvim_create_autocmd( + { "BufEnter", "FocusGained", "InsertLeave", "WinEnter", "CmdlineLeave" }, + { + group = augroup("toggle_relative_number"), + callback = function() + if not vim.opt.number:get() and not vim.opt.relativenumber:get() then + return + end + vim.opt.relativenumber = vim.api.nvim_get_mode().mode ~= "i" + end, + } +) + +vim.api.nvim_create_autocmd( + { "BufLeave", "FocusLost", "InsertEnter", "WinLeave", "CmdlineEnter" }, + { + group = augroup("toggle_relative_number"), + callback = function(ev) + vim.opt.relativenumber = false + if ev.event == "CmdlineEnter" then + vim.cmd("redraw") + end + end, + } +) + -- close some filetypes with vim.api.nvim_create_autocmd({ 'FileType' }, { pattern = { 'qf', 'help', 'man', 'lspinfo', 'spectre_panel', 'lir' }, @@ -41,15 +71,6 @@ vim.api.nvim_create_autocmd('FileType', { end, }) -function _G.set_terminal_keymaps() - local opts = { buffer = 0 } - vim.keymap.set('t', '', [[]], opts) - vim.keymap.set('t', '', [[]], opts) -end - --- if you only want these mappings for toggle term use term://*toggleterm#* instead -vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') - -- go to last loc when opening a buffer vim.api.nvim_create_autocmd("BufReadPost", { callback = function(event) @@ -75,8 +96,8 @@ vim.cmd [[ ]] -- Fixes Autocomment -vim.api.nvim_create_autocmd({ 'BufWinEnter' }, { - callback = function() - vim.cmd 'set formatoptions-=cro' - end, -}) +-- vim.api.nvim_create_autocmd({ 'BufWinEnter' }, { +-- callback = function() +-- vim.cmd 'set formatoptions-=cro' +-- end, +-- }) diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua index 56188ad..7c07973 100644 --- a/lua/config/mappings.lua +++ b/lua/config/mappings.lua @@ -23,51 +23,13 @@ vnoremap M :m '>+1gv=gv vnoremap L :m '<-2gv=gv imap [s1z=`]a ]]) - -keymap('n', 'Y', '"+y', opt) -keymap('v', 'Y', '"+y', opt) -keymap('n', '', '"+p', opt) -keymap('v', '', '"+p', opt) --- }}} --- open/close folds with enter key {{{ -keymap('n', '', "@=(foldlevel('.')?'za':\"\")", opt) --- }}} --- terminal {{{ -keymap('n', '', 'ToggleTerm direction=horizontal', opt) -keymap('t', '', 'ToggleTerm direction=horizontal', opt) -keymap('v', '', 'ToggleTerm direction=horizontal', opt) -keymap('i', '', 'ToggleTerm direction=horizontal', opt) -keymap('n', '', 'ToggleTerm direction=float', opt) -keymap('t', '', 'ToggleTerm direction=float', opt) -keymap('v', '', 'ToggleTerm direction=float', opt) -keymap('i', '', 'ToggleTerm direction=float', opt) --- }}} - keymap('n', '', ':', { noremap = true }) -keymap('n', ';', ':', { noremap = true }) - -keymap('n', 'D', '"_d', { noremap = true }) - -keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opt) -keymap('n', 'gd', 'TroubleToggle lsp_definitions', opt) -keymap('n', 'gr', 'TroubleToggle lsp_references', opt) -keymap('n', '', 'lua vim.lsp.buf.hover()', opt) -keymap('n', 'gI', 'TroubleToggle lsp_implementations', opt) -keymap('n', 'gl', 'lua vim.diagnostic.open_float()', opt) -keymap('n', 'lf', 'lua vim.lsp.buf.format { async = true }', opt) -keymap('n', 'li', 'LspInfo', opt) -keymap('n', 'lI', 'LspInstallInfo', opt) -keymap('n', 'la', 'lua vim.lsp.buf.code_action()', opt) -keymap('n', 'lj', 'lua vim.diagnostic.goto_next({buffer=0})', opt) -keymap('n', 'lk', 'lua vim.diagnostic.goto_prev({buffer=0})', opt) -keymap('n', 'lr', 'lua vim.lsp.buf.rename()', opt) -keymap('n', 'ls', 'lua vim.lsp.buf.signature_help()', opt) -keymap('n', 'lq', 'lua vim.diagnostic.setloclist()', opt) -keymap('n', 'e', 'lua vim.diagnostic.open_float()', opt) +-- search and replace {{{ keymap('n', 'rs', ':s///gI', { noremap = true }) keymap('n', 'rr', ':%s///gI', { noremap = true }) keymap('v', 'r', ':s///gI', { noremap = true }) +-- }}} function MapDHM() keymap('n', 'i', 'l', { noremap = true }) @@ -109,206 +71,3 @@ end if file_exists('/tmp/colemak') then MapDHM() end - -local wk = require 'which-key' - --- which-key {{{ -wk.setup { - plugins = { - marks = true, -- shows a list of your marks on ' and ` - registers = true, -- shows your registers on " in NORMAL or in INSERT mode - -- the presets plugin, adds help for a bunch of default keybindings in Neovim - -- No actual key bindings are created - presets = { - operators = true, -- adds help for operators like d, y, ... - motions = true, -- adds help for motions - text_objects = false, -- help for text objects triggered after entering an operator - windows = true, -- default bindings on - nav = true, -- misc bindings to work with windows - z = true, -- bindings for folds, spelling and others prefixed with z - g = true, -- bindings for prefixed with g - }, - }, - icons = { - breadcrumb = '»', -- symbol used in the command line area that shows your active key combo - separator = '➜ ', -- symbol used between a key and it's label - group = '+', -- symbol prepended to a group - }, - window = { - border = 'none', -- none, single, double, shadow - position = 'bottom', -- bottom, top - margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] - padding = { 1, 1, 1, 1 }, -- extra window padding [top, right, bottom, left] - }, - layout = { - height = { min = 4, max = 25 }, -- min and max height of the columns - width = { min = 20, max = 50 }, -- min and max width of the columns - spacing = 3, -- spacing between columns - }, - hidden = { '', '', '', '', 'call', 'lua', '^:', '^ ' }, -- hide mapping boilerplate - show_help = true, -- show help message on the command line when the popup is visible -} - -local opts = { - mode = 'n', -- NORMAL mode - prefix = '', - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = false, -- use `nowait` when creating keymaps -} - ---[[ vim.keymap.set('n', 'L', function() - local win = vim.api.nvim_get_current_win() - local qf_winid = vim.fn.getloclist(win, { winid = 0 }).winid - local action = qf_winid > 0 and 'lclose' or 'lopen' - vim.cmd(action) -end, { noremap = true, silent = true }) - -vim.keymap.set('n', 'X', function() - local qf_winid = vim.fn.getqflist({ winid = 0 }).winid - local action = qf_winid > 0 and 'cclose' or 'copen' - vim.cmd('botright ' .. action) -end, { noremap = true, silent = true }) ]] --- }}} --- leader mappings {{{ -local mappings = { - [''] = { - function() - require('buffer_manager.ui').toggle_quick_menu() - end, - 'Buffers', - }, - ['s'] = { 'ASToggle', 'Auto Save toggle' }, - ['D'] = { 'Dashboard', 'Dashboard' }, - ['.'] = { 'Oil', 'Oil' }, - ['f'] = { 'e ~/.config/nvim/ ', 'Neovim config' }, - ['rr'] = 'Search and replace all', - ['rs'] = 'Search and replace', - ['q'] = { 'lua UnMapDHM()', 'Qwerty' }, - ['k'] = { 'bd', 'Delete buffer' }, - ['b'] = { - function() - require('buffer_manager.ui').toggle_quick_menu() - end, - 'List buffers', - }, - ['n'] = { - function() - require('buffer_manager.ui').nav_next() - end, - 'Next buffer', - }, - ['p'] = { - function() - require('buffer_manager.ui').nav_prev() - end, - 'Previous buffer', - }, - ['h'] = { 'TSBufToggle highlight', 'Enable TS highlight' }, - ['1'] = { - function() - require('buffer_manager.ui').nav_file(1) - end, - 'Buffer 1', - }, - ['2'] = { - function() - require('buffer_manager.ui').nav_file(2) - end, - 'Buffer 2', - }, - ['3'] = { - function() - require('buffer_manager.ui').nav_file(3) - end, - 'Buffer 3', - }, - ['4'] = { - function() - require('buffer_manager.ui').nav_file(4) - end, - 'Buffer 4', - }, - ['5'] = { - function() - require('buffer_manager.ui').nav_file(5) - end, - 'Buffer 5', - }, - ['g'] = { 'Neogit', 'Neogit' }, - d = { - S = { 'Lazy load nvim-gdb ', 'Load GDB' }, - b = { "DapToggleBreakpoint", "Toggle Breakpoint" }, - c = { "DapContinue", "Continue" }, - n = { "DapStepOver", "Step Over" }, - i = { "DapStepInto", "Step Into" }, - o = { "DapStepOut", "Step Out" }, - d = { - function() - require("dapui").toggle() - end, - "Toggle DAP UI" }, - s = { - function() - require("dapui").float_element("scopes", _) - end, - "Scopes" - }, - r = { - function() - require("dapui").float_element("repl", _) - end, - "REPL" - }, - C = { - function() - require("dapui").float_element("console", _) - end, - "Console" - }, - }, - l = { - name = 'LSP', - l = { 'Lazy load none-ls.nvim lsp LspStart ', 'Start LSP' }, - f = { 'lua vim.lsp.buf.format { async = true }', 'Format' }, - i = 'Lsp Info', - a = 'Code action', - j = 'Next diagnostic', - k = 'Prev diagnostic', - r = 'Rename', - s = 'Signature Help', - q = 'Set LocList', - }, - [''] = { - name = 'Tab', - n = { 'tabnew', 'New' }, - p = { 'tabp', 'Previous' }, - d = { 'tabclose', 'Close' }, - [''] = { 'tabnext', 'Next' }, - ['1'] = { '1gt', 'Go to tab 1' }, - ['2'] = { '2gt', 'Go to tab 2' }, - ['3'] = { '3gt', 'Go to tab 3' }, - ['4'] = { '4gt', 'Go to tab 4' }, - ['5'] = { '5gt', 'Go to tab 5' }, - ['6'] = { '6gt', 'Go to tab 6' }, - ['7'] = { '7gt', 'Go to tab 7' }, - ['8'] = { '8gt', 'Go to tab 8' }, - ['9'] = { '9gt', 'Go to tab 9' }, - }, - w = { - name = 'Window', - v = { 'v', 'Vertical split' }, - h = { 's', 'Horizontal split' }, - }, - x = { - name = 'Trouble', - l = { 'TroubleToggle loclist', 'Loclist' }, - q = { 'TroubleToggle quickfix', 'Quickfix' }, - x = { 'TroubleToggle', 'Toggle' }, - w = { 'TroubleToggle workspace_diagnostics', 'Workspace' }, - d = { 'TroubleToggle document_diagnostics', 'Document' }, - }, -} --- }}} -wk.register(mappings, opts) diff --git a/lua/config/options.lua b/lua/config/options.lua index 33fdc7a..5b50ac9 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -57,9 +57,14 @@ opt.fillchars = 'eob: ' opt.cmdheight = 1 opt.grepprg = 'rg --vimgrep --no-heading --smart-case --hidden' opt.grepformat = '%f:%l:%c:%m' +opt.completeopt= 'menu,preview,menuone,noselect' opt.cursorline = true -opt.cursorlineopt = 'number' +opt.signcolumn = "yes:1" +-- opt.cursorlineopt = 'number' vim.opt.formatoptions:remove("c") vim.api.nvim_create_user_command('Cd', 'lcd %:p:h', { nargs = 0 }) vim.api.nvim_create_user_command('Grep', 'silent grep! | TroubleToggle quickfix', { nargs = '+' }) +vim.cmd([[ +hi NotifyBackground guibg = #000000 +]]) diff --git a/lua/plugins/auto-save.lua b/lua/plugins/auto-save.lua deleted file mode 100644 index 0da6699..0000000 --- a/lua/plugins/auto-save.lua +++ /dev/null @@ -1,30 +0,0 @@ -return { - 'okuuva/auto-save.nvim', - cmd = 'ASToggle', - opts = { - enabled = false, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it) - execution_message = { - enabled = true, - message = function() -- message to print on save - return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S")) - end, - dim = 0.18, -- dim the color of `message` - cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea - }, - trigger_events = { -- See :h events - immediate_save = { "BufLeave", "FocusLost" }, -- vim events that trigger an immediate save - defer_save = { "InsertLeave", "TextChanged" }, -- vim events that trigger a deferred save (saves after `debounce_delay`) - cancel_defered_save = { "InsertEnter" }, -- vim events that cancel a pending deferred save - }, - -- function that takes the buffer handle and determines whether to save the current buffer or not - -- return true: if buffer is ok to be saved - -- return false: if it's not ok to be saved - -- if set to `nil` then no specific condition is applied - condition = nil, - write_all_buffers = false, -- write all buffers when the current one meets `condition` - noautocmd = false, -- do not execute autocmds when saving - debounce_delay = 100, -- delay after which a pending save is executed - -- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable - debug = false, - } -} diff --git a/lua/plugins/buffer_manager.lua b/lua/plugins/buffer_manager.lua index 11e4a89..ff5d80c 100644 --- a/lua/plugins/buffer_manager.lua +++ b/lua/plugins/buffer_manager.lua @@ -1,5 +1,10 @@ return { 'j-morano/buffer_manager.nvim', + keys = { + { '', " lua require('buffer_manager.ui').toggle_quick_menu()", desc = 'buffers' }, + { 'gn', " lua require('buffer_manager.ui').nav_next()", desc = 'next buffer' }, + { 'gp', " lua require('buffer_manager.ui').nav_prev()", desc = 'next buffer' }, + }, opts = { -- line_keys = '', -- deactivate line keybindings @@ -20,6 +25,6 @@ return { }, }, width = 0.6, - highlight = "Normal:Normal", + highlight = 'Normal:Normal', }, } diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index f0862a9..f063ad0 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -1,142 +1,108 @@ return { 'hrsh7th/nvim-cmp', - -- lazy = false, dependencies = { - { 'honza/vim-snippets' }, - { 'dcampos/nvim-snippy' }, - { 'dcampos/cmp-snippy' }, 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-path', - 'windwp/nvim-autopairs', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-calc', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-nvim-lsp-signature-help', + 'saadparwaiz1/cmp_luasnip', + 'onsails/lspkind.nvim', }, event = { 'InsertEnter', 'CmdlineEnter' }, - version = false, config = function() local cmp = require 'cmp' - local utils = require 'config.utils' + local lspkind = require 'lspkind' cmp.setup { - -- enabled = function() - -- return vim.api.nvim_buf_get_option(0, 'buftype') ~= 'prompt' or require('cmp_dap').is_dap_buffer() - -- end, + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, view = { entries = { name = 'custom', -- can be "custom", "wildmenu" or "native" -- separator = ' | ', + selection_order = 'near_cursor', }, }, - completion = { - -- autocomplete = { 'TextChanged', 'CmdlineChanged', 'TextChangedP' }, - autocomplete = false, - }, - snippet = { - expand = function(args) - require('snippy').expand_snippet(args.body) - end, - }, + -- completion = { + -- autocomplete = { 'TextChanged', 'CmdlineChanged', 'TextChangedP' }, + -- -- autocomplete = false, + -- }, window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, experimental = { - ghost_text = true, - }, - formatting = { - fields = { 'abbr', 'kind', 'menu' }, - format = function(_, item) - local ELLIPSIS_CHAR = '…' - local MAX_LABEL_WIDTH = 25 - item.kind = string.format('%s', item.kind) -- This concatonates the icons with the name of the item kind - - local label = item.abbr - local truncated_label = vim.fn.strcharpart(label, 0, MAX_LABEL_WIDTH) - if truncated_label ~= label then - item.abbr = truncated_label .. ELLIPSIS_CHAR - end - return item - end, - }, - mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.mapping { - i = cmp.mapping.abort(), - c = cmp.mapping.close(), + ghost_text = { + hl_group = { "Comment" }, }, - [''] = cmp.mapping.confirm { select = true }, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), [''] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.select_next_item { behavior = cmp.SelectBehavior.Select } - elseif require('snippy').can_expand_or_advance() then - require('snippy').expand_or_advance() - elseif utils.has_words_before() then - cmp.complete() + cmp.select_next_item() else fallback() end end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.select_prev_item { behavior = cmp.SelectBehavior.Insert } - elseif require('snippy').can_jump(-1) then - require('snippy').previous() + cmp.select_prev_item() else fallback() end end, { 'i', 's' }), + [''] = cmp.mapping.confirm { select = false }, }, - sources = { + sources = cmp.config.sources({ + { name = 'luasnip' }, { name = 'nvim_lsp' }, + { name = 'nvim_lsp_signature_help' }, + }, { { name = 'path' }, - { name = 'snippy' }, + { name = 'calc' }, { name = 'buffer' }, + }), + formatting = { + format = require 'lspkind'.cmp_format({ + mode = 'symbol_text', -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + -- can also be a function to dynamically calculate max width such as + -- maxwidth = function() return math.floor(0.45 * vim.o.columns) end, + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + show_labelDetails = true, -- show labelDetails in menu. Disabled by default + + -- The function below will be called before any actual modifications from lspkind + -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) + before = function(entry, vim_item) + return vim_item + end + }) }, } - cmp.setup.cmdline(':', { - completion = { autocomplete = { 'TextChanged', 'CmdlineChanged', 'TextChanged' } }, + + cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { - { name = 'cmdline' }, + { name = 'buffer' }, }, - -- view = { - -- entries = { name = 'wildmenu', separator = ' · ' }, - -- }, }) - -- cmp.setup.cmdline('/', { - -- sources = { - -- { name = 'buffer' }, - -- }, - -- view = { - -- entries = { name = 'wildmenu', separator = ' · ' }, - -- }, - -- }) - - -- cmp.setup.filetype({ 'dap-repl', 'dapui_watches', 'dapui_hover' }, { - -- sources = { - -- { name = 'dap' }, - -- }, - -- }) - - local npairs = require 'nvim-autopairs' - npairs.setup { - check_ts = true, -- treesitter integration - fast_wrap = { - map = '', - highlight = 'Search', - highlight_grey = 'Comment', - }, - map_c_w = true, - -- disable_filetype = { "TelescopePrompt" }, - } - - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done {}) + cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' }, + }, { + { name = 'cmdline' }, + }), + }) end, } diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua index 67ca369..5587858 100644 --- a/lua/plugins/comment.lua +++ b/lua/plugins/comment.lua @@ -42,8 +42,7 @@ return { if ctx.ctype == U.ctype.blockwise then location = require('ts_context_commentstring.utils').get_cursor_location() elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then - location = require('ts_context_commentstring.utils') - .get_visual_start_location() + location = require('ts_context_commentstring.utils').get_visual_start_location() end return require('ts_context_commentstring.internal').calculate_commentstring { diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index fcc26d0..6a597ec 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -1,82 +1,118 @@ return { - { 'mfussenegger/nvim-dap', }, + { + 'mfussenegger/nvim-dap', + keys = function() + local function dap(name) + return function() + require('dap')[name]() + end + end + + return { + { 'dc', dap 'continue', desc = 'continue' }, + { 'ds', dap 'step_into', desc = 'step into' }, + { 'dn', dap 'step_over', desc = 'step over (next)' }, + { 'df', dap 'step_out', desc = 'step out (finish)' }, + { 'db', dap 'toggle_breakpoint', desc = 'toggle breakpoint' }, + { + 'do', + function() + vim.ui.input({ prompt = 'Condition: ' }, function(input) + if input == nil then + return + end + require('dap').set_breakpoint(input) + end) + end, + desc = 'set conditional breakpoint', + }, + { 'dl', dap 'clear_breakpoints', desc = 'clear breakpoints' }, + { 'dq', dap 'terminate', desc = 'quit' }, + } + end, + }, { 'rcarriga/nvim-dap-ui', opts = { controls = { - element = "repl", + element = 'repl', enabled = true, icons = { - disconnect = "", - pause = "", - play = "", - run_last = "", - step_back = "", - step_into = "", - step_out = "", - step_over = "", - terminate = "" - } + disconnect = '', + pause = '', + play = '', + run_last = '', + step_back = '', + step_into = '', + step_out = '', + step_over = '', + terminate = '', + }, }, element_mappings = {}, expand_lines = true, floating = { - border = "single", + border = 'single', mappings = { - close = { "q", "" } - } + close = { 'q', '' }, + }, }, force_buffers = true, icons = { - collapsed = "", - current_frame = "", - expanded = "" + collapsed = '', + current_frame = '', + expanded = '', }, - layouts = { { - elements = { - { - id = "scopes", - size = 0.5 + layouts = { + { + elements = { + { + id = 'scopes', + size = 0.5, + }, + -- { + -- id = "breakpoints", + -- size = 0.25 + -- }, + { + id = 'stacks', + size = 0.25, + }, + { + id = 'watches', + size = 0.25, + }, }, - -- { - -- id = "breakpoints", - -- size = 0.25 - -- }, - { - id = "stacks", - size = 0.25 - }, - { - id = "watches", - size = 0.25 - } + position = 'right', + size = 40, }, - position = "right", - size = 40 - }, { - elements = { { - id = "repl", - size = 0.5 - }, { - id = "console", - size = 0.5 - } }, - position = "bottom", - size = 10 - } }, + { + elements = { + { + id = 'repl', + size = 0.5, + }, + { + id = 'console', + size = 0.5, + }, + }, + position = 'bottom', + size = 10, + }, + }, mappings = { - edit = "e", - expand = { "", "<2-LeftMouse>" }, - open = "o", - remove = "d", - repl = "r", - toggle = "t" + edit = 'e', + expand = { '', '<2-LeftMouse>' }, + open = 'o', + remove = 'd', + repl = 'r', + toggle = 't', }, render = { indent = 1, - max_value_lines = 100 - } - + max_value_lines = 100, + }, }, }, } diff --git a/lua/plugins/editing.lua b/lua/plugins/editing.lua new file mode 100644 index 0000000..4874a6b --- /dev/null +++ b/lua/plugins/editing.lua @@ -0,0 +1,27 @@ +return { + { 'mg979/vim-visual-multi', event = 'VeryLazy' }, + { + 'ecthelionvi/NeoSwap.nvim', + opts = {}, + }, + { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = function() + require('nvim-autopairs').setup { + check_ts = true, -- treesitter integration + fast_wrap = { + map = '', + highlight = 'Search', + highlight_grey = 'Comment', + }, + map_c_w = true, + disable_filetype = { 'TelescopePrompt' }, + } + + 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 = '' } }) + end, + }, +} diff --git a/lua/plugins/editor.lua b/lua/plugins/editor.lua new file mode 100644 index 0000000..7ab2f40 --- /dev/null +++ b/lua/plugins/editor.lua @@ -0,0 +1,113 @@ +return { + { + 'echasnovski/mini.diff', + version = false, + event = "VeryLazy", + opts = { + -- Options for how hunks are visualized + view = { + -- Visualization style. Possible values are 'sign' and 'number'. + -- Default: 'number' if line numbers are enabled, 'sign' otherwise. + style = 'sign', + + -- Signs used for hunks with 'sign' view + signs = { add = '▒', change = '▒', delete = '▒' }, + + -- Priority of used visualization extmarks + priority = 199, + }, + + -- Source for how reference text is computed/updated/etc + -- Uses content from Git index by default + source = nil, + + -- Delays (in ms) defining asynchronous processes + delay = { + -- How much to wait before update following every text change + text_change = 200, + }, + + -- Module mappings. Use `''` (empty string) to disable one. + mappings = { + -- Apply hunks inside a visual/operator region + apply = 'gh', + + -- Reset hunks inside a visual/operator region + reset = 'gH', + + -- Hunk range textobject to be used inside operator + textobject = 'gh', + + -- Go to hunk range in corresponding direction + goto_first = '[H', + goto_prev = '[h', + goto_next = ']h', + goto_last = ']H', + }, + + -- Various options + options = { + -- Diff algorithm. See `:h vim.diff()`. + algorithm = 'histogram', + + -- Whether to use "indent heuristic". See `:h vim.diff()`. + indent_heuristic = true, + + -- The amount of second-stage diff to align lines (in Neovim>=0.9) + linematch = 60, + + -- Whether to wrap around edges during hunk navigation + wrap_goto = false, + }, + } + }, + { + 'nvim-telescope/telescope.nvim', + dependencies = { + { 'nvim-lua/plenary.nvim' }, + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + { 'nvim-tree/nvim-web-devicons' }, + }, + cmd = 'Telescope', + keys = function() + local telescope = require('utils').telescope + + return { + { 'ff', telescope 'find_files', desc = 'files' }, + { 'fg', telescope 'git_files', desc = 'git files' }, + { 'fr', telescope 'live_grep', desc = 'grep' }, + { 'fb', telescope 'buffers', desc = 'buffers' }, + { 'fc', telescope 'colorscheme', desc = 'colorscheme' }, + { 'fh', telescope 'oldfiles', desc = 'history' }, + } + end, + config = function() + local telescope = require 'telescope' + telescope.setup { + defaults = { + mappings = { + i = { + [""] = require('telescope.actions').close + } + }, + } + } + telescope.load_extension 'fzf' + end, + }, + { + 'f-person/git-blame.nvim', + dependencies = {}, + keys = { + { 'bt', 'GitBlameToggle', desc = 'Blame toggle' }, + { 'bo', 'GitBlameOpenCommitURL', desc = 'Open in browser' }, + { 'bc', 'GitBlameCopySHA', desc = 'Copy SHA1' }, + }, + config = function() + require('gitblame').setup { + enabled = false, + message_template = ' ', + } + end, + }, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua deleted file mode 100644 index 3a67ea5..0000000 --- a/lua/plugins/init.lua +++ /dev/null @@ -1,42 +0,0 @@ -return { - - 'folke/which-key.nvim', - 'nvim-lua/plenary.nvim', - 'mfussenegger/nvim-jdtls', - 'simrat39/rust-tools.nvim', - 'sakhnik/nvim-gdb', - { 'mg979/vim-visual-multi', event = 'VeryLazy' }, - { 'rush-rs/tree-sitter-asm', ft = 'asm' }, - { 'jghauser/mkdir.nvim', lazy = false }, - -- { - -- 'jakewvincent/mkdnflow.nvim', - -- dependencies = 'nvim-lua/plenary.nvim', - -- ft = 'markdown', - -- opts = {}, - -- }, - { - 'glepnir/dbsession.nvim', - cmd = { 'SessionSave', 'SessionDelete', 'SessionLoad' }, - opts = {}, - }, - { - "stevearc/dressing.nvim", - lazy = true, - init = function() - ---@diagnostic disable-next-line: duplicate-set-field - vim.ui.select = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.select(...) - end - ---@diagnostic disable-next-line: duplicate-set-field - vim.ui.input = function(...) - require("lazy").load({ plugins = { "dressing.nvim" } }) - return vim.ui.input(...) - end - end, - }, - { - "ecthelionvi/NeoSwap.nvim", - opts = {} - }, -} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua deleted file mode 100644 index 4bbecec..0000000 --- a/lua/plugins/lsp.lua +++ /dev/null @@ -1,44 +0,0 @@ -return { - 'neovim/nvim-lspconfig', - name = 'lsp', - ft = 'java', - dependencies = { 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim' }, - opts = { - -- options for vim.diagnostic.config() - diagnostics = { - underline = true, - update_in_insert = false, - signs = false, - virtual_text = { - source = "if_many", - prefix = "●", - -- this will set set the prefix to a function that returns the diagnostics icon based on the severity - -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported - -- prefix = "icons", - }, - float = { - focusable = false, - -- style = 'minimal', - border = 'rounded', - source = 'always', - header = '', - prefix = '', - }, - severity_sort = true, - }, - }, - config = function(_, opts) - vim.diagnostic.config(vim.deepcopy(opts.diagnostics)) - -- vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { - -- border = 'rounded', - -- }) - -- vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { - -- border = 'rounded', - -- }) - local on_references = vim.lsp.handlers['textDocument/references'] - vim.lsp.handlers['textDocument/references'] = vim.lsp.with(on_references, { - -- Use location list instead of quickfix list - loclist = true, - }) - end -} diff --git a/lua/plugins/mason.lua b/lua/plugins/lsp/init.lua similarity index 52% rename from lua/plugins/mason.lua rename to lua/plugins/lsp/init.lua index 3a4de64..18160ef 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/lsp/init.lua @@ -1,4 +1,45 @@ return { + { + 'neovim/nvim-lspconfig', + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + { 'williamboman/mason.nvim' }, + { 'williamboman/mason-lspconfig.nvim' }, + { 'hrsh7th/cmp-nvim-lsp' }, + { 'mfussenegger/nvim-dap' }, + { 'simrat39/rust-tools.nvim' }, + { + 'j-hui/fidget.nvim', + opts = { + }, + }, + }, + config = function() + require('plugins.lsp.ui').setup() + vim.diagnostic.config { + underline = true, + update_in_insert = true, + signs = false, + virtual_text = { + source = 'if_many', + prefix = '●', + spacing = 5, + -- this will set set the prefix to a function that returns the diagnostics icon based on the severity + -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported + -- prefix = "icons", + }, + float = { + focusable = true, + -- style = 'minimal', + border = 'rounded', + source = 'always', + header = '', + prefix = '', + }, + severity_sort = true, + } + end, + }, { 'williamboman/mason.nvim', cmd = 'Mason', @@ -18,9 +59,12 @@ return { }, }, { - "jay-babu/mason-nvim-dap.nvim", + 'jay-babu/mason-nvim-dap.nvim', + dependencies = 'nvim-neotest/nvim-nio', opts = { - ensure_installed = { 'javatest', 'javadbg', 'codelldb' }, + ensure_installed = { --[[ 'javatest', 'javadbg', ]] + 'codelldb', + }, handlers = { function(config) -- all sources with no handler get passed here @@ -40,17 +84,18 @@ return { -- require('mason-nvim-dap').default_setup(config) -- don't forget this! -- end, }, - } + }, }, { 'williamboman/mason-lspconfig.nvim', - dependencies = { 'jay-babu/mason-nvim-dap.nvim', 'rcarriga/nvim-dap-ui' }, + dependencies = { 'jay-babu/mason-nvim-dap.nvim', 'rcarriga/nvim-dap-ui', 'Issafalcon/lsp-overloads.nvim' }, config = function() + require('mason').setup() local cmp_nvim_lsp = require 'cmp_nvim_lsp' local capabilities = cmp_nvim_lsp.default_capabilities() local lspconfig = require 'lspconfig' capabilities.textDocument.completion.completionItem = { - documentationFormat = { "markdown", "plaintext" }, + documentationFormat = { 'markdown', 'plaintext' }, snippetSupport = true, preselectSupport = true, insertReplaceSupport = true, @@ -60,15 +105,27 @@ return { tagSupport = { valueSet = { 1 } }, resolveSupport = { properties = { - "documentation", - "detail", - "additionalTextEdits", + 'documentation', + 'detail', + 'additionalTextEdits', }, }, } local function on_attach(client, bufnr) - --[[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]] + require('plugins.lsp.keymaps').on_attach(bufnr) + require('plugins.lsp.ui').on_attach(client, bufnr) + -- [[ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') ]] + if client.server_capabilities.signatureHelpProvider then + require('lsp-overloads').setup(client, { + ui = { + max_width = 60, + max_height = 8, + floating_window_above_cur_line = true, + }, + display_automatically = true, -- Uses trigger characters to automatically display the signature overloads when typing a method signature + }) + end if client.name == 'jdtls' or client.name == 'jdt.ls' then -- client.server_capabilities.documentFormattingProvider = false vim.lsp.codelens.refresh() @@ -80,7 +137,6 @@ return { end -- -- util.info(client.name .. " " .. (enable and "yes" or "no"), "format") client.server_capabilities.documentFormattingProvider = true - -- client.server_capabilities.documentFormattingProvider = true client.server_capabilities.semanticTokensProvider = nil end @@ -88,7 +144,7 @@ return { function(server_name) -- default handler (optional) lspconfig[server_name].setup { on_attach = on_attach, - capabilities = capabilities, + capabilities = vim.deepcopy(capabilities), } end, ['clangd'] = function() @@ -112,15 +168,15 @@ return { on_attach = on_attach, capabilities = capabilities, arg = { - unpack(clangd_flags) - } + unpack(clangd_flags), + }, } end, ['html'] = function() lspconfig.html.setup { on_attach = on_attach, capabilities = capabilities, - filetypes = { "html", "jsp" }, + filetypes = { 'html', 'jsp' }, } end, ['lua_ls'] = function() @@ -148,17 +204,58 @@ return { }, } end, - ['jdtls'] = function() - end, + ['jdtls'] = function() end, ['rust_analyzer'] = function() - require('rust-tools').setup { + local rt = require 'rust-tools' + rt.setup { server = { - on_attach = on_attach, - standalone = false, + on_attach = function(client, bufnr) + require('plugins.lsp.keymaps').on_attach(bufnr) + require('plugins.lsp.ui').on_attach(client, bufnr) + client.server_capabilities.semanticTokensProvider = nil + if client.server_capabilities.signatureHelpProvider then + require('lsp-overloads').setup(client, { + ui = { + max_width = 60, + max_height = 8, + floating_window_above_cur_line = true, + }, + display_automatically = true, -- Uses trigger characters to automatically display the signature overloads when typing a method signature + }) + end + -- Hover actions + vim.keymap.set('n', '', + rt.hover_actions.hover_actions, + { buffer = bufnr }) + -- Code action groups + vim.keymap.set( + 'n', + 'a', + rt.code_action_group.code_action_group, + { buffer = bufnr } + ) + end, + settings = { + ['rust-analyzer'] = { + cargo = { features = 'all' }, + check = { allTargets = true }, + }, + procMacro = { + enable = true, + }, + }, + }, + -- debugging stuff + dap = { + adapter = { + type = 'executable', + command = 'lldb-vscode', + name = 'rt_lldb', + }, }, } end, } - end - } + end, + }, } diff --git a/lua/plugins/lsp/keymaps.lua b/lua/plugins/lsp/keymaps.lua new file mode 100644 index 0000000..e89076a --- /dev/null +++ b/lua/plugins/lsp/keymaps.lua @@ -0,0 +1,38 @@ +local M = {} + +function M.on_attach(bufnr) + local telescope = require('utils').telescope + + local function map(key, rhs, desc) + vim.keymap.set('n', key, rhs, { + silent = true, + buffer = bufnr, + desc = desc, + }) + end + + map('K', vim.lsp.buf.hover, 'hover') + + map('lf', vim.lsp.buf.format, 'format') + map('lD', vim.lsp.buf.declaration, 'declaration') + map('ld', telescope 'lsp_definitions', 'definition') + map('li', telescope 'lsp_implementations', 'implementation') + map('lt', telescope 'lsp_type_definitions', 'type defintion') + map('lr', telescope 'lsp_references', 'references') + map('ly', telescope 'lsp_document_symbols', 'LSP symbols') + + map('ln', vim.lsp.buf.rename, 'rename') + map('la', vim.lsp.buf.code_action, 'action') + + map('lp', vim.diagnostic.goto_prev, 'previous diagnostic') + map('ll', vim.diagnostic.goto_next, 'next diagnostic') + map('lw', telescope 'diagnostics', 'diagnostics list') + map('ls', function() + vim.diagnostic.open_float { scope = 'cursor' } + end, 'cursor diagnostic') + map('lS', function() + vim.diagnostic.open_float { scope = 'line' } + end, 'line diagnostics') +end + +return M diff --git a/lua/plugins/lsp/ui.lua b/lua/plugins/lsp/ui.lua new file mode 100644 index 0000000..f853d1a --- /dev/null +++ b/lua/plugins/lsp/ui.lua @@ -0,0 +1,53 @@ +local M = {} + +function M.setup() + -- Signs + local signs = { Error = "", Warn = "", Hint = "", Info = "" } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end + + -- Floating window borders + local border = { + { "╭", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╮", "FloatBorder" }, + { "│", "FloatBorder" }, + { "╯", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╰", "FloatBorder" }, + { "│", "FloatBorder" }, + } + local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview + function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) + opts = opts or {} + opts.border = opts.border or border + return orig_util_open_floating_preview(contents, syntax, opts, ...) + end +end + +function M.on_attach(client, bufnr) + -- Highlight references + if client.server_capabilities.documentHighlightProvider then + vim.api.nvim_create_augroup("lsp_document_highlight", { + clear = false, + }) + vim.api.nvim_clear_autocmds({ + group = "lsp_document_highlight", + buffer = bufnr, + }) + -- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { + -- group = "lsp_document_highlight", + -- buffer = bufnr, + -- callback = vim.lsp.buf.document_highlight, + -- }) + -- vim.api.nvim_create_autocmd("CursorMoved", { + -- group = "lsp_document_highlight", + -- buffer = bufnr, + -- callback = vim.lsp.buf.clear_references, + -- }) + end +end + +return M diff --git a/lua/plugins/misc.lua b/lua/plugins/misc.lua new file mode 100644 index 0000000..a4c6ace --- /dev/null +++ b/lua/plugins/misc.lua @@ -0,0 +1,8 @@ +return { + { 'jghauser/mkdir.nvim', lazy = false }, + { + 'glepnir/dbsession.nvim', + cmd = { 'SessionSave', 'SessionDelete', 'SessionLoad' }, + opts = {}, + }, +} diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua index 50cd647..b30fe73 100644 --- a/lua/plugins/neogit.lua +++ b/lua/plugins/neogit.lua @@ -1,7 +1,14 @@ return { 'NeogitOrg/neogit', - dependencies = 'sindrets/diffview.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'sindrets/diffview.nvim', -- optional + 'ibhagwan/fzf-lua', -- optional + }, cmd = 'Neogit', + keys = { + { 'g', 'Neogit', desc = 'neogit' }, + }, opts = { disable_signs = false, disable_hint = false, diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index 998efd2..f67de1e 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -2,12 +2,15 @@ return { 'stevearc/oil.nvim', -- lazy = false, event = 'VeryLazy', + keys = { + { '.', 'Oil', desc = 'oil' }, + }, opts = { columns = { - "mtime", - "size", - "permissions", - "icon", + 'mtime', + 'size', + 'permissions', + 'icon', }, -- Buffer-local options to use for oil buffers buf_options = { @@ -16,9 +19,9 @@ return { -- Window-local options to use for oil buffers win_options = { wrap = false, - signcolumn = "no", + signcolumn = 'no', cursorcolumn = false, - foldcolumn = "0", + foldcolumn = '0', spell = false, list = false, conceallevel = 3, diff --git a/lua/plugins/snippets/init.lua b/lua/plugins/snippets/init.lua new file mode 100644 index 0000000..481767c --- /dev/null +++ b/lua/plugins/snippets/init.lua @@ -0,0 +1,53 @@ +return { + "L3MON4D3/LuaSnip", + keys = { + { + "", + function() + if require("luasnip").jumpable(1) then + require("luasnip").jump(1) + end + end, + mode = { "i", "s" }, + }, + { + "", + function() + if require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + end + end, + mode = { "i", "s" }, + }, + { + "", + function() + if require("luasnip").choice_active() then + require("luasnip").change_choice(1) + end + end, + mode = { "i", "s" }, + }, + { + "", + function() + if require("luasnip").choice_active() then + require("luasnip").change_choice(-1) + end + end, + mode = { "i", "s" }, + }, + }, + opts = { + history = true, + update_events = { "TextChanged", "TextChangedI" }, + }, + config = function(_, opts) + local ls = require("luasnip") + ls.setup(opts) + -- for _, lang in pairs({ "c", "make", "markdown", "tiger", "sh", "nix" }) do + -- ls.add_snippets(lang, require("plugins.snippets." .. lang)) + -- end + -- ls.add_snippets("cpp", require("plugins.snippets.c")) + end, +} diff --git a/lua/plugins/theme.lua b/lua/plugins/theme.lua deleted file mode 100644 index 25a3a87..0000000 --- a/lua/plugins/theme.lua +++ /dev/null @@ -1,159 +0,0 @@ -local l = false -return { - { - -- url = 'https://git.filnar.com/fiplox/neogruber.git', - dir = '~/dev/home/neogruber.nvim/', - lazy = false, - opts = { - transparent = true, - light = l, - } - -- event = 'VeryLazy' - }, - -- { - -- "Mofiqul/adwaita.nvim", - -- lazy = false, - -- priority = 1000, - -- -- configure and set on startup - -- config = function() - -- vim.g.adwaita_darker = false -- for darker version - -- vim.g.adwaita_disable_cursorline = false -- to disable cursorline - -- vim.g.adwaita_transparent = true -- makes the background transparent - -- -- vim.cmd('colorscheme adwaita') - -- end - -- }, - { - 'freddiehaddad/feline.nvim', - dependencies = { - 'nvim-tree/nvim-web-devicons', - }, - config = function() - local feline = require 'feline' - local utils = require 'config.utils' - local c = utils.feline_c - local theme - if l then - theme = utils.feline_theme_light - else - theme = utils.feline_theme_dark - end - local vi_mode_colors = utils.feline_vi_mode_colors - - local left = { - c.vim_mode, - -- c.gitBranch, - -- c.gitDiffAdded, - -- c.gitDiffRemoved, - -- c.gitDiffChanged, - c.file_info, - c.right_separator, - c.lsp_client_names, - c.diagnostic_errors, - c.diagnostic_warnings, - c.diagnostic_info, - c.diagnostic_hints, - } - - -- local middle = { - -- c.separator, - -- } - - local right = { - c.file_type, - c.search_count, - c.macro, - c.file_encoding, - -- c.startup, - c.line_percentage, - c.select_count, - c.position, - } - - local components = { - active = { - left, - -- middle, - right, - }, - inactive = { - left, - -- middle, - right, - }, - } - - feline.setup { - components = components, - theme = theme, - vi_mode_colors = vi_mode_colors, - } - end, - }, - -- { - -- 'nvim-lualine/lualine.nvim', - -- dependencies = { 'nvim-tree/nvim-web-devicons', 'nvim-lua/lsp-status.nvim' }, - -- opts = { - -- options = { - -- theme = "adwaita" - -- }, - -- sections = { - -- lualine_a = { 'mode' }, - -- lualine_b = { 'branch', 'diff', 'diagnostics' }, - -- lualine_c = { 'filename', "require'lsp-status'.status()" }, - -- lualine_x = { 'encoding', 'fileformat', 'filetype' }, - -- lualine_y = { 'progress' }, - -- lualine_z = { 'location' } - -- }, - -- inactive_sections = { - -- lualine_a = {}, - -- lualine_b = {}, - -- lualine_c = { 'filename', "require'lsp-status'.status()" }, - -- lualine_x = { 'location' }, - -- lualine_y = {}, - -- lualine_z = {} - -- }, - -- tabline = {}, - -- winbar = {}, - -- inactive_winbar = {}, - -- extensions = {} - -- }, - -- }, - -- { - -- 'nvimdev/dashboard-nvim', - -- event = 'VimEnter', - -- opts = { - -- -- theme = 'doom', - -- theme = 'hyper', - -- shortcut_type = 'number', - -- config = { - -- shortcut = { - -- -- action can be a function type - -- { - -- desc = "Files", - -- group = '', - -- key = 'f', - -- action = 'edit .' - -- }, - -- }, - -- packages = { enable = false }, -- show how many plugins neovim loaded - -- -- limit how many projects list, action when you press key or enter it will run this action. - -- -- action can be a functino type, e.g. - -- -- action = func(path) vim.cmd('Telescope find_files cwd=' .. path) end - -- project = { - -- enable = true, - -- limit = 8, - -- -- icon = ' ', - -- label = '', - -- action = 'edit' - -- }, - -- mru = { - -- limit = 10, - -- -- icon = 'your icon', - -- label = '', - -- }, - -- footer = {}, -- footer - -- } - -- }, - -- dependencies = { { 'nvim-tree/nvim-web-devicons' } } - -- }, -} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index a0b21df..eda0fff 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -1,6 +1,10 @@ return { 'akinsho/toggleterm.nvim', cmd = 'ToggleTerm', + keys = { + { "", 'ToggleTerm direction=horizontal', mode = { 'n', 't', 'v', 'i' }, desc = "Toggle Terminal" }, + { "", 'ToggleTerm direction=float', mode = { 'n', 't', 'v', 'i' }, desc = "Toggle Terminal floating" }, + }, opts = { -- size can be a number or function which is passed the current terminal -- size = function(term) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index dabc361..0c956ad 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,13 +1,17 @@ return { 'nvim-treesitter/nvim-treesitter', -- lazy = false, - -- dependencies = { 'nvim-treesitter/playground' }, + dependencies = { 'rush-rs/tree-sitter-asm' }, -- dependencies = 'windwp/nvim-ts-autotag', event = 'VeryLazy', - init = function(plugin) - require("lazy.core.loader").add_to_rtp(plugin) - require("nvim-treesitter.query_predicates") - end, + keys = { + { 's', desc = 'start incremental selection' }, + { 'h', 'TSBufToggle highlight', desc = 'toggle TS highlight' }, + }, + -- init = function(plugin) + -- require('lazy.core.loader').add_to_rtp(plugin) + -- require 'nvim-treesitter.query_predicates' + -- end, config = function() require('nvim-treesitter.parsers').get_parser_configs().asm = { install_info = { @@ -20,14 +24,30 @@ return { configs.setup { ignore_install = { 'haskell' }, + ensure_installed = { 'c', 'rust', 'lua', 'vim', 'vimdoc', 'cpp', 'go' }, + auto_install = true, highlight = { enable = true, -- false will disable the whole extension - disable = { 'html' }, }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = 's', + node_incremental = '', + scope_incremental = false, + node_decremental = '', + }, + }, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + disable = function(_, buf) + local max_filesize = 300 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, -- context_commentstring = { enable = true, config = { css = '// %s' } }, - -- indent = {enable = true, disable = {"python", "html", "javascript"}}, - -- TODO seems to be broken - indent = { enable = true, disable = { 'python', 'css' } }, + indent = { enable = true }, -- autotag = { enable = true }, } end, diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua new file mode 100644 index 0000000..c74f319 --- /dev/null +++ b/lua/plugins/ui.lua @@ -0,0 +1,152 @@ +return { + { + 'blazkowolf/gruber-darker.nvim', + lazy = false, + opts = { + -- invert = { + -- signs = true, + -- tabline = true, + -- visual = true, + -- }, + }, + }, + { + 'freddiehaddad/feline.nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = function() + local feline = require 'feline' + local utils = require 'config.utils' + local c = utils.feline_c + local theme = utils.feline_theme_dark + -- if l then + -- theme = utils.feline_theme_light + -- else + -- theme = utils.feline_theme_dark + -- end + local vi_mode_colors = utils.feline_vi_mode_colors + + local left = { + c.vim_mode, + -- c.gitBranch, + -- c.gitDiffAdded, + -- c.gitDiffRemoved, + -- c.gitDiffChanged, + c.file_info, + c.right_separator, + c.lsp_client_names, + c.diagnostic_errors, + c.diagnostic_warnings, + c.diagnostic_info, + c.diagnostic_hints, + } + + -- local middle = { + -- c.separator, + -- } + + local right = { + c.file_type, + c.search_count, + c.macro, + c.file_encoding, + -- c.startup, + c.line_percentage, + c.select_count, + c.position, + } + + local components = { + active = { + left, + -- middle, + right, + }, + inactive = { + left, + -- middle, + right, + }, + } + + feline.setup { + components = components, + theme = theme, + vi_mode_colors = vi_mode_colors, + } + end, + }, + { + 'rcarriga/nvim-notify', + lazy = true, + keys = { + { + 'k', + function() + require('notify').dismiss() + end, + desc = 'dismiss notifications', + }, + }, + init = function() + vim.notify = function(...) + return require 'notify' (...) + end + end, + }, + { + 'stevearc/dressing.nvim', + lazy = true, + opts = { + input = { + win_options = { winblend = 0 }, + }, + }, + init = function() + ---@diagnostic disable-next-line: duplicate-set-field + vim.ui.select = function(...) + require('lazy').load { plugins = { 'dressing.nvim' } } + return vim.ui.select(...) + end + ---@diagnostic disable-next-line: duplicate-set-field + vim.ui.input = function(...) + require('lazy').load { plugins = { 'dressing.nvim' } } + return vim.ui.input(...) + end + end, + }, + { + "lukas-reineke/indent-blankline.nvim", + event = { "BufReadPost", "BufNewFile" }, + main = "ibl", + config = function() + local highlight = { + "RainbowRed", + "RainbowYellow", + "RainbowBlue", + "RainbowOrange", + "RainbowGreen", + "RainbowViolet", + "RainbowCyan", + } + local hooks = require "ibl.hooks" + -- create the highlight groups in the highlight setup hook, so they are reset + -- every time the colorscheme changes + 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, show_start = false } } + + hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) + end + } +} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/unused/none-ls.lua.bak similarity index 97% rename from lua/plugins/none-ls.lua rename to lua/plugins/unused/none-ls.lua.bak index 0fda725..57c4345 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/unused/none-ls.lua.bak @@ -29,8 +29,8 @@ return { -- 'google', -- }, -- }, - formatting.beautysh, - formatting.latexindent, + -- formatting.beautysh, + -- formatting.latexindent, formatting.goimports, formatting.gofumpt, formatting.sql_formatter, diff --git a/lua/plugins/trouble.lua b/lua/plugins/unused/trouble.lua.bak similarity index 100% rename from lua/plugins/trouble.lua rename to lua/plugins/unused/trouble.lua.bak diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 0000000..9fc4b94 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,80 @@ +return { + 'folke/which-key.nvim', + event = 'VeryLazy', + config = function() + local wk = require 'which-key' + wk.setup { + plugins = { + marks = true, -- shows a list of your marks on ' and ` + registers = true, -- shows your registers on " in NORMAL or in INSERT mode + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = true, -- adds help for operators like d, y, ... + motions = true, -- adds help for motions + text_objects = false, -- help for text objects triggered after entering an operator + windows = true, -- default bindings on + nav = true, -- misc bindings to work with windows + z = true, -- bindings for folds, spelling and others prefixed with z + g = true, -- bindings for prefixed with g + }, + }, + icons = { + breadcrumb = '»', -- symbol used in the command line area that shows your active key combo + separator = '➜ ', -- symbol used between a key and it's label + group = '+', -- symbol prepended to a group + }, + window = { + border = 'none', -- none, single, double, shadow + position = 'bottom', -- bottom, top + margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 1, 1, 1, 1 }, -- extra window padding [top, right, bottom, left] + }, + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + }, + hidden = { '', '', '', '', 'call', 'lua', '^:', '^ ' }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible + } + local opts = { + mode = 'n', -- NORMAL mode + prefix = '', + buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings + silent = true, -- use `silent` when creating keymaps + noremap = true, -- use `noremap` when creating keymaps + nowait = false, -- use `nowait` when creating keymaps + } + local mappings = { + ['o'] = { 'e ~/.config/nvim/ ', 'Neovim config' }, + ['rr'] = 'Search and replace all', + ['rs'] = 'Search and replace', + ['q'] = { 'lua UnMapDHM()', 'qwerty' }, + ['c'] = { 'lua MapDHM()', 'colemak' }, + [';'] = { 'bd', 'Delete buffer' }, + [''] = { + name = 'Tab', + n = { 'tabnew', 'New' }, + p = { 'tabp', 'Previous' }, + d = { 'tabclose', 'Close' }, + [''] = { 'tabnext', 'Next' }, + ['1'] = { '1gt', 'Go to tab 1' }, + ['2'] = { '2gt', 'Go to tab 2' }, + ['3'] = { '3gt', 'Go to tab 3' }, + ['4'] = { '4gt', 'Go to tab 4' }, + ['5'] = { '5gt', 'Go to tab 5' }, + ['6'] = { '6gt', 'Go to tab 6' }, + ['7'] = { '7gt', 'Go to tab 7' }, + ['8'] = { '8gt', 'Go to tab 8' }, + ['9'] = { '9gt', 'Go to tab 9' }, + }, + w = { + name = 'Window', + v = { 'v', 'Vertical split' }, + h = { 's', 'Horizontal split' }, + }, + } + wk.register(mappings, opts) + end, +} diff --git a/lua/plugins/wildcat.lua b/lua/plugins/wildcat.lua deleted file mode 100644 index 900f6d0..0000000 --- a/lua/plugins/wildcat.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - 'javiorfo/nvim-wildcat', - lazy = true, - cmd = { "WildcatRun" }, - dependencies = { 'javiorfo/nvim-popcorn' }, - opts = { - tomcat = { - home = "/home/fiplox/Software/apache-tomcat-10.1.13/", - app_base = "webapps", - default = true - } - } -} diff --git a/lua/utils.lua b/lua/utils.lua new file mode 100644 index 0000000..8e88d90 --- /dev/null +++ b/lua/utils.lua @@ -0,0 +1,17 @@ +local M = {} + +function M.telescope(builtin) + return function() + require("telescope.builtin")[builtin]() + end +end + +function M.get_or_default(value, default) + if value ~= nil then + return value + else + return default + end +end + +return M diff --git a/spell/fr.utf-8.spl b/spell/fr.utf-8.spl new file mode 100644 index 0000000..ff27132 Binary files /dev/null and b/spell/fr.utf-8.spl differ diff --git a/spell/fr.utf-8.sug b/spell/fr.utf-8.sug new file mode 100644 index 0000000..df555d2 Binary files /dev/null and b/spell/fr.utf-8.sug differ