From 3d0035b92221f0d8c2c131fd0e7c4a3a0501ee30 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 22 Nov 2023 23:59:39 +0200 Subject: New function find_private() --- lua/plugins/telescope.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index e4c62c2..2ba1195 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -404,6 +404,19 @@ function M.find_notes() search_dirs = { '~/documents/notes/private/', '~/documents/notes', + }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) +end + +function M.find_private() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = false, + prompt_title = ' Find Notes', + path_display = { 'smart' }, + search_dirs = { '~/notes/private', '~/notes', }, -- cgit v1.2.3 From c2eb403d49bf8d9bdf62b58de5f40bc3a451d3bc Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 22 Nov 2023 23:59:54 +0200 Subject: Add telescope find_private() --- lua/user/keys.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index a70eef6..fa59150 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -297,6 +297,7 @@ map('n', 'ffw', [[lua require'plugins.telescope'.find_projects()ffb', [[lua require'plugins.telescope'.find_books()]]) -- find books map('n', 'ffn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes +map('n', 'ffp', [[lua require'plugins.telescope'.find_private()]]) -- search notes map('n', 'frf', "lua require('telescope').extensions.recent_files.pick()") map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") map('n', 'f/', "lua require('telescope').extensions.file_browser.file_browser()") -- cgit v1.2.3 From 7c09a0c3c88235a449f8472716078983ab715e09 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 23 Dec 2023 13:20:05 +0200 Subject: Add telescope find_logs() keybinding --- lua/user/keys.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index fa59150..78a9e94 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -298,6 +298,7 @@ map('n', 'ffb', [[lua require'plugins.telescope'.find_books()]] map('n', 'ffn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes map('n', 'ffp', [[lua require'plugins.telescope'.find_private()]]) -- search notes +map('n', 'ffl', [[lua require'plugins.telescope'.find_logs()]]) -- search notes map('n', 'frf', "lua require('telescope').extensions.recent_files.pick()") map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") map('n', 'f/', "lua require('telescope').extensions.file_browser.file_browser()") -- cgit v1.2.3 From ae17b4311f43b996686cf4fbb6838aa75fe3205b Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 16 Jan 2024 22:46:37 +0200 Subject: Create new file with e --- lua/user/keys.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 78a9e94..3b615ae 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -40,6 +40,12 @@ map('n', 'q', function() end end, { expr = true, replace_keycodes = true }) +-- Write as sudo +map('c', 'W', "exe 'w !sudo tee >/dev/null %:p:S' | setl nomod", { silent = true, desc = 'Write as Sudo' }) + +-- Create new file +map('n', 'e', [[:e =expand("%:h")..'/']], { noremap = true, silent = true, desc = 'New file' }) + -- Combine buffers list with buffer name map('n', 'b', ':buffers:buffer') @@ -274,7 +280,7 @@ map('n', 'gm', ':Gmove') -- Telescope map('n', 'ff', ":cd %:p:h:pwdlua require('telescope.builtin').find_files()") -- find files with hidden option -map('n', 'fF', ":cd %:p:h:pwdlua require('user.mods').findFilesInCwd()", { noremap = true, silent = true, desc = 'Find files in cwd' }) +map('n', 'fF', ':cd %:p:h:pwdlua require("user.mods").findFilesInCwd()', { noremap = true, silent = true, desc = 'Find files in cwd' }) map('n', 'f.', function() require('telescope.builtin').find_files({ hidden = true, no_ignore = true }) end) -- find all files -- cgit v1.2.3 From cad1eccc2ea4633a3f9236755727fea7351377d5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 16 Jan 2024 22:46:54 +0200 Subject: Edit glow path --- lua/user/pack.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 1a37d28..6c99473 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -362,8 +362,19 @@ return packer.startup(function(use) use({ 'ellisonleao/glow.nvim', -- Markdown Preview config = function() + local glow_path + + -- Check if glow exists in ~/.local/bin + if vim.fn.executable('~/.local/bin/glow') == 1 then + glow_path = '~/.local/bin/glow' + else + -- Fallback to /usr/bin/glow + glow_path = '/usr/bin/glow' + end + require('glow').setup({ style = 'dark', + glow_path = glow_path, }) end, }) -- cgit v1.2.3 From ab9469df6b83768278e6724599131aeed3afe11e Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 16 Jan 2024 22:47:29 +0200 Subject: Troubleshooting tree taking long to load --- lua/plugins/nvim-tree.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index f82a327..902a278 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -207,6 +207,11 @@ require('nvim-tree').setup({ --respect_buf_cwd = false, sync_root_with_cwd = true, --reload_on_bufenter = false, + filesystem_watchers = { + enable = true, + debounce_delay = 50, + ignore_dirs = { 'node_modules' }, + }, view = view, system_open = system_open, renderer = renderer, @@ -214,6 +219,16 @@ require('nvim-tree').setup({ notify = { threshold = vim.log.levels.ERROR, }, + log = { + enable = true, + truncate = true, + types = { + diagnostics = true, + git = true, + profile = true, + watcher = true, + }, + }, git = { ignore = false }, diagnostics = { enable = true, -- cgit v1.2.3 From ef9c7a4c61d608a61b42c31c025fa2b98bddc131 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 19 Jan 2024 18:19:31 +0200 Subject: Write as sudo --- lua/user/keys.lua | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 3b615ae..11de667 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -40,12 +40,12 @@ map('n', 'q', function() end end, { expr = true, replace_keycodes = true }) --- Write as sudo -map('c', 'W', "exe 'w !sudo tee >/dev/null %:p:S' | setl nomod", { silent = true, desc = 'Write as Sudo' }) - --- Create new file +-- Edit new file map('n', 'e', [[:e =expand("%:h")..'/']], { noremap = true, silent = true, desc = 'New file' }) +-- Write as sudo +map('c', 'W', "exe 'w !sudo tee >/dev/null %:p:S' | setl nomod", { silent = true, desc = 'Write as Sudo' }) + -- Combine buffers list with buffer name map('n', 'b', ':buffers:buffer') @@ -280,7 +280,7 @@ map('n', 'gm', ':Gmove') -- Telescope map('n', 'ff', ":cd %:p:h:pwdlua require('telescope.builtin').find_files()") -- find files with hidden option -map('n', 'fF', ':cd %:p:h:pwdlua require("user.mods").findFilesInCwd()', { noremap = true, silent = true, desc = 'Find files in cwd' }) +map('n', 'fF', ":cd %:p:h:pwdlua require('user.mods').findFilesInCwd()", { noremap = true, silent = true, desc = 'Find files in cwd' }) map('n', 'f.', function() require('telescope.builtin').find_files({ hidden = true, no_ignore = true }) end) -- find all files @@ -303,8 +303,6 @@ map('n', 'ffw', [[lua require'plugins.telescope'.find_projects()ffb', [[lua require'plugins.telescope'.find_books()]]) -- find books map('n', 'ffn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes -map('n', 'ffp', [[lua require'plugins.telescope'.find_private()]]) -- search notes -map('n', 'ffl', [[lua require'plugins.telescope'.find_logs()]]) -- search notes map('n', 'frf', "lua require('telescope').extensions.recent_files.pick()") map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") map('n', 'f/', "lua require('telescope').extensions.file_browser.file_browser()") -- cgit v1.2.3 From 818abc092a89c7ae8e975e2f4d9d6de005f5bd09 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 19 Jan 2024 18:20:38 +0200 Subject: Disabled keys = up/down (not disabled) --- lua/plugins/hardtime.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/plugins/hardtime.lua b/lua/plugins/hardtime.lua index e058b8b..0a93f1b 100644 --- a/lua/plugins/hardtime.lua +++ b/lua/plugins/hardtime.lua @@ -13,6 +13,10 @@ end hardtime.setup({ -- hardtime config here disabled_filetypes = { 'qf', 'netrw', 'NvimTree', 'NvimTree_1', 'lazy', 'mason', 'oil', 'dashboard' }, + disabled_keys = { + [''] = {}, + [''] = {}, + }, }) return { -- cgit v1.2.3 From 055d53133eb7b86589b0ce04281ad27d8732753e Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 26 Jan 2024 23:55:03 +0200 Subject: Restriction_mode = 'hint' and disable_mouse = false --- lua/plugins/hardtime.lua | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lua/plugins/hardtime.lua b/lua/plugins/hardtime.lua index 0a93f1b..cb03468 100644 --- a/lua/plugins/hardtime.lua +++ b/lua/plugins/hardtime.lua @@ -1,5 +1,19 @@ local hardtime = require('hardtime') +hardtime.setup({ + -- hardtime config here + enabled = true, + restriction_mode = 'hint', + disabled_filetypes = { 'qf', 'netrw', 'NvimTree', 'NvimTree_1', 'lazy', 'mason', 'oil', 'dashboard' }, + disable_mouse = false, + disabled_keys = { + [''] = {}, + [''] = {}, + [''] = {}, + [''] = {}, + }, +}) + -- Function to toggle the hardtime state and echo a message local hardtime_enabled = true @@ -10,15 +24,6 @@ function ToggleHardtime() vim.cmd('echo "' .. message .. '"') end -hardtime.setup({ - -- hardtime config here - disabled_filetypes = { 'qf', 'netrw', 'NvimTree', 'NvimTree_1', 'lazy', 'mason', 'oil', 'dashboard' }, - disabled_keys = { - [''] = {}, - [''] = {}, - }, -}) - return { ToggleHardtime = ToggleHardtime, } -- cgit v1.2.3 From af7744e4b5d3490ac05b04f00cc0d39c9064d95c Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 10 Feb 2024 23:27:32 +0200 Subject: Ignore .config/nvm --- lua/plugins/nvim-tree.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 902a278..b9ae3f1 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -210,7 +210,7 @@ require('nvim-tree').setup({ filesystem_watchers = { enable = true, debounce_delay = 50, - ignore_dirs = { 'node_modules' }, + ignore_dirs = { 'node_modules', '.config/nvm' }, }, view = view, system_open = system_open, -- cgit v1.2.3 From ac2fee06b46816f582c9ef4ab6858c4ce6acc469 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 10 Feb 2024 23:28:05 +0200 Subject: Add history to search_dirs for M.find_configs() --- lua/plugins/telescope.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 2ba1195..506be8b 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -324,6 +324,9 @@ function M.find_configs() table.insert(tracked_files, os.getenv('HOME') .. '/' .. file) end + local history = os.getenv('HOME') .. '/.config/zsh/.zhistory' + table.insert(tracked_files, history) + require('telescope.builtin').find_files({ hidden = true, no_ignore = false, -- cgit v1.2.3 From 61de4331abc2f6663e895d3a5f7c8381130a6a0c Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 10 Feb 2024 23:28:33 +0200 Subject: Auto-formatted --- init.lua | 122 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/init.lua b/init.lua index 30adcac..92df3d2 100644 --- a/init.lua +++ b/init.lua @@ -44,60 +44,60 @@ --$ nvim --startuptime startup.log -c exit && tail -100 startup.log -- Load impatient (Faster loading times) -local impatient_ok, impatient = pcall(require, 'impatient') +local impatient_ok, impatient = pcall(require, "impatient") if impatient_ok then impatient.enable_profile() end -- Schedule reading shadafile to improve the startup time -vim.opt.shadafile = 'NONE' +vim.opt.shadafile = "NONE" vim.schedule(function() - vim.opt.shadafile = '' - vim.cmd('silent! rsh') + vim.opt.shadafile = "" + vim.cmd("silent! rsh") end) -- Load/reload modules local modules = { - 'user.pack', -- Packer plugin manager - 'user.opts', -- Options - 'user.keys', -- Keymaps - 'user.mods', -- Modules/functions - 'user.view', -- Colorscheme/UI - 'plugins.web-devicons', - 'plugins.treesitter', - 'plugins.neodev', - 'plugins.telescope', - 'plugins.nvim-tree', - 'plugins.lsp', - 'plugins.cmp', - 'plugins.quickfix', + "user.pack", -- Packer plugin manager + "user.opts", -- Options + "user.keys", -- Keymaps + "user.mods", -- Modules/functions + "user.view", -- Colorscheme/UI + "plugins.web-devicons", + "plugins.treesitter", + "plugins.neodev", + "plugins.telescope", + "plugins.nvim-tree", + "plugins.lsp", + "plugins.cmp", + "plugins.quickfix", --"plugins.snippets", --"plugins.colorizer", --"plugins.prettier", --"plugins.git", --"plugins.fugitive", - 'plugins.gitsigns', - 'plugins.sniprun', - 'plugins.session', - 'plugins.neoscroll', - 'plugins.statuscol', - 'plugins.trouble', - 'plugins.goto-preview', - 'plugins.autopairs', - 'plugins.navic', - 'plugins.toggleterm', - 'plugins.zen-mode', - 'plugins.fidget', - 'plugins.dap', - 'plugins.neotest', - 'plugins.heirline', - 'plugins.dashboard', - 'plugins.which-key', - 'plugins.harpoon', - 'plugins.leetcode', - 'plugins.hardtime', - 'plugins.notify', - 'plugins.overseer', + "plugins.gitsigns", + "plugins.sniprun", + "plugins.session", + "plugins.neoscroll", + "plugins.statuscol", + "plugins.trouble", + "plugins.goto-preview", + "plugins.autopairs", + "plugins.navic", + "plugins.toggleterm", + "plugins.zen-mode", + "plugins.fidget", + "plugins.dap", + "plugins.neotest", + "plugins.heirline", + "plugins.dashboard", + "plugins.which-key", + "plugins.harpoon", + "plugins.leetcode", + "plugins.hardtime", + "plugins.notify", + "plugins.overseer", --"plugins.modify-blend", } @@ -109,32 +109,32 @@ end -- Improve speed by disabling some default plugins/modules local builtins = { - 'gzip', - 'zip', - 'zipPlugin', - 'tar', - 'tarPlugin', - 'getscript', - 'getscriptPlugin', - 'vimball', - 'vimballPlugin', - '2html_plugin', + "gzip", + "zip", + "zipPlugin", + "tar", + "tarPlugin", + "getscript", + "getscriptPlugin", + "vimball", + "vimballPlugin", + "2html_plugin", --"matchit", --"matchparen", - 'logiPat', - 'rrhelper', - 'netrw', - 'netrwPlugin', - 'netrwSettings', - 'netrwFileHandlers', - 'tutor_mode_plugin', - 'fzf', - 'spellfile_plugin', - 'sleuth', + "logiPat", + "rrhelper", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "tutor_mode_plugin", + "fzf", + "spellfile_plugin", + "sleuth", } for _, plugin in ipairs(builtins) do - vim.g['loaded_' .. plugin] = 1 + vim.g["loaded_" .. plugin] = 1 end vim.g.do_filetype_lua = 1 vim.g.did_load_filetypes = 0 @@ -143,4 +143,4 @@ vim.g.did_load_filetypes = 0 --vim.g.snippets = 'luasnip' -- Notifications -vim.notify = require('notify') -- Requires plugin "rcarriga/nvim-notify" +vim.notify = require("notify") -- Requires plugin "rcarriga/nvim-notify" -- cgit v1.2.3 From 840c6c431f84cd1fe8cb91503024c3234467a471 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 18 Feb 2024 23:57:04 +0200 Subject: Changed highlight for executable files --- lua/plugins/nvim-tree.lua | 279 +++++++++++++++++++++++----------------------- 1 file changed, 142 insertions(+), 137 deletions(-) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index b9ae3f1..e817c04 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -5,11 +5,15 @@ --- To see mappings `g?` on nvim-tree --- To see default mappings `:nvim-tree-default-mappings` +-- Nvim-Tree.lua advises to do this at the start. +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + local icons = { webdev_colors = true, - git_placement = 'signcolumn', - modified_placement = 'after', - padding = ' ', + git_placement = "signcolumn", + modified_placement = "after", + padding = " ", show = { file = true, folder = true, @@ -19,27 +23,27 @@ local icons = { }, glyphs = { - default = '󰈔', - symlink = '', + default = "󰈔", + symlink = "", folder = { - arrow_open = '', - arrow_closed = '', - default = ' ', - open = ' ', - empty = ' ', - empty_open = ' ', - symlink = '', - symlink_open = '', + arrow_open = "", + arrow_closed = "", + default = " ", + open = " ", + empty = " ", + empty_open = " ", + symlink = "", + symlink_open = "", }, git = { - deleted = '', - unmerged = '', - untracked = '', - unstaged = '', - staged = '', - renamed = '➜', - ignored = '◌', + deleted = "", + unmerged = "", + untracked = "", + unstaged = "", + staged = "", + renamed = "➜", + ignored = "◌", }, }, web_devicons = { @@ -54,25 +58,24 @@ local renderer = { group_empty = true, -- default: true. Compact folders that only contain a single folder into one node in the file tree. highlight_git = false, full_name = false, - highlight_opened_files = 'icon', -- "none" (default), "icon", "name" or "all" - highlight_modified = 'icon', -- "none", "name" or "all". Nice and subtle, override the open icon - root_folder_label = ':~:s?$?/..?', + highlight_opened_files = "icon", -- "none" (default), "icon", "name" or "all" + highlight_modified = "icon", -- "none", "name" or "all". Nice and subtle, override the open icon + root_folder_label = ":~:s?$?/..?", indent_width = 2, indent_markers = { enable = true, inline_arrows = true, icons = { - corner = '└', - edge = '│', - item = '│', - bottom = '─', - none = ' ', + corner = "└", + edge = "│", + item = "│", + bottom = "─", + none = " ", }, }, icons = icons, } - -local system_open = { cmd = 'zathura' } +local system_open = { cmd = "zathura" } local HEIGHT_RATIO = 0.8 local WIDTH_RATIO = 0.15 @@ -89,8 +92,8 @@ local float = { local center_x = (screen_w - window_w) / 2 local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get() return { - border = 'rounded', - relative = 'editor', + border = "rounded", + relative = "editor", row = center_y, col = center_x, width = window_w_int, @@ -103,89 +106,90 @@ local view = { cursorline = true, float = float, --signcolumn = 'no', - width = function() - return math.floor(vim.opt.columns:get() * WIDTH_RATIO) - end, - side = 'left', + --width = function() + -- return math.floor(vim.opt.columns:get() * WIDTH_RATIO) + --end, + width = { max = 38, min = 38 }, + side = "left", } -local api = require('nvim-tree.api') +local api = require("nvim-tree.api") local function on_attach(bufnr) local function opts(desc) - return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } end local mappings = { - [''] = { api.tree.change_root_to_node, 'CD' }, - [''] = { api.node.open.replace_tree_buffer, 'Open: In Place' }, - [''] = { api.node.show_info_popup, 'Info' }, - [''] = { api.fs.rename_sub, 'Rename: Omit Filename' }, - [''] = { api.node.open.tab, 'Open: New Tab' }, - [''] = { api.node.open.vertical, 'Open: Vertical Split' }, - [''] = { api.node.open.horizontal, 'Open: Horizontal Split' }, - [''] = { api.node.navigate.parent_close, 'Close Directory' }, + [""] = { api.tree.change_root_to_node, "CD" }, + [""] = { api.node.open.replace_tree_buffer, "Open: In Place" }, + [""] = { api.node.show_info_popup, "Info" }, + [""] = { api.fs.rename_sub, "Rename: Omit Filename" }, + [""] = { api.node.open.tab, "Open: New Tab" }, + [""] = { api.node.open.vertical, "Open: Vertical Split" }, + [""] = { api.node.open.horizontal, "Open: Horizontal Split" }, + [""] = { api.node.navigate.parent_close, "Close Directory" }, -- [""] = { api.node.open.edit, "Open" }, - [''] = { api.node.open.preview, 'Open Preview' }, - ['>'] = { api.node.navigate.sibling.next, 'Next Sibling' }, - ['<'] = { api.node.navigate.sibling.prev, 'Previous Sibling' }, - ['.'] = { api.node.run.cmd, 'Run Command' }, - ['-'] = { api.tree.change_root_to_parent, 'Up' }, - ['a'] = { api.fs.create, 'Create' }, - ['bmv'] = { api.marks.bulk.move, 'Move Bookmarked' }, - ['B'] = { api.tree.toggle_no_buffer_filter, 'Toggle No Buffer' }, - ['c'] = { api.fs.copy.node, 'Copy' }, + [""] = { api.node.open.preview, "Open Preview" }, + [">"] = { api.node.navigate.sibling.next, "Next Sibling" }, + ["<"] = { api.node.navigate.sibling.prev, "Previous Sibling" }, + ["."] = { api.node.run.cmd, "Run Command" }, + ["-"] = { api.tree.change_root_to_parent, "Up" }, + ["a"] = { api.fs.create, "Create" }, + ["bmv"] = { api.marks.bulk.move, "Move Bookmarked" }, + ["B"] = { api.tree.toggle_no_buffer_filter, "Toggle No Buffer" }, + ["c"] = { api.fs.copy.node, "Copy" }, -- ["C"] = { api.tree.toggle_git_clean_filter, "Toggle Git Clean" }, - ['[c'] = { api.node.navigate.git.prev, 'Prev Git' }, - [']c'] = { api.node.navigate.git.next, 'Next Git' }, - ['d'] = { api.fs.remove, 'Delete' }, - ['D'] = { api.fs.trash, 'Trash' }, - ['E'] = { api.tree.expand_all, 'Expand All' }, - ['e'] = { api.fs.rename_basename, 'Rename: Basename' }, - [']e'] = { api.node.navigate.diagnostics.next, 'Next Diagnostic' }, - ['[e'] = { api.node.navigate.diagnostics.prev, 'Prev Diagnostic' }, - ['F'] = { api.live_filter.clear, 'Clean Filter' }, - ['f'] = { api.live_filter.start, 'Filter' }, - ['g?'] = { api.tree.toggle_help, 'Help' }, - ['gy'] = { api.fs.copy.absolute_path, 'Copy Absolute Path' }, - ['H'] = { api.tree.toggle_hidden_filter, 'Toggle Dotfiles' }, - ['I'] = { api.tree.toggle_gitignore_filter, 'Toggle Git Ignore' }, - ['J'] = { api.node.navigate.sibling.last, 'Last Sibling' }, - ['K'] = { api.node.navigate.sibling.first, 'First Sibling' }, - ['m'] = { api.marks.toggle, 'Toggle Bookmark' }, + ["[c"] = { api.node.navigate.git.prev, "Prev Git" }, + ["]c"] = { api.node.navigate.git.next, "Next Git" }, + ["d"] = { api.fs.remove, "Delete" }, + ["D"] = { api.fs.trash, "Trash" }, + ["E"] = { api.tree.expand_all, "Expand All" }, + ["e"] = { api.fs.rename_basename, "Rename: Basename" }, + ["]e"] = { api.node.navigate.diagnostics.next, "Next Diagnostic" }, + ["[e"] = { api.node.navigate.diagnostics.prev, "Prev Diagnostic" }, + ["F"] = { api.live_filter.clear, "Clean Filter" }, + ["f"] = { api.live_filter.start, "Filter" }, + ["g?"] = { api.tree.toggle_help, "Help" }, + ["gy"] = { api.fs.copy.absolute_path, "Copy Absolute Path" }, + ["H"] = { api.tree.toggle_hidden_filter, "Toggle Dotfiles" }, + ["I"] = { api.tree.toggle_gitignore_filter, "Toggle Git Ignore" }, + ["J"] = { api.node.navigate.sibling.last, "Last Sibling" }, + ["K"] = { api.node.navigate.sibling.first, "First Sibling" }, + ["m"] = { api.marks.toggle, "Toggle Bookmark" }, -- ["o"] = { api.node.open.edit, "Open" }, - ['O'] = { api.node.open.no_window_picker, 'Open: No Window Picker' }, - ['p'] = { api.fs.paste, 'Paste' }, - ['P'] = { api.node.navigate.parent, 'Parent Directory' }, - ['q'] = { api.tree.close, 'Close' }, - ['r'] = { api.fs.rename, 'Rename' }, - ['R'] = { api.tree.reload, 'Refresh' }, - ['s'] = { api.node.run.system, 'Run System' }, - ['S'] = { api.tree.search_node, 'Search' }, - ['U'] = { api.tree.toggle_custom_filter, 'Toggle Hidden' }, - ['W'] = { api.tree.collapse_all, 'Collapse' }, - ['x'] = { api.fs.cut, 'Cut' }, - ['y'] = { api.fs.copy.filename, 'Copy Name' }, - ['Y'] = { api.fs.copy.relative_path, 'Copy Relative Path' }, - ['<2-LeftMouse>'] = { api.node.open.edit, 'Open' }, - ['<2-RightMouse>'] = { api.tree.change_root_to_node, 'CD' }, + ["O"] = { api.node.open.no_window_picker, "Open: No Window Picker" }, + ["p"] = { api.fs.paste, "Paste" }, + ["P"] = { api.node.navigate.parent, "Parent Directory" }, + ["q"] = { api.tree.close, "Close" }, + ["r"] = { api.fs.rename, "Rename" }, + ["R"] = { api.tree.reload, "Refresh" }, + ["s"] = { api.node.run.system, "Run System" }, + ["S"] = { api.tree.search_node, "Search" }, + ["U"] = { api.tree.toggle_custom_filter, "Toggle Hidden" }, + ["W"] = { api.tree.collapse_all, "Collapse" }, + ["x"] = { api.fs.cut, "Cut" }, + ["y"] = { api.fs.copy.filename, "Copy Name" }, + ["Y"] = { api.fs.copy.relative_path, "Copy Relative Path" }, + ["<2-LeftMouse>"] = { api.node.open.edit, "Open" }, + ["<2-RightMouse>"] = { api.tree.change_root_to_node, "CD" }, -- Mappings migrated from view.mappings.list - ['l'] = { api.node.open.edit, 'Open' }, - [''] = { api.node.open.edit, 'Open' }, - ['o'] = { api.node.open.edit, 'Open' }, - ['h'] = { api.node.navigate.parent_close, 'Close Directory' }, - ['v'] = { api.node.open.vertical, 'Open: Vertical Split' }, - ['C'] = { api.tree.change_root_to_node, 'CD' }, + ["l"] = { api.node.open.edit, "Open" }, + [""] = { api.node.open.edit, "Open" }, + ["o"] = { api.node.open.edit, "Open" }, + ["h"] = { api.node.navigate.parent_close, "Close Directory" }, + ["v"] = { api.node.open.vertical, "Open: Vertical Split" }, + ["C"] = { api.tree.change_root_to_node, "CD" }, } for keys, mapping in pairs(mappings) do - vim.keymap.set('n', keys, mapping[1], opts(mapping[2])) + vim.keymap.set("n", keys, mapping[1], opts(mapping[2])) end end --api.events.subscribe(api.events.Event.FileCreated, function(file) -- vim.cmd('edit' .. file.fname) --end) -require('nvim-tree').setup({ +require("nvim-tree").setup({ --auto_reload_on_write = true, --create_in_closed_folder = false, --hijack_cursor = true, @@ -210,7 +214,7 @@ require('nvim-tree').setup({ filesystem_watchers = { enable = true, debounce_delay = 50, - ignore_dirs = { 'node_modules', '.config/nvm' }, + ignore_dirs = { "node_modules", ".config/nvm" }, }, view = view, system_open = system_open, @@ -234,14 +238,14 @@ require('nvim-tree').setup({ enable = true, show_on_dirs = true, icons = { - hint = '⚑', - info = '􀅳', - warning = '▲', - error = '', + hint = "⚑", + info = "􀅳", + warning = "▲", + error = "", }, }, trash = { - cmd = 'gio trash', + cmd = "gio trash", require_confirm = true, }, modified = { @@ -272,17 +276,17 @@ require('nvim-tree').setup({ resize_window = false, window_picker = { enable = true, - chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', + chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", exclude = { - filetype = { 'notify', 'packer', 'qf', 'diff', 'fugitive', 'fugitiveblame' }, - buftype = { 'nofile', 'terminal', 'help' }, + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, }, }, }, }, }) -local api = require('nvim-tree.api') +local api = require("nvim-tree.api") local event = api.events.Event --api.events.subscribe(event.TreeOpen, function(_) -- vim.cmd([[setlocal statuscolumn=\ ]]) @@ -293,32 +297,32 @@ local event = api.events.Event --end) local function open_nvim_tree(data) - vim.cmd.cd(data.file:match('(.+)/[^/]*$')) + vim.cmd.cd(data.file:match("(.+)/[^/]*$")) local directory = vim.fn.isdirectory(data.file) == 1 if not directory then return end - require('nvim-tree.api').tree.open() + require("nvim-tree.api").tree.open() end -vim.api.nvim_create_autocmd({ 'VimEnter' }, { callback = open_nvim_tree }) +vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) -- Change Root To Global Current Working Directory local function change_root_to_global_cwd() - local api = require('nvim-tree.api') + local api = require("nvim-tree.api") local global_cwd = vim.fn.getcwd(-1, -1) api.tree.change_root(global_cwd) end local function copy_file_to(node) - local file_src = node['absolute_path'] + local file_src = node["absolute_path"] -- The args of input are {prompt}, {default}, {completion} -- Read in the new file path using the existing file's path as the baseline. - local file_out = vim.fn.input('COPY TO: ', file_src, 'file') + local file_out = vim.fn.input("COPY TO: ", file_src, "file") -- Create any parent dirs as required - local dir = vim.fn.fnamemodify(file_out, ':h') - vim.fn.system({ 'mkdir', '-p', dir }) + local dir = vim.fn.fnamemodify(file_out, ":h") + vim.fn.system({ "mkdir", "-p", dir }) -- Copy the file - vim.fn.system({ 'cp', '-R', file_src, file_out }) + vim.fn.system({ "cp", "-R", file_src, file_out }) end local function edit_and_close(node) @@ -333,48 +337,48 @@ end -- group = 'NvimTreeRefresh', --}) -vim.api.nvim_create_autocmd({ 'CursorHold' }, { - pattern = 'NvimTree*', +vim.api.nvim_create_autocmd({ "CursorHold" }, { + pattern = "NvimTree*", callback = function() - local def = vim.api.nvim_get_hl_by_name('Cursor', true) + local def = vim.api.nvim_get_hl_by_name("Cursor", true) vim.api.nvim_set_hl( 0, - 'Cursor', - vim.tbl_extend('force', def, { + "Cursor", + vim.tbl_extend("force", def, { blend = 100, }) ) - vim.opt.guicursor:append('a:Cursor/lCursor') + vim.opt.guicursor:append("a:Cursor/lCursor") end, }) -vim.api.nvim_create_autocmd({ 'BufLeave', 'WinClosed', 'WinLeave' }, { - pattern = 'NvimTree*', +vim.api.nvim_create_autocmd({ "BufLeave", "WinClosed", "WinLeave" }, { + pattern = "NvimTree*", callback = function() - local def = vim.api.nvim_get_hl_by_name('Cursor', true) + local def = vim.api.nvim_get_hl_by_name("Cursor", true) vim.api.nvim_set_hl( 0, - 'Cursor', - vim.tbl_extend('force', def, { + "Cursor", + vim.tbl_extend("force", def, { blend = 0, }) ) - vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20' + vim.opt.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" end, }) -- Highlight Groups -vim.api.nvim_command('highlight NvimTreeNormal guibg=NONE ctermbg=NONE') -vim.api.nvim_command('highlight NvimTreeNormalNC guibg=NONE ctermbg=NONE guifg=NONE') -vim.api.nvim_command('highlight NvimTreeNormalFloat guibg=NONE ctermbg=NONE') -vim.api.nvim_command('highlight NvimTreeEndOfBuffer guibg=NONE ctermbg=NONE') --(NonText) -vim.api.nvim_command('highlight NvimTreeCursorLine guibg=#50fa7b guifg=#000000') -vim.api.nvim_command('highlight NvimTreeSymlinkFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') -vim.api.nvim_command('highlight NvimTreeFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') -vim.api.nvim_command('highlight NvimTreeRootFolder guifg=#f8f8f2 guibg=NONE ctermbg=NONE') -vim.api.nvim_command('highlight NvimTreeEmptyFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') --(Directory) -vim.api.nvim_command('highlight NvimTreeOpenedFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') --(Directory) -vim.api.nvim_command('highlight NvimTreeOpenedFile guifg=#50fa7b guibg=NONE ctermbg=NONE') +vim.api.nvim_command("highlight NvimTreeNormal guibg=NONE ctermbg=NONE") +vim.api.nvim_command("highlight NvimTreeNormalNC guibg=NONE ctermbg=NONE guifg=NONE") +vim.api.nvim_command("highlight NvimTreeNormalFloat guibg=NONE ctermbg=NONE") +vim.api.nvim_command("highlight NvimTreeEndOfBuffer guibg=NONE ctermbg=NONE") --(NonText) +vim.api.nvim_command("highlight NvimTreeCursorLine guibg=#50fa7b guifg=#000000") +vim.api.nvim_command("highlight NvimTreeSymlinkFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE") +vim.api.nvim_command("highlight NvimTreeFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE") +vim.api.nvim_command("highlight NvimTreeRootFolder guifg=#f8f8f2 guibg=NONE ctermbg=NONE") +vim.api.nvim_command("highlight NvimTreeEmptyFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE") --(Directory) +vim.api.nvim_command("highlight NvimTreeOpenedFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE") --(Directory) +vim.api.nvim_command("highlight NvimTreeOpenedFile guifg=#50fa7b guibg=NONE ctermbg=NONE") --vim.api.nvim_command("highlight NvimTreeSymlink ") --vim.api.nvim_command("highlight NvimTreeSymlinkFolderName ") --(Directory) @@ -387,6 +391,7 @@ vim.api.nvim_command('highlight NvimTreeOpenedFile guifg=#50fa7b guibg=NONE cter --vim.api.nvim_command("highlight NvimTreeEmptyFolderName ") --(Directory) --vim.api.nvim_command("highlight NvimTreeOpenedFolderName ") --(Directory) --vim.api.nvim_command("highlight NvimTreeExecFile ") +vim.api.nvim_command("highlight NvimTreeExecFile guifg=#ff882a guibg=none gui=NONE") --vim.api.nvim_command("highlight NvimTreeOpenedFile ") --vim.api.nvim_command("highlight NvimTreeModifiedFile ") --vim.api.nvim_command("highlight NvimTreeSpecialFile ") -- cgit v1.2.3 From 9464c0cfdaa74b666c6b2798cc5d860c46840345 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 18 Feb 2024 23:57:18 +0200 Subject: Nvim-surround config --- lua/plugins/surround.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 lua/plugins/surround.lua diff --git a/lua/plugins/surround.lua b/lua/plugins/surround.lua new file mode 100644 index 0000000..04def1b --- /dev/null +++ b/lua/plugins/surround.lua @@ -0,0 +1,22 @@ +require("nvim-surround").setup({ + keymaps = { + insert = false, + insert_line = false, + normal = false, + normal_cur = false, + normal_line = false, + normal_cur_line = false, + visual = "", + visual_line = false, + delete = false, + change = false, + }, + aliases = { + ["a"] = false, + ["b"] = false, + ["B"] = false, + ["r"] = false, + ["q"] = false, + ["s"] = false, + }, +}) -- cgit v1.2.3 From abf26f5af5279c643e1aec9d7b3a1bc67d1384f9 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 18 Feb 2024 23:57:40 +0200 Subject: Install nvim-surround plugin --- lua/user/pack.lua | 316 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 162 insertions(+), 154 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 6c99473..2ad3db6 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -3,17 +3,17 @@ local fn = vim.fn -------------------------------------------------- -- Automatically install packer -local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim' +local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if fn.empty(fn.glob(install_path)) > 0 then PACKER_BOOTSTRAP = fn.system({ - 'git', - 'clone', - '--depth', - '1', - 'https://github.com/wbthomason/packer.nvim', + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", install_path, }) - print('Installing packer, please close and reopen Neovim...') + print("Installing packer, please close and reopen Neovim...") vim.cmd([[packadd packer.nvim]]) end @@ -30,7 +30,7 @@ vim.cmd([[ -------------------------------------------------- -- Use a protected call so don't error out on first use -local status_ok, packer = pcall(require, 'packer') +local status_ok, packer = pcall(require, "packer") if not status_ok then return end @@ -43,7 +43,7 @@ packer.init({ --max_jobs = 90, display = { open_fn = function() - return require('packer.util').float({ border = 'rounded' }) + return require("packer.util").float({ border = "rounded" }) end, }, }) @@ -53,33 +53,33 @@ packer.init({ -- Install plugins here return packer.startup(function(use) -- Defaults - use('wbthomason/packer.nvim') -- Have packer manage itself (package manager) - use('nvim-lua/plenary.nvim') -- Useful lua functions used by lots of plugins - use('lewis6991/impatient.nvim') -- Faster loading/startup times + use("wbthomason/packer.nvim") -- Have packer manage itself (package manager) + use("nvim-lua/plenary.nvim") -- Useful lua functions used by lots of plugins + use("lewis6991/impatient.nvim") -- Faster loading/startup times -- Tree-sitter - use({ 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }) -- For language parsing, examples: highlighting, folding, jumping, refactoring... - use('nvim-treesitter/nvim-treesitter-refactor') -- Refactor module for nvim-treesitter + use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) -- For language parsing, examples: highlighting, folding, jumping, refactoring... + use("nvim-treesitter/nvim-treesitter-refactor") -- Refactor module for nvim-treesitter -- lsp - use('williamboman/mason.nvim') -- Package manager to install and manage LSP servers, DAP servers, linters and formatters - use('neovim/nvim-lspconfig') -- Collection of LSP configs - use('williamboman/mason-lspconfig.nvim') -- Bridges mason.nvim with nvim-lspconfig to help use them together + use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters + use("neovim/nvim-lspconfig") -- Collection of LSP configs + use("williamboman/mason-lspconfig.nvim") -- Bridges mason.nvim with nvim-lspconfig to help use them together use({ - 'https://git.sr.ht/~whynothugo/lsp_lines.nvim', + "https://git.sr.ht/~whynothugo/lsp_lines.nvim", config = function() - require('lsp_lines').setup() + require("lsp_lines").setup() end, }) - use('rmagatti/goto-preview') + use("rmagatti/goto-preview") -- Debugger - use('mfussenegger/nvim-dap') -- Debug Adapter Protocol client implementation for Neovim - use('rcarriga/nvim-dap-ui') -- UI for nvim-dap + use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim + use("rcarriga/nvim-dap-ui") -- UI for nvim-dap --use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } - use('theHamsta/nvim-dap-virtual-text') - use('gabrielpoca/replacer.nvim') - use('jayp0521/mason-nvim-dap.nvim') + use("theHamsta/nvim-dap-virtual-text") + use("gabrielpoca/replacer.nvim") + use("jayp0521/mason-nvim-dap.nvim") --use({ -- "jayp0521/mason-nvim-dap.nvim", -- config = function() @@ -91,8 +91,8 @@ return packer.startup(function(use) --}) -- Linters/Formatters - use('mhartington/formatter.nvim') - use('jay-babu/mason-null-ls.nvim') + use("mhartington/formatter.nvim") + use("jay-babu/mason-null-ls.nvim") --use({"jayp0521/mason-null-ls.nvim", -- config = function() -- require('mason-null-ls.nvim').setup({ @@ -101,118 +101,122 @@ return packer.startup(function(use) -- end --}) use({ - 'jose-elias-alvarez/null-ls.nvim', -- Provides LSP: linters, formatters, diagnostics, code actions and etc... - requires = { 'jay-babu/mason-null-ls.nvim' }, + "jose-elias-alvarez/null-ls.nvim", -- Provides LSP: linters, formatters, diagnostics, code actions and etc... + requires = { "jay-babu/mason-null-ls.nvim" }, }) -- Completion - use('hrsh7th/nvim-cmp') -- Completion engine plugin - use('hrsh7th/cmp-nvim-lsp') -- Completion source for nvim-lsp - use('hrsh7th/cmp-buffer') -- Completion source for content of current buffer - use('hrsh7th/cmp-path') -- Completion source for paths - use('hrsh7th/cmp-cmdline') -- Completion source for command-line - use('petertriho/cmp-git') -- Completion source for git - use('tamago324/cmp-zsh') -- Completion source for zsh - use('f3fora/cmp-spell') -- Completion source for spell-checking - use('hrsh7th/cmp-calc') -- Completion source for math calculation - use('saadparwaiz1/cmp_luasnip') -- Completion source for snippets, specifically for luasnip - use('hrsh7th/cmp-nvim-lsp-signature-help') -- Completion source for displaying function signatures with the current parameter emphasized - use('rcarriga/cmp-dap') + use("hrsh7th/nvim-cmp") -- Completion engine plugin + use("hrsh7th/cmp-nvim-lsp") -- Completion source for nvim-lsp + use("hrsh7th/cmp-buffer") -- Completion source for content of current buffer + use("hrsh7th/cmp-path") -- Completion source for paths + use("hrsh7th/cmp-cmdline") -- Completion source for command-line + use("petertriho/cmp-git") -- Completion source for git + use("tamago324/cmp-zsh") -- Completion source for zsh + use("f3fora/cmp-spell") -- Completion source for spell-checking + use("hrsh7th/cmp-calc") -- Completion source for math calculation + use("saadparwaiz1/cmp_luasnip") -- Completion source for snippets, specifically for luasnip + use("hrsh7th/cmp-nvim-lsp-signature-help") -- Completion source for displaying function signatures with the current parameter emphasized + use("rcarriga/cmp-dap") -- Snippets - use('L3MON4D3/LuaSnip') -- Snippet engine - use('rafamadriz/friendly-snippets') -- Collection of snippets to use + use("L3MON4D3/LuaSnip") -- Snippet engine + use("rafamadriz/friendly-snippets") -- Collection of snippets to use -- Git - use('tpope/vim-fugitive') -- + use("tpope/vim-fugitive") -- --use("dinhhuy258/git.nvim") -- For git blame & browse - use('kdheepak/lazygit.nvim') -- Terminal UI for git commands - use('lewis6991/gitsigns.nvim') -- Git decorations + use("kdheepak/lazygit.nvim") -- Terminal UI for git commands + use("lewis6991/gitsigns.nvim") -- Git decorations -- File explorer/fuzzy finder - use('kyazdani42/nvim-tree.lua') -- File explorer - use('ibhagwan/fzf-lua') -- Fuzzy finder - use('ThePrimeagen/harpoon') + use("kyazdani42/nvim-tree.lua") -- File explorer + use("ibhagwan/fzf-lua") -- Fuzzy finder + use("ThePrimeagen/harpoon") --use("nvim-telescope/telescope.nvim") -- Fuzzy finder with lots of features/extendabilities use({ - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', + "nvim-telescope/telescope.nvim", + branch = "0.1.x", --config = function() -- require('plugins.telescope').setup() --end, requires = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope-live-grep-args.nvim', - 'nvim-telescope/telescope-file-browser.nvim', - { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-live-grep-args.nvim", + "nvim-telescope/telescope-file-browser.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, }, }) - use({ 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }) -- Support fzf syntax/algorithm - use('nvim-telescope/telescope-ui-select.nvim') -- - use('nvim-telescope/telescope-project.nvim') -- - use('nvim-telescope/telescope-media-files.nvim') -- - use('nvim-telescope/telescope-file-browser.nvim') -- - use({ 'nvim-telescope/telescope-symbols.nvim', after = 'telescope.nvim' }) -- Search emoji(s) and other symbols - use('nvim-telescope/telescope-dap.nvim') - use('axkirillov/telescope-changed-files') -- - use('smartpde/telescope-recent-files') - use('rmagatti/auto-session') - use('rmagatti/session-lens') + use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm + use("nvim-telescope/telescope-ui-select.nvim") -- + use("nvim-telescope/telescope-project.nvim") -- + use("nvim-telescope/telescope-media-files.nvim") -- + use("nvim-telescope/telescope-file-browser.nvim") -- + use({ "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" }) -- Search emoji(s) and other symbols + use("nvim-telescope/telescope-dap.nvim") + use("axkirillov/telescope-changed-files") -- + use("smartpde/telescope-recent-files") + use("rmagatti/auto-session") + use("rmagatti/session-lens") -- UX - use('folke/neodev.nvim') + use("folke/neodev.nvim") use({ - 'numToStr/Navigator.nvim', -- Navigate between Tmux and Nvim + "numToStr/Navigator.nvim", -- Navigate between Tmux and Nvim config = function() - require('Navigator').setup() + require("Navigator").setup() end, }) - use({ 'tpope/vim-eunuch', cmd = { 'Rename', 'Delete', 'Mkdir' } }) -- Handy unix commands inside Vim (Rename, Move etc.) - --use("tpope/vim-surround") -- + use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete", "Mkdir" } }) -- Handy unix commands inside Vim (Rename, Move etc.) --use("tpope/vim-obsession") -- - use('tpope/vim-unimpaired') -- + use("tpope/vim-unimpaired") -- + --use("tpope/vim-surround") -- + use({ + "kylechui/nvim-surround", + tag = "*", -- Use for stability; omit to use `main` branch for the latest features + }) --use("vimpostor/vim-tpipeline") -- --use("nathom/filetype.nvim") -- - use('mbbill/undotree') + use("mbbill/undotree") use({ - 'myusuf3/numbers.vim', -- + "myusuf3/numbers.vim", -- vim.cmd("let g:numbers_exclude = ['dashboard']"), }) - use('windwp/nvim-autopairs') -- - use('numToStr/Comment.nvim') -- - use('akinsho/toggleterm.nvim') -- - use('tweekmonster/startuptime.vim') -- - use('qpkorr/vim-bufkill') + use("windwp/nvim-autopairs") -- + use("numToStr/Comment.nvim") -- + use("akinsho/toggleterm.nvim") -- + use("tweekmonster/startuptime.vim") -- + use("qpkorr/vim-bufkill") use({ - 'ggandor/leap.nvim', -- + "ggandor/leap.nvim", -- config = function() - require('leap').add_default_mappings() + require("leap").add_default_mappings() --require("leap").set_default_keymaps() --vim.keymap.set('n', '-', '(leap-forward)', {}) --vim.keymap.set('n', '_', '(leap-backward)', {}) end, }) use({ - 'ggandor/flit.nvim', -- + "ggandor/flit.nvim", -- config = function() - require('flit').setup() + require("flit").setup() end, }) - use('folke/which-key.nvim') -- - use('folke/zen-mode.nvim') -- - use('romainl/vim-cool') -- - use('antoinemadec/FixCursorHold.nvim') -- + use("folke/which-key.nvim") -- + use("folke/zen-mode.nvim") -- + use("romainl/vim-cool") -- + use("antoinemadec/FixCursorHold.nvim") -- use({ - 'folke/trouble.nvim', - requires = 'nvim-tree/nvim-web-devicons', + "folke/trouble.nvim", + requires = "nvim-tree/nvim-web-devicons", }) use({ - 'airblade/vim-rooter', -- + "airblade/vim-rooter", -- --vim.cmd("let g:rooter_change_directory_for_non_project_files = ''"), --vim.cmd("let g:rooter_change_directory_for_non_project_files = 'current'") }) - use({ 'michaelb/sniprun', run = 'bash ./install.sh' }) - use({ 'stevearc/overseer.nvim' }) + use({ "michaelb/sniprun", run = "bash ./install.sh" }) + use({ "stevearc/overseer.nvim" }) --use("vim-test/vim-test") -- --use({ -- "rcarriga/vim-ultest", -- @@ -228,65 +232,65 @@ return packer.startup(function(use) --end, --}) use({ - 'nvim-neotest/neotest', + "nvim-neotest/neotest", requires = { { - 'nvim-neotest/neotest-python', - 'nvim-neotest/neotest-plenary', - 'nvim-neotest/neotest-vim-test', + "nvim-neotest/neotest-python", + "nvim-neotest/neotest-plenary", + "nvim-neotest/neotest-vim-test", }, }, }) - use('kawre/leetcode.nvim') - use('m4xshen/hardtime.nvim') + use("kawre/leetcode.nvim") + use("m4xshen/hardtime.nvim") use({ - 'luckasRanarison/nvim-devdocs', + "luckasRanarison/nvim-devdocs", config = function() - require('nvim-devdocs').setup() + require("nvim-devdocs").setup() end, }) -- Colorschemes - use('bluz71/vim-nightfly-guicolors') - use('ayu-theme/ayu-vim') - use('joshdick/onedark.vim') - use('NTBBloodbath/doom-one.nvim') - use('nyngwang/nvimgelion') - use('projekt0n/github-nvim-theme') - use('folke/tokyonight.nvim') - use('ribru17/bamboo.nvim') + use("bluz71/vim-nightfly-guicolors") + use("ayu-theme/ayu-vim") + use("joshdick/onedark.vim") + use("NTBBloodbath/doom-one.nvim") + use("nyngwang/nvimgelion") + use("projekt0n/github-nvim-theme") + use("folke/tokyonight.nvim") + use("ribru17/bamboo.nvim") -- UI - use('kyazdani42/nvim-web-devicons') -- - use('onsails/lspkind-nvim') -- - use({ 'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async' }) -- Fold code + use("kyazdani42/nvim-web-devicons") -- + use("onsails/lspkind-nvim") -- + use({ "kevinhwang91/nvim-ufo", requires = "kevinhwang91/promise-async" }) -- Fold code use({ - 'luukvbaal/statuscol.nvim', + "luukvbaal/statuscol.nvim", config = function() - local builtin = require('statuscol.builtin') - require('statuscol').setup({ + local builtin = require("statuscol.builtin") + require("statuscol").setup({ relculright = true, segments = { - { text = { builtin.foldfunc }, click = 'v:lua.ScFa' }, - { text = { '%s' }, click = 'v:lua.ScSa' }, - { text = { builtin.lnumfunc, ' ' }, click = 'v:lua.ScLa' }, + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, }, }) end, }) use({ - 'glepnir/dashboard-nvim', + "glepnir/dashboard-nvim", --event = 'VimEnter', - requires = { 'nvim-tree/nvim-web-devicons' }, + requires = { "nvim-tree/nvim-web-devicons" }, }) - use('rcarriga/nvim-notify') -- Notification plugin - use('karb94/neoscroll.nvim') -- Faster/smooth scrolling + use("rcarriga/nvim-notify") -- Notification plugin + use("karb94/neoscroll.nvim") -- Faster/smooth scrolling --use("MunifTanjim/prettier.nvim") -- Prettier plugin for Neovim's built-in LSP client use({ - 'norcalli/nvim-colorizer.lua', -- colorize hexa and rgb strings - cmd = { 'ColorizerToggle', 'ColorizerAttachToBuffer' }, + "norcalli/nvim-colorizer.lua", -- colorize hexa and rgb strings + cmd = { "ColorizerToggle", "ColorizerAttachToBuffer" }, config = function() - require('colorizer').setup({ + require("colorizer").setup({ --'*'; user_default_options = { RGB = true, @@ -295,56 +299,56 @@ return packer.startup(function(use) RRGGBBAA = false, css = false, css_fn = true, - mode = 'foreground', + mode = "foreground", }, }) end, }) - use('MunifTanjim/nui.nvim') + use("MunifTanjim/nui.nvim") use({ - 'j-hui/fidget.nvim', - tag = 'legacy', + "j-hui/fidget.nvim", + tag = "legacy", }) -- UI to show nvim-lsp progress - use('metakirby5/codi.vim') + use("metakirby5/codi.vim") use({ - 'simrat39/symbols-outline.nvim', -- + "simrat39/symbols-outline.nvim", -- config = function() - require('symbols-outline').setup({ + require("symbols-outline").setup({ auto_close = true, }) end, }) use({ - 'kosayoda/nvim-lightbulb', -- - requires = 'antoinemadec/FixCursorHold.nvim', + "kosayoda/nvim-lightbulb", -- + requires = "antoinemadec/FixCursorHold.nvim", }) use({ - 'SmiteshP/nvim-navic', -- Statusline/Winbar component that uses LSP to show current code context - requires = 'neovim/nvim-lspconfig', + "SmiteshP/nvim-navic", -- Statusline/Winbar component that uses LSP to show current code context + requires = "neovim/nvim-lspconfig", }) use({ - 'rebelot/heirline.nvim', -- Statusline that is highly configurable + "rebelot/heirline.nvim", -- Statusline that is highly configurable --requires = 'kyazdani42/nvim-web-devicons', --event = 'VimEnter', }) -- Language specific tools - use('simrat39/rust-tools.nvim') -- Rust tooling ecosystem + use("simrat39/rust-tools.nvim") -- Rust tooling ecosystem use({ - 'saecki/crates.nvim', -- - requires = { 'nvim-lua/plenary.nvim' }, + "saecki/crates.nvim", -- + requires = { "nvim-lua/plenary.nvim" }, config = function() - require('crates').setup() + require("crates").setup() end, }) use({ - 'akinsho/flutter-tools.nvim', + "akinsho/flutter-tools.nvim", requires = { - 'nvim-lua/plenary.nvim', - 'stevearc/dressing.nvim', -- optional for vim.ui.select + "nvim-lua/plenary.nvim", + "stevearc/dressing.nvim", -- optional for vim.ui.select }, config = function() - require('flutter-tools').setup({ + require("flutter-tools").setup({ debugger = { enabled = true, run_via_dap = true, @@ -353,37 +357,41 @@ return packer.startup(function(use) end, }) use({ - 'iamcco/markdown-preview.nvim', -- Markdown Preview + "iamcco/markdown-preview.nvim", -- Markdown Preview run = function() - vim.fn['mkdp#util#install']() + vim.fn["mkdp#util#install"]() end, - vim.cmd('let g:mkdp_auto_close = 0'), + vim.cmd("let g:mkdp_auto_close = 0"), }) use({ - 'ellisonleao/glow.nvim', -- Markdown Preview + "ellisonleao/glow.nvim", -- Markdown Preview config = function() local glow_path -- Check if glow exists in ~/.local/bin - if vim.fn.executable('~/.local/bin/glow') == 1 then - glow_path = '~/.local/bin/glow' + if vim.fn.executable("~/.local/bin/glow") == 1 then + glow_path = "~/.local/bin/glow" else -- Fallback to /usr/bin/glow - glow_path = '/usr/bin/glow' + glow_path = "/usr/bin/glow" end - require('glow').setup({ - style = 'dark', + require("glow").setup({ + style = "dark", glow_path = glow_path, }) end, }) + use({ + "lervag/vimtex", + }) + use("micangl/cmp-vimtex") -------------------------------------------------- -- Automatically set up your configuration after cloning packer.nvim -- Put this at the end after all plugins if PACKER_BOOTSTRAP then - require('packer').sync() + require("packer").sync() end end) -- cgit v1.2.3 From efaf6de5ebd46589d1f1401853f3cd6cd4823b37 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 19 Feb 2024 23:59:37 +0200 Subject: Add vimtex and surround plugins --- init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init.lua b/init.lua index 92df3d2..a94213e 100644 --- a/init.lua +++ b/init.lua @@ -79,6 +79,7 @@ local modules = { "plugins.gitsigns", "plugins.sniprun", "plugins.session", + "plugins.surround", "plugins.neoscroll", "plugins.statuscol", "plugins.trouble", @@ -98,6 +99,7 @@ local modules = { "plugins.hardtime", "plugins.notify", "plugins.overseer", + "plugins.vimtex", --"plugins.modify-blend", } -- cgit v1.2.3 From 296d861f34588210f762947e9cea4c278394fd83 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 20 Feb 2024 23:50:58 +0200 Subject: Add vimtex keys --- lua/plugins/vimtex.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lua/plugins/vimtex.lua diff --git a/lua/plugins/vimtex.lua b/lua/plugins/vimtex.lua new file mode 100644 index 0000000..732e6ed --- /dev/null +++ b/lua/plugins/vimtex.lua @@ -0,0 +1,45 @@ +--ft = { "latex", "tex" }, +--if vim.loop.os_uname().sysname == "Linux" then +-- vim.g.vimtex_view_method = "zathura" +--end +--vim.g["vimtex_view_method"] = "zathura" -- main variant with xdotool (requires X11; not compatible with wayland) +--vim.g.vimtex_compiler_method = "pdflatex" +-- compilation configuration +vim.g["vimtex_compiler_method"] = "latexmk" +--vim.g["vimtex_compiler_method"] = "xelatex" +--vim.g["vimtex_compiler_method"] = "lualatex" +vim.g["vimtex_compiler_latexmk"] = { + callback = 1, + continuous = 1, + executable = "latexmk", + options = { + "-shell-escape", + "-verbose", + "-file-line-error", + "-synctex=1", + "-interaction=nonstopmode", + }, +} +vim.g["vimtex_view_enabled"] = 1 +vim.g["vimtex_view_zathura_check_libsynctex"] = 0 +--vim.g["vimtex_view_method"] = "zathura" -- main variant with xdotool (requires X11; not compatible with wayland) +if vim.loop.os_uname().sysname == "Linux" then + vim.g.vimtex_view_method = "zathura" +end +--vim.g.vimtex_view_method = "sioyek" +--vim.g["vimtex_view_method"] = "zathura_simple" -- for variant without xdotool to avoid errors in wayland +vim.g["vimtex_quickfix_mode"] = 0 -- suppress error reporting on save and build +vim.g["vimtex_mappings_enabled"] = 0 -- Ignore mappings +vim.g["vimtex_indent_enabled"] = 0 -- Auto Indent +vim.g["tex_flavor"] = "latex" -- how to read tex files +vim.g["tex_indent_items"] = 0 -- turn off enumerate indent +vim.g["tex_indent_brace"] = 0 -- turn off brace indent +--vim.g.vimtex_view_forward_search_on_start = 0 +--vim.g["vimtex_context_pdf_viewer"] = "zathura" -- external PDF viewer run from vimtex menu command +--vim.g["latex_view_general_viewer"] = "zathura" +vim.g["vimtex_log_ignore"] = { -- Error suppression: + "Underfull", + "Overfull", + "specifier changed to", + "Token not allowed in a PDF string", +} -- cgit v1.2.3 From 6af1d0d7b18ecd4f771b8aa1d96dfcbe00355ead Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 20 Feb 2024 23:58:34 +0200 Subject: Add vimtex keys --- lua/user/keys.lua | 441 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 229 insertions(+), 212 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 11de667..87d852b 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -6,14 +6,14 @@ local map = function(mode, l, r, opts) keymap.set(mode, l, r, opts) end local term_opts = { noremap = true, silent = false } -local mods = require('user.mods') +local mods = require("user.mods") local bufnr = vim.api.nvim_get_current_buf() -- Semi-colon as leader key -vim.g.mapleader = ';' +vim.g.mapleader = ";" -- "jk" and "kj" to exit insert-mode -map('i', 'jk', '') +map("i", "jk", "") -- Jump to next match on line using `.` instead of `;` NOTE: commented out in favour of "ggandor/flit.nvim" --map("n", ".", ";") @@ -22,395 +22,404 @@ map('i', 'jk', '') --map("n", "", ".") -- Reload nvim config -map('n', '', "luafile ~/.config/nvim/init.lua | :echom ('Nvim config loading...') | :sl! | echo ('')") +map("n", "", + "luafile ~/.config/nvim/init.lua | :echom ('Nvim config loading...') | :sl! | echo ('')") --------------- Extended Operations --------------- -- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros -- TODO: Have a list of if available on system/packages, example "Zen Mode" to not work on it (quit Zen Mode) -map('n', 'q', function() +map("n", "q", function() local config = vim.api.nvim_win_get_config(0) - if config.relative ~= '' then -- is_floating_window? - return ':silent! close!' - elseif vim.o.buftype == 'quickfix' then - return ':quit' - elseif vim.o.buftype == 'help' then - return ':close' + if config.relative ~= "" then -- is_floating_window? + return ":silent! close!" + elseif vim.o.buftype == "quickfix" then + return ":quit" + elseif vim.o.buftype == "help" then + return ":close" else - return 'q' + return "q" end end, { expr = true, replace_keycodes = true }) -- Edit new file -map('n', 'e', [[:e =expand("%:h")..'/']], { noremap = true, silent = true, desc = 'New file' }) +map("n", ";", [[:e =expand("%:h")..'/']], { noremap = true, silent = true, desc = "New file" }) -- Write as sudo -map('c', 'W', "exe 'w !sudo tee >/dev/null %:p:S' | setl nomod", { silent = true, desc = 'Write as Sudo' }) +map("c", "W", "exe 'w !sudo tee >/dev/null %:p:S' | setl nomod", { silent = true, desc = "Write as Sudo" }) -- Combine buffers list with buffer name -map('n', 'b', ':buffers:buffer') +map("n", "b", ":buffers:buffer") -- Buffer confirmation -map('n', 'y', ':BufferPick') +map("n", "y", ":BufferPick") --- Map buffer next, prev and delete to +(n/p/d) respectively -map('n', 'n', ':bn') -map('n', 'p', ':bp') -map('n', 'd', ':bd') +-- Map buffer next, prev and delete to +(n/p/d) respectively and tab/s-tab +map("n", "n", ":bn") +map("n", "p", ":bp") +map("n", "d", ":bd") +map("n", "", ":bnext") +map("n", "", ":bprevious") -- Delete file of current buffer -map('n', 'rm', "call delete(expand('%')) | bdelete!") +map("n", "rm", "call delete(expand('%')) | bdelete!") -- List marks -map('n', 'm', ':marks') +map("n", "m", ":marks") -- Messages -map('n', 'M', ':messages') +map("n", "M", ":messages") --- Clear messages or just refresh/redraw the screen -map('n', 'i', "lua require('notify').dismiss()") +map("n", "i", "lua require('notify').dismiss()") -- Unsets the 'last search pattern' register by hitting return --map("n", "", "!silent :noh") -- Toggle set number -map('n', '$', ':NumbersToggle') -map('n', '%', ':NumbersOnOff') +map("n", "$", ":NumbersToggle") +map("n", "%", ":NumbersOnOff") -- Easier split navigations, just ctrl-j instead of ctrl-w then j -map('t', '', '') -map('t', '', '') -map('t', '', '') -map('t', '', '') -map('t', '', '') +map("t", "", "") +map("t", "", "") +map("t", "", "") +map("t", "", "") +map("t", "", "") -- Split window -map('n', 'h', ':split') -map('n', 'v', ':vsplit') -map('n', 'c', 'c') +map("n", "-", ":split") +map("n", "\\", ":vsplit") +map("n", "c", "c") -- Resize Panes -map('n', '+', ':resize +5') -map('n', '-', ':resize -5') -map('n', '<', ':vertical resize +5') -map('n', '>', ':vertical resize -5') -map('n', '=', '=') +--map('n', '+', ':resize +5') +--map('n', '-', ':resize -5') +map("n", "<", ":vertical resize +5") +map("n", ">", ":vertical resize -5") +map("n", "=", "=") -- Map Alt+(h/j/k/l) in insert(include terminal/command) mode to move directional -map({ 'i', 't', 'c' }, '', '') -map({ 'i', 't', 'c' }, '', '') -map({ 'i', 't', 'c' }, '', '') -map({ 'i', 't', 'c' }, '', '') +map({ "i", "t", "c" }, "", "") +map({ "i", "t", "c" }, "", "") +map({ "i", "t", "c" }, "", "") +map({ "i", "t", "c" }, "", "") -- Create tab, edit and move between them -map('n', 'n', ':tabnew') -map('n', 'e', ':tabedit') -map('n', '[', ':tabprev') -map('n', ']', ':tabnext') +map("n", "n", ":tabnew") +map("n", "e", ":tabedit") +map("n", "[", ":tabprev") +map("n", "]", ":tabnext") -- "Zoom" a split window into a tab and/or close it --map("n", ",", ":tabnew %") --map("n", ".", ":tabclose") -- Vim TABs -map('n', '1', '1gt') -map('n', '2', '2gt') -map('n', '3', '3gt') -map('n', '4', '4gt') -map('n', '5', '5gt') -map('n', '6', '6gt') -map('n', '7', '7gt') -map('n', '8', '8gt') -map('n', '9', '9gt') -map('n', '0', '10gt') +map("n", "1", "1gt") +map("n", "2", "2gt") +map("n", "3", "3gt") +map("n", "4", "4gt") +map("n", "5", "5gt") +map("n", "6", "6gt") +map("n", "7", "7gt") +map("n", "8", "8gt") +map("n", "9", "9gt") +map("n", "0", "10gt") -- Hitting ESC when inside a terminal to get into normal mode --map("t", "", [[]]) -- Move block (indentation) easily -map('n', '<', '<<', term_opts) -map('n', '>', '>>', term_opts) -map('x', '<', '', '>gv', term_opts) +--map("n", "<", "<<", term_opts) +--map("n", ">", ">>", term_opts) +--map("x", "<", "", ">gv", term_opts) +map("v", "<", "", ">gv") +map("n", "<", "<") +map("n", ">", ">") -- Set alt+(j/k) to switch lines of texts or simply move them -map('n', '', ':let save_a=@a"add"ap:let @a=save_a') -map('n', '', ':let save_a=@a"add"ap:let @a=save_a') +map("n", "", ':let save_a=@a"add"ap:let @a=save_a') +map("n", "", ':let save_a=@a"add"ap:let @a=save_a') -- Toggle Diff -map('n', 'df', 'call utils#ToggleDiff()') +map("n", "df", "call utils#ToggleDiff()") -- Toggle Verbose -map('n', 'uvt', 'call utils#VerboseToggle()') +map("n", "uvt", "call utils#VerboseToggle()") -- Jump List -map('n', 'j', 'call utils#GotoJump()') +map("n", "j", "call utils#GotoJump()") -- Rename file -map('n', 'rf', 'call utils#RenameFile()') +map("n", "rf", "call utils#RenameFile()") -- Map delete to Ctrl+l -map('i', '', '') +map("i", "", "") -- Clear screen -map('n', '', '!clear') +map("n", "", "!clear") -- Change file to an executable -map('n', 'x', ":lua require('user.mods').Toggle_executable() | :echom ('Toggle executable') | :sl! | echo ('')") +map("n", "x", + ":lua require('user.mods').Toggle_executable() | :echom ('Toggle executable') | :sl! | echo ('')") -- map("n", "x", ":!chmod +x %") -- Paste without replace clipboard -map('v', 'p', '"_dP') +map("v", "p", '"_dP') -- Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in -- visual mode to select text to swap with --map("v", "", "`.``gvP``P") -- Change Working Directory to current project -map('n', 'cd', ':cd %:p:h:pwd') +map("n", "cd", ":cd %:p:h:pwd") -- Open the current file in the default program (on Mac this should just be just `open`) -map('n', 'o', ':!xdg-open %') +map("n", "o", ":!xdg-open %") -- URL handling -if vim.fn.has('mac') == 1 then - map('', 'gx', 'call jobstart(["open", expand("")], {"detach": v:true})', {}) -elseif vim.fn.has('unix') == 1 then - map('', 'gx', 'call jobstart(["xdg-open", expand("")], {"detach": v:true})', {}) -elseif vim.fn.has('wsl') == 1 then - map('', 'gx', 'call jobstart(["wslview", expand("")], {"detach": v:true})', {}) +if vim.fn.has("mac") == 1 then + map("", "gx", 'call jobstart(["open", expand("")], {"detach": v:true})', {}) +elseif vim.fn.has("unix") == 1 then + map("", "gx", 'call jobstart(["xdg-open", expand("")], {"detach": v:true})', {}) +elseif vim.fn.has("wsl") == 1 then + map("", "gx", 'call jobstart(["wslview", expand("")], {"detach": v:true})', {}) else - map[''].gx = { 'lua print("Error: gx is not supported on this OS!")' } + map[""].gx = { 'lua print("Error: gx is not supported on this OS!")' } end -- Search and replace -map('v', 'sr', 'y:%s/"//gc') +map("v", "sr", 'y:%s/"//gc') -- Substitute globally and locally in the selected region. -map('n', 's', ':%s//g') -map('v', 's', ':s//g') +map("n", "s", ":%s//g") +map("v", "s", ":s//g") -- Toggle completion -map('n', 'tc', ':lua require("user.mods").toggle_completion()') +map("n", "tc", ':lua require("user.mods").toggle_completion()') -- Disable default completion. -map('i', '', '') -map('i', '', '') +map("i", "", "") +map("i", "", "") -- Set line wrap -map('n', '', function() - local wrap_status = vim.api.nvim_exec('set wrap ?', true) +map("n", "", function() + local wrap_status = vim.api.nvim_exec("set wrap ?", true) - if wrap_status == 'nowrap' then - vim.api.nvim_command('set wrap linebreak') - print('Wrap enabled') + if wrap_status == "nowrap" then + vim.api.nvim_command("set wrap linebreak") + print("Wrap enabled") else - vim.api.nvim_command('set wrap nowrap') - print('Wrap disabled') + vim.api.nvim_command("set wrap nowrap") + print("Wrap disabled") end end, { silent = true }) -- Toggle between folds ---utils.map("n", "", "&foldlevel ? 'zM' : 'zR'", { expr = true }) +map("n", "", "&foldlevel ? 'zM' : 'zR'", { expr = true }) -- Use space to toggle fold -map('n', '', 'za') +--map("n", "", "za") -- Make a copy of current file --vim.cmd([[ -- map s :up \| saveas! %:p:r-=strftime("%y.%m.%d-%H:%M")-bak.=expand("%:e") \| 3sleep \| e # --]]) -map('n', '.b', ':!cp % %.backup') +map("n", ".b", ":!cp % %.backup") -- Toggle transparency -map('n', 'tb', ':call utils#Toggle_transparent_background()') +map("n", "tb", ":call utils#Toggle_transparent_background()") -- Toggle zoom -map('n', 'z', ':call utils#ZoomToggle()') -map('n', 'z', '|_') +map("n", "z", ":call utils#ZoomToggle()") +map("n", "z", "|_") -- Toggle statusline -map('n', 'sl', ':call utils#ToggleHiddenAll()') +map("n", "sl", ":call utils#ToggleHiddenAll()") -- Open last closed buffer -map('n', '', ':call OpenLastClosed()') +map("n", "", ":call OpenLastClosed()") ---------------- Plugin Operations ---------------- -- Packer -map('n', 'Pc', 'PackerCompile') -map('n', 'Pi', 'PackerInstall') -map('n', 'Ps', 'PackerSync') -map('n', 'PS', 'PackerStatus') -map('n', 'Pu', 'PackerUpdate') +map("n", "Pc", "PackerCompile") +map("n", "Pi", "PackerInstall") +map("n", "Ps", "PackerSync") +map("n", "PS", "PackerStatus") +map("n", "Pu", "PackerUpdate") -- Tmux navigation (aserowy/tmux.nvim) -map('n', '', 'NavigatorLeft') -map('n', '', 'NavigatorRight') -map('n', '', 'NavigatorUp') -map('n', '', 'NavigatorDown') +map("n", "", "NavigatorLeft") +map("n", "", "NavigatorRight") +map("n", "", "NavigatorUp") +map("n", "", "NavigatorDown") -- ToggleTerm -map({ 'n', 't' }, 'tt', 'ToggleTerm') -map({ 'n', 't' }, 'th', 'lua Horizontal_term_toggle()') -map({ 'n', 't' }, 'tv', 'lua Vertical_term_toggle()') +map({ "n", "t" }, "tt", "ToggleTerm") +map({ "n", "t" }, "th", "lua Horizontal_term_toggle()") +map({ "n", "t" }, "tv", "lua Vertical_term_toggle()") -- LazyGit -map({ 'n', 't' }, 'gg', 'lua Lazygit_toggle()') +map({ "n", "t" }, "gg", "lua Lazygit_toggle()") -map('n', 'tg', 'lua Gh_dash()') +map("n", "tg", "lua Gh_dash()") -- Fugitive git bindings -map('n', 'gs', vim.cmd.Git) -map('n', 'ga', ':Git add %:p') +map("n", "gs", vim.cmd.Git) +map("n", "ga", ":Git add %:p") --map("n", "gs", ":Gstatus") -map('n', 'gc', ':Gcommit -v -q') -map('n', 'gt', ':Gcommit -v -q %:p') +map("n", "gc", ":Gcommit -v -q") +map("n", "gt", ":Gcommit -v -q %:p") --map("n", "gd", ":Gdiff") -map('n', 'ge', ':Gedit') +map("n", "ge", ":Gedit") --map("n", "gr", ":Gread") -map('n', 'gw', ':Gwrite') -map('n', 'gl', ':silent! Glog:bot copen') +map("n", "gw", ":Gwrite") +map("n", "gl", ":silent! Glog:bot copen") --map("n", "gp", ":Ggrep") --map("n", "gp", ":Git push") --map("n", "gb", ":Gblame") -map('n', 'gm', ':Gmove') +map("n", "gm", ":Gmove") --map("n", "gb", ":Git branch") --map("n", "go", ":Git checkout") --map("n", "gps", ":Dispatch! git push") --map("n", "gpl", ":Dispatch! git pull") -- Telescope -map('n', 'ff', ":cd %:p:h:pwdlua require('telescope.builtin').find_files()") -- find files with hidden option -map('n', 'fF', ":cd %:p:h:pwdlua require('user.mods').findFilesInCwd()", { noremap = true, silent = true, desc = 'Find files in cwd' }) -map('n', 'f.', function() - require('telescope.builtin').find_files({ hidden = true, no_ignore = true }) +map("n", "ff", ":cd %:p:h:pwdlua require('telescope.builtin').find_files()") -- find files with hidden option +map("n", "fF", ":cd %:p:h:pwdlua require('user.mods').findFilesInCwd()", + { noremap = true, silent = true, desc = "Find files in cwd" }) +map("n", "f.", function() + require("telescope.builtin").find_files({ hidden = true, no_ignore = true }) end) -- find all files -map('n', 'fg', "lua require('telescope.builtin').live_grep()") -map('n', 'fb', "lua require('telescope.builtin').buffers()") -map('n', 'fh', "lua require('telescope.builtin').help_tags()") -map('n', 'fc', "lua require('telescope.builtin').commands()") -map('n', 'cf', 'Telescope changed_files') -map('n', 'fp', 'Telescope pickers') -map('n', 'fd', "lua require('telescope.builtin').diagnostics()") -map('n', 'fk', "lua require('telescope.builtin').keymaps()") -map('n', 'fr', "lua require('telescope.builtin').registers({})") -- registers picker -map('n', 'fm', "lua require('telescope').extensions.media_files.media_files({})") -- find media files -map('n', 'fi', "lua require('telescope').extensions.notify.notify({})") -- find notifications -map('n', 'fs', 'lua require("session-lens").search_session()') -map('n', 'ffd', [[lua require'plugins.telescope'.find_dirs()]]) -- find dies -map('n', 'ff.', [[lua require'plugins.telescope'.find_configs()]]) -- find configs -map('n', 'ffs', [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts -map('n', 'ffw', [[lua require'plugins.telescope'.find_projects()]]) -- find projects -map('n', 'ffb', [[lua require'plugins.telescope'.find_books()]]) -- find books -map('n', 'ffn', [[lua require'plugins.telescope'.find_notes()]]) -- find notes -map('n', 'fgn', [[lua require'plugins.telescope'.grep_notes()]]) -- search notes -map('n', 'frf', "lua require('telescope').extensions.recent_files.pick()") -map('n', 'ffc', "lua require('telescope.builtin').current_buffer_fuzzy_find()") -map('n', 'f/', "lua require('telescope').extensions.file_browser.file_browser()") +map("n", "fg", "lua require('telescope.builtin').live_grep()") +map("n", "fb", "lua require('telescope.builtin').buffers()") +map("n", "fh", "lua require('telescope.builtin').help_tags()") +map("n", "fc", "lua require('telescope.builtin').commands()") +map("n", "cf", "Telescope changed_files") +map("n", "fp", "Telescope pickers") +map("n", "fd", "lua require('telescope.builtin').diagnostics()") +map("n", "fk", "lua require('telescope.builtin').keymaps()") +map("n", "fr", "lua require('telescope.builtin').registers({})") -- registers picker +map("n", "fm", "lua require('telescope').extensions.media_files.media_files({})") -- find media files +map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find notifications +map("n", "fs", 'lua require("session-lens").search_session()') +map("n", "ffd", [[lua require'plugins.telescope'.find_dirs()]]) -- find dies +map("n", "ff.", [[lua require'plugins.telescope'.find_configs()]]) -- find configs +map("n", "ffs", [[lua require'plugins.telescope'.find_scripts()]]) -- find scripts +map("n", "ffw", [[lua require'plugins.telescope'.find_projects()]]) -- find projects +map("n", "ffb", [[lua require'plugins.telescope'.find_books()]]) -- find books +map("n", "ffn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes +map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes +map("n", "frf", "lua require('telescope').extensions.recent_files.pick()") +map("n", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") +map("n", "f/", "lua require('telescope').extensions.file_browser.file_browser()") --map("n", "f/", "lua require('plugins.telescope').curbuf()") -- find files with hidden option -- Map a shortcut to open the picker. -- FZF -map('n', 'fz', "lua require('fzf-lua').files()") +map("n", "fz", "lua require('fzf-lua').files()") -- Nvim-tree -map('n', 'f', 'Rooter:NvimTreeToggle', {}) +map("n", "e", "Rooter:NvimTreeToggle", {}) -- Undotree -map('n', 'u', vim.cmd.UndotreeToggle) +map("n", "u", vim.cmd.UndotreeToggle) -- Markdown-preview -map('n', 'md', 'MarkdownPreviewToggle') -map('n', 'mg', 'Glow') +map("n", "md", "MarkdownPreviewToggle") +map("n", "mg", "Glow") -- Autopairs -map('n', 'ww', "lua require('user.mods').Toggle_autopairs()") +map("n", "ww", "lua require('user.mods').Toggle_autopairs()") -- Zen-mode toggle -map('n', 'zm', "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") +map("n", "zm", "ZenMode | :echom ('Zen Mode') | :sl! | echo ('')") -- Vim-rooter -map('n', 'ro', "Rooter | :echom ('cd to root/project directory') | :sl! | echo ('')", term_opts) +map("n", "ro", "Rooter | :echom ('cd to root/project directory') | :sl! | echo ('')", term_opts) -- Trouble (UI to show diagnostics) -map('n', 't', ':cd %:p:h:pwdTroubleToggle') -map('n', 'tw', ':cd %:p:h:pwdTroubleToggle workspace_diagnostics') -map('n', 'td', ':cd %:p:h:pwdTroubleToggle document_diagnostics') -map('n', 'tq', ':cd %:p:h:pwdTroubleToggle quickfix') -map('n', 'tl', ':cd %:p:h:pwdTroubleToggle loclist') -map('n', 'gR', 'TroubleToggle lsp_references') +map("n", "t", ":cd %:p:h:pwdTroubleToggle") +map("n", "tw", ":cd %:p:h:pwdTroubleToggle workspace_diagnostics") +map("n", "td", ":cd %:p:h:pwdTroubleToggle document_diagnostics") +map("n", "tq", ":cd %:p:h:pwdTroubleToggle quickfix") +map("n", "tl", ":cd %:p:h:pwdTroubleToggle loclist") +map("n", "gR", "TroubleToggle lsp_references") -- Null-ls -map('n', 'ls', 'NullLsToggle') +map("n", "ls", "NullLsToggle") -- Replacer -map('n', 'qr', ':lua require("replacer").run()') +map("n", "qr", ':lua require("replacer").run()') -- Quickfix -map('n', 'q', function() +map("n", "q", function() if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then - require('plugins.quickfix').close() + require("plugins.quickfix").close() else - require('plugins.quickfix').open() + require("plugins.quickfix").open() end -end, { desc = 'Toggle quickfix window' }) +end, { desc = "Toggle quickfix window" }) -- Move to the next and previous item in the quickfixlist -map('n', ']c', 'cnext') -map('n', '[c', 'cprevious') +map("n", "]c", "cnext") +map("n", "[c", "cprevious") -- Location list -map('n', 'l', 'lua require("plugins.loclist").loclist_toggle()') +map("n", "l", 'lua require("plugins.loclist").loclist_toggle()') -- Dap (debugging) -local dap_ok, dap = pcall(require, 'dap') -local dap_ui_ok, ui = pcall(require, 'dapui') +local dap_ok, dap = pcall(require, "dap") +local dap_ui_ok, ui = pcall(require, "dapui") if not (dap_ok and dap_ui_ok) then - require('notify')('nvim-dap or dap-ui not installed!', 'warning') + require("notify")("nvim-dap or dap-ui not installed!", "warning") return end -vim.fn.sign_define('DapBreakpoint', { text = '🐞' }) +vim.fn.sign_define("DapBreakpoint", { text = "🐞" }) -- Start debugging session -map('n', 'ds', function() +map("n", "ds", function() dap.continue() ui.toggle({}) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('=', false, true, true), 'n', false) -- Spaces buffers evenly + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("=", false, true, true), "n", false) -- Spaces buffers evenly end) -- Set breakpoints, get variable values, step into/out of functions, etc. -map('n', 'dC', dap.continue) +map("n", "dC", dap.continue) -- map("n", "dC", dap.close) -- map("n", "dt", dap.terminate) -map('n', 'dt', ui.toggle) -map('n', 'dd', function() +map("n", "dt", ui.toggle) +map("n", "dd", function() dap.disconnect({ terminateDebuggee = true }) end) -map('n', 'dn', dap.step_over) -map('n', 'di', dap.step_into) -map('n', 'do', dap.step_out) -map('n', 'db', dap.toggle_breakpoint) -map('n', 'dB', function() +map("n", "dn", dap.step_over) +map("n", "di", dap.step_into) +map("n", "do", dap.step_out) +map("n", "db", dap.toggle_breakpoint) +map("n", "dB", function() dap.clear_breakpoints() - require('notify')('Breakpoints cleared', 'warn') + require("notify")("Breakpoints cleared", "warn") end) -map('n', 'dl', require('dap.ui.widgets').hover) -map('n', 'de', function() - require('dapui').float_element() -end, { desc = 'Open Element' }) -map('n', 'dq', function() - require('dapui').close() - require('dap').repl.close() - local session = require('dap').session() +map("n", "dl", require("dap.ui.widgets").hover) +map("n", "de", function() + require("dapui").float_element() +end, { desc = "Open Element" }) +map("n", "dq", function() + require("dapui").close() + require("dap").repl.close() + local session = require("dap").session() if session then - require('dap').terminate() + require("dap").terminate() end - require('nvim-dap-virtual-text').refresh() -end, { desc = 'Terminate Debug' }) -map('n', 'dc', function() - require('telescope').extensions.dap.commands() -end, { desc = 'DAP-Telescope: Commands' }) + require("nvim-dap-virtual-text").refresh() +end, { desc = "Terminate Debug" }) +map("n", "dc", function() + require("telescope").extensions.dap.commands() +end, { desc = "DAP-Telescope: Commands" }) --vim.keymap.set("n", "B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))") --vim.keymap.set("v", "B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))") --vim.keymap.set("n", "lp", ":lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))") @@ -426,30 +435,38 @@ end, { desc = 'DAP-Telescope: Commands' }) --end) -- Toggle Dashboard -map('n', '', 'lua require("user.mods").toggle_dashboard()') +map("n", "", 'lua require("user.mods").toggle_dashboard()') -- Lsp Lines toggle -map('', 'll', require('lsp_lines').toggle, { desc = 'Toggle lsp_lines' }) +map("", "ll", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) -- SnipRun -map({ 'n', 'v' }, 'r', 'SnipRun') +map({ "n", "v" }, "r", "SnipRun") -- Codi -map('n', 'co', 'lua require("user.mods").toggleCodi()') +map("n", "co", 'lua require("user.mods").toggleCodi()') -- Scratch buffer -map('n', 'ss', 'lua require("user.mods").Scratch("float")') -map('n', 'sh', 'lua require("user.mods").Scratch("horizontal")') -map('n', 'sv', 'lua require("user.mods").Scratch("vertical")') +map("n", "ss", 'lua require("user.mods").Scratch("float")') +map("n", "sh", 'lua require("user.mods").Scratch("horizontal")') +map("n", "sv", 'lua require("user.mods").Scratch("vertical")') -- Hardtime -map('n', 'H', 'lua require("plugins.hardtime").ToggleHardtime()') +map("n", "H", 'lua require("plugins.hardtime").ToggleHardtime()') -- Code Run -map('n', 'rr', 'lua require("user.mods").toggleCodeRunner()') +map("n", "rr", 'lua require("user.mods").toggleCodeRunner()') -- Run executable file -map('n', 'rx', ":lua require('user.mods').RunCurrentFile():echom 'Running executable file...':sl!:echo ''") +map("n", "rx", + ":lua require('user.mods').RunCurrentFile():echom 'Running executable file...':sl!:echo ''") -- Close all floating windows -map({ 'n', 't', 'c' }, 'w', 'CloseFloatingWindows') +map({ "n", "t", "c" }, "w", "CloseFloatingWindows") + +-- Vimtex +map("n", "lc", ":VimtexCompile") +map("v", "ls", ":VimtexCompileSelected") +map("n", "li", ":VimtexInfo") +map("n", "lt", ":VimtexTocToggle") +map("n", "lv", ":VimtexView") -- cgit v1.2.3 From cc7e3b0729b57c0319cb537c38642294d07c465a Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 20 Feb 2024 23:58:52 +0200 Subject: Autopairs for vimtex --- lua/plugins/autopairs.lua | 99 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 27 deletions(-) diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua index 90c6d35..90b62b1 100644 --- a/lua/plugins/autopairs.lua +++ b/lua/plugins/autopairs.lua @@ -1,42 +1,87 @@ -local status_ok, npairs = pcall(require, "nvim-autopairs") +local status_ok, autopairs = pcall(require, "nvim-autopairs") if not status_ok then return end -npairs.setup { +autopairs.setup({ check_ts = true, ts_config = { lua = { "string", "source" }, javascript = { "string", "template_string" }, java = false, }, - map = "", - pairs_map = { -['<'] = '>', -}, + map = "", + pairs_map = { + ["<"] = ">", + }, disable_filetype = { "TelescopePrompt", "spectre_panel" }, disable_in_macro = true, disable_in_visualblock = true, enable_moveright = true, - enable_afterquote = true, -- add bracket pairs after quote - enable_check_bracket_line = false, --- check bracket in same line - enable_bracket_in_quote = true, -- - break_undo = true, -- switch for basic rule break undo sequence - fast_wrap = { - chars = { "{", "[", "(", '"', "'" }, - pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), - offset = 0, -- Offset from pattern match - end_key = "$", - keys = "qwertyuiopzxcvbnmasdfghjkl", - check_comma = true, - highlight = "PmenuSel", - highlight_grey = "LineNr", - }, -} + enable_afterquote = true, -- add bracket pairs after quote + enable_check_bracket_line = false, --- check bracket in same line + enable_bracket_in_quote = true, -- + break_undo = true, -- switch for basic rule break undo sequence + --fast_wrap = { + -- chars = { "{", "[", "(", '"', "'" }, + -- pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + -- offset = 0, -- Offset from pattern match + -- end_key = "$", + -- keys = "qwertyuiopzxcvbnmasdfghjkl", + -- check_comma = true, + -- highlight = "PmenuSel", + -- highlight_grey = "LineNr", + --}, +}) +local Rule = require("nvim-autopairs.rule") -local cmp_autopairs = require "nvim-autopairs.completion.cmp" -local cmp_status_ok, cmp = pcall(require, "cmp") -if not cmp_status_ok then - return -end -cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) +local cond = require("nvim-autopairs.conds") + +autopairs.add_rules({ + Rule("`", "'", "tex"), + Rule("$", "$", "tex"), + Rule(" ", " ") + :with_pair(function(opts) + local pair = opts.line:sub(opts.col, opts.col + 1) + return vim.tbl_contains({ "$$", "()", "{}", "[]", "<>" }, pair) + end) + :with_move(cond.none()) + :with_cr(cond.none()) + :with_del(function(opts) + local col = vim.api.nvim_win_get_cursor(0)[2] + local context = opts.line:sub(col - 1, col + 2) + return vim.tbl_contains({ "$ $", "( )", "{ }", "[ ]", "< >" }, context) + end), + Rule("$ ", " ", "tex"):with_pair(cond.not_after_regex(" ")):with_del(cond.none()), + Rule("[ ", " ", "tex"):with_pair(cond.not_after_regex(" ")):with_del(cond.none()), + Rule("{ ", " ", "tex"):with_pair(cond.not_after_regex(" ")):with_del(cond.none()), + Rule("( ", " ", "tex"):with_pair(cond.not_after_regex(" ")):with_del(cond.none()), + Rule("< ", " ", "tex"):with_pair(cond.not_after_regex(" ")):with_del(cond.none()), +}) + +autopairs.get_rule("$"):with_move(function(opts) + return opts.char == opts.next_char:sub(1, 1) +end) + +-- import nvim-cmp plugin (completions plugin) +local cmp = require("cmp") + +-- import nvim-autopairs completion functionality +local cmp_autopairs = require("nvim-autopairs.completion.cmp") + +-- make autopairs and completion work together +cmp.event:on( + "confirm_done", + cmp_autopairs.on_confirm_done({ + filetypes = { + tex = false, -- Disable for tex + }, + }) +) + +--local cmp_autopairs = require "nvim-autopairs.completion.cmp" +--local cmp_status_ok, cmp = pcall(require, "cmp") +--if not cmp_status_ok then +-- return +--end +--cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) -- cgit v1.2.3 From 8a1cee79003fa4f9ee47e661a1582e0d5bb318fe Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 20 Feb 2024 23:59:06 +0200 Subject: Auto formatting --- lua/user/mods.lua | 428 +++++++++++++++++++++++++++--------------------------- 1 file changed, 217 insertions(+), 211 deletions(-) diff --git a/lua/user/mods.lua b/lua/user/mods.lua index c4431df..c20c687 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -27,13 +27,13 @@ end -------------------------------------------------- -- Format on save -local format_augroup = vim.api.nvim_create_augroup('LspFormatting', {}) -require('null-ls').setup({ +local format_augroup = vim.api.nvim_create_augroup("LspFormatting", {}) +require("null-ls").setup({ -- you can reuse a shared lspconfig on_attach callback here on_attach = function(client, bufnr) - if client.supports_method('textDocument/formatting') then + if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = format_augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd('BufWritePre', { + vim.api.nvim_create_autocmd("BufWritePre", { group = format_augroup, buffer = bufnr, callback = function() @@ -59,13 +59,13 @@ function M.empty(item) return true end local item_type = type(item) - if item_type == 'string' then - return item == '' + if item_type == "string" then + return item == "" end - if item_type == 'number' then + if item_type == "number" then return item <= 0 end - if item_type == 'table' then + if item_type == "table" then return vim.tbl_isempty(item) end return item ~= nil @@ -78,7 +78,7 @@ function M.may_create_dir(dir) local res = fn.isdirectory(dir) if res == 0 then - fn.mkdir(dir, 'p') + fn.mkdir(dir, "p") end end @@ -87,16 +87,16 @@ end --- Toggle cmp completion vim.g.cmp_toggle_flag = false -- initialize local normal_buftype = function() - return vim.api.nvim_buf_get_option(0, 'buftype') ~= 'prompt' + return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" end M.toggle_completion = function() - local ok, cmp = pcall(require, 'cmp') + local ok, cmp = pcall(require, "cmp") if ok then local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag if next_cmp_toggle_flag then - print('completion on') + print("completion on") else - print('completion off') + print("completion off") end cmp.setup({ enabled = function() @@ -109,7 +109,7 @@ M.toggle_completion = function() end, }) else - print('completion not available') + print("completion not available") end end @@ -119,12 +119,12 @@ end function M.get_nvim_version() local actual_ver = vim.version() - local nvim_ver_str = string.format('%d.%d.%d', actual_ver.major, actual_ver.minor, actual_ver.patch) + local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch) return nvim_ver_str end function M.add_pack(name) - local status, error = pcall(vim.cmd, 'packadd ' .. name) + local status, error = pcall(vim.cmd, "packadd " .. name) return status end @@ -133,11 +133,11 @@ end -- Define a global function to retrieve LSP clients based on Neovim version function M.get_lsp_clients(bufnr) - local mods = require('user.mods') + local mods = require("user.mods") --local expected_ver = '0.10.0' local nvim_ver = mods.get_nvim_version() - local version_major, version_minor = string.match(nvim_ver, '(%d+)%.(%d+)') + local version_major, version_minor = string.match(nvim_ver, "(%d+)%.(%d+)") version_major = tonumber(version_major) version_minor = tonumber(version_minor) @@ -152,17 +152,17 @@ end --- Toggle autopairs on/off (requires "windwp/nvim-autopairs") function M.Toggle_autopairs() - local ok, autopairs = pcall(require, 'nvim-autopairs') + local ok, autopairs = pcall(require, "nvim-autopairs") if ok then if autopairs.state.disabled then autopairs.enable() - print('autopairs on') + print("autopairs on") else autopairs.disable() - print('autopairs off') + print("autopairs off") end else - print('autopairs not available') + print("autopairs not available") end end @@ -185,10 +185,10 @@ end --]]) function M.findFilesInCwd() - vim.cmd('let g:rooter_manual_only = 1') -- Toggle the rooter plugin - require('plugins.telescope').findhere() + vim.cmd("let g:rooter_manual_only = 1") -- Toggle the rooter plugin + require("plugins.telescope").findhere() vim.defer_fn(function() - vim.cmd('let g:rooter_manual_only = 0') -- Change back to automatic rooter + vim.cmd("let g:rooter_manual_only = 0") -- Change back to automatic rooter end, 100) end @@ -202,19 +202,19 @@ end -- Toggle the executable permission function M.Toggle_executable() - local current_file = vim.fn.expand('%:p') + local current_file = vim.fn.expand("%:p") local executable = vim.fn.executable(current_file) == 1 if executable then -- File is executable, unset the executable permission - vim.fn.system('chmod -x ' .. current_file) + vim.fn.system("chmod -x " .. current_file) --print(current_file .. ' is no longer executable.') - print('No longer executable') + print("No longer executable") else -- File is not executable, set the executable permission - vim.fn.system('chmod +x ' .. current_file) + vim.fn.system("chmod +x " .. current_file) --print(current_file .. ' is now executable.') - print('Now executable') + print("Now executable") end end @@ -239,21 +239,21 @@ end ------ -local prev_cwd = '' +local prev_cwd = "" function M.Set_git_env_vars() local cwd = vim.fn.getcwd() - if prev_cwd == '' then + if prev_cwd == "" then -- First buffer being opened, set prev_cwd to cwd prev_cwd = cwd elseif cwd ~= prev_cwd then -- Working directory has changed since last buffer was opened prev_cwd = cwd - local git_dir_job = vim.fn.jobstart({ 'git', 'rev-parse', '--git-dir' }) + local git_dir_job = vim.fn.jobstart({ "git", "rev-parse", "--git-dir" }) local command_status = vim.fn.jobwait({ git_dir_job })[1] if command_status > 0 then - vim.env.GIT_DIR = vim.fn.expand('$HOME/.cfg') - vim.env.GIT_WORK_TREE = vim.fn.expand('~') + vim.env.GIT_DIR = vim.fn.expand("$HOME/.cfg") + vim.env.GIT_WORK_TREE = vim.fn.expand("~") else vim.env.GIT_DIR = nil vim.env.GIT_WORK_TREE = nil @@ -271,28 +271,32 @@ vim.cmd([[augroup END]]) --- Update Tmux Status Vi-mode function M.update_tmux_status() - local mode = vim.api.nvim_eval('mode()') + -- Check if the current buffer has a man filetype + if vim.bo.filetype == "man" then + return + end + local mode = vim.api.nvim_eval("mode()") -- Determine the mode name based on the mode value local mode_name - if mode == 'n' then - mode_name = '-- NORMAL --' - elseif mode == 'i' or mode == 'ic' then - mode_name = '-- INSERT --' + if mode == "n" then + mode_name = "-- NORMAL --" + elseif mode == "i" or mode == "ic" then + mode_name = "-- INSERT --" else - mode_name = '-- NORMAL --' --'-- COMMAND --' + mode_name = "-- NORMAL --" --'-- COMMAND --' end -- Write the mode name to the file - local file = io.open(os.getenv('HOME') .. '/.vi-mode', 'w') + local file = io.open(os.getenv("HOME") .. "/.vi-mode", "w") file:write(mode_name) file:close() if nvim_running then -- Neovim is running, update the mode file and refresh tmux - VI_MODE = '' -- Clear VI_MODE to show Neovim mode - vim.cmd('silent !tmux refresh-client -S') + VI_MODE = "" -- Clear VI_MODE to show Neovim mode + vim.cmd("silent !tmux refresh-client -S") end ---- Force tmux to update the status - vim.cmd('silent !tmux refresh-client -S') + vim.cmd("silent !tmux refresh-client -S") end vim.cmd([[ @@ -417,42 +421,43 @@ function M.Update_neovim() -- Create a new floating window local bufnr, winid = vim.api.nvim_create_buf(false, true) vim.api.nvim_open_win(bufnr, true, { - relative = 'editor', + relative = "editor", width = 80, height = 20, row = 2, col = 2, - style = 'minimal', - border = 'single', + style = "minimal", + border = "single", }) -- Function to append a line to the buffer in the floating window local function append_line(line) - vim.api.nvim_buf_set_option(bufnr, 'modifiable', true) + vim.api.nvim_buf_set_option(bufnr, "modifiable", true) vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, { line }) - vim.api.nvim_buf_set_option(bufnr, 'modifiable', false) + vim.api.nvim_buf_set_option(bufnr, "modifiable", false) end -- Download the latest version of Neovim - append_line('Downloading the latest version of Neovim...') - os.execute('curl -L -o nvim-linux64.tar.gz https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz') - append_line('Download complete.') + append_line("Downloading the latest version of Neovim...") + os.execute( + "curl -L -o nvim-linux64.tar.gz https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz") + append_line("Download complete.") -- Extract the downloaded archive - append_line('Extracting the downloaded archive...') - os.execute('tar xzvf nvim-linux64.tar.gz') - append_line('Extraction complete.') + append_line("Extracting the downloaded archive...") + os.execute("tar xzvf nvim-linux64.tar.gz") + append_line("Extraction complete.") -- Replace the existing Neovim installation with the new version - append_line('Replacing the existing Neovim installation...') - os.execute('rm -rf $HOME/nvim') - os.execute('mv nvim-linux64 $HOME/nvim') - append_line('Update complete.') + append_line("Replacing the existing Neovim installation...") + os.execute("rm -rf $HOME/nvim") + os.execute("mv nvim-linux64 $HOME/nvim") + append_line("Update complete.") -- Clean up the downloaded file - append_line('Cleaning up the downloaded file...') - os.execute('rm nvim-linux64.tar.gz') - append_line('Cleanup complete.') + append_line("Cleaning up the downloaded file...") + os.execute("rm nvim-linux64.tar.gz") + append_line("Cleanup complete.") -- Close the floating window after a delay vim.defer_fn(function() @@ -461,14 +466,15 @@ function M.Update_neovim() end -- Bind a keymap to the update_neovim function (optional) -vim.api.nvim_set_keymap('n', 'U', ' lua require("user.mods").Update_neovim()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap("n", "U", ' lua require("user.mods").Update_neovim()', + { noremap = true, silent = true }) -------------------------------------------------- -- Fix or suppress closing nvim error message (/src/unix/core.c:147: uv_close: Assertion `!uv__is_closing(handle)' failed.) -vim.api.nvim_create_autocmd({ 'VimLeave' }, { +vim.api.nvim_create_autocmd({ "VimLeave" }, { callback = function() - vim.fn.jobstart('!notify-send 2>/dev/null &', { detach = true }) + vim.fn.jobstart("!notify-send 2>/dev/null &", { detach = true }) end, }) @@ -483,7 +489,7 @@ vim.api.nvim_create_autocmd({ 'VimLeave' }, { local modifiedBufs = function(bufs) -- nvim-tree is also there in modified buffers so this function filter it out local t = 0 for k, v in pairs(bufs) do - if v.name:match('NvimTree_', 'NvimTree1') == nil then + if v.name:match("NvimTree_", "NvimTree1") == nil then t = t + 1 end end @@ -509,15 +515,15 @@ function M.DeleteCurrentBuffer() end if idx == size then - vim.cmd('bprevious') + vim.cmd("bprevious") else - vim.cmd('bnext') + vim.cmd("bnext") end - vim.cmd('silent! bdelete ' .. cbn) + vim.cmd("silent! bdelete " .. cbn) -- Open a new blank window - vim.cmd('silent! enew') -- Opens a new vertical split + vim.cmd("silent! enew") -- Opens a new vertical split -- OR -- vim.cmd("new") -- Opens a new horizontal split -- Delay before opening a new split @@ -530,12 +536,12 @@ end vim.cmd([[autocmd FileType NvimTree lua require("user.mods").DeleteCurrentBuffer()]]) -- On :bd nvim-tree should behave as if it wasn't opened -vim.api.nvim_create_autocmd('BufEnter', { +vim.api.nvim_create_autocmd("BufEnter", { nested = true, callback = function() -- Only 1 window with nvim-tree left: we probably closed a file buffer - if #vim.api.nvim_list_wins() == 1 and require('nvim-tree.utils').is_nvim_tree_buf() then - local api = require('nvim-tree.api') + if #vim.api.nvim_list_wins() == 1 and require("nvim-tree.utils").is_nvim_tree_buf() then + local api = require("nvim-tree.api") -- Required to let the close event complete. An error is thrown without this. vim.defer_fn(function() -- close nvim-tree: will go to the last buffer used before closing @@ -543,7 +549,7 @@ vim.api.nvim_create_autocmd('BufEnter', { -- re-open nivm-tree api.tree.toggle({ find_file = true, focus = true }) -- nvim-tree is still the active window. Go to the previous window. - vim.cmd('wincmd p') + vim.cmd("wincmd p") end, 0) end end, @@ -551,13 +557,13 @@ vim.api.nvim_create_autocmd('BufEnter', { -- Dismiss notifications when opening nvim-tree window local function isNvimTreeOpen() - local win = vim.fn.win_findbuf(vim.fn.bufnr('NvimTree')) + local win = vim.fn.win_findbuf(vim.fn.bufnr("NvimTree")) return vim.fn.empty(win) == 0 end function M.DisableNotify() if isNvimTreeOpen() then - require('notify').dismiss() + require("notify").dismiss() end end @@ -569,10 +575,10 @@ vim.cmd([[ -- Toggle Dashboard function M.toggle_dashboard() - if vim.bo.filetype == 'dashboard' then - vim.cmd('bdelete') + if vim.bo.filetype == "dashboard" then + vim.cmd("bdelete") else - vim.cmd('Dashboard') + vim.cmd("Dashboard") end end @@ -580,9 +586,9 @@ end -- Helper function to suppress errors local function silent_execute(cmd) - vim.fn['serverlist']() -- Required to prevent 'Press ENTER' prompt - local result = vim.fn.system(cmd .. ' 2>/dev/null') - vim.fn['serverlist']() + vim.fn["serverlist"]() -- Required to prevent 'Press ENTER' prompt + local result = vim.fn.system(cmd .. " 2>/dev/null") + vim.fn["serverlist"]() return result end @@ -595,14 +601,14 @@ local is_codi_open = false function M.toggleCodi() if is_codi_open then -- Close Codi - vim.cmd('Codi!') + vim.cmd("Codi!") is_codi_open = false - print('Codi off') + print("Codi off") else -- Open Codi - vim.cmd('Codi') + vim.cmd("Codi") is_codi_open = true - print('Codi on') + print("Codi on") end end @@ -614,39 +620,39 @@ local scratch_buf = nil local scratch_win = nil -- Other global variables -local scratch_date = os.date('%Y-%m-%d') -local scratch_dir = vim.fn.expand('~/notes/private') -local scratch_file = 'scratch-' .. scratch_date .. '.md' +local scratch_date = os.date("%Y-%m-%d") +local scratch_dir = vim.fn.expand("~/notes/private") +local scratch_file = "scratch-" .. scratch_date .. ".md" -- Function to close and delete a buffer function CloseAndDeleteBuffer(bufnr) if bufnr and vim.api.nvim_buf_is_valid(bufnr) then - vim.api.nvim_command('silent! bwipe ' .. bufnr) + vim.api.nvim_command("silent! bwipe " .. bufnr) end end function M.Scratch(Split_direction) -- Check if the directory exists, and create it if it doesn't if vim.fn.isdirectory(scratch_dir) == 0 then - vim.fn.mkdir(scratch_dir, 'p') + vim.fn.mkdir(scratch_dir, "p") end -- Determine the window type based on Split_direction - local current_window_type = 'float' - if Split_direction == 'float' then - current_window_type = 'float' - elseif Split_direction == 'vertical' then - current_window_type = 'vertical' - elseif Split_direction == 'horizontal' then - current_window_type = 'horizontal' + local current_window_type = "float" + if Split_direction == "float" then + current_window_type = "float" + elseif Split_direction == "vertical" then + current_window_type = "vertical" + elseif Split_direction == "horizontal" then + current_window_type = "horizontal" end - local file_path = scratch_dir .. '/' .. scratch_file + local file_path = scratch_dir .. "/" .. scratch_file if scratch_win and vim.api.nvim_win_is_valid(scratch_win) then -- Window exists, save buffer to file and close it WriteScratchBufferToFile(scratch_buf, file_path) - vim.cmd(':w!') + vim.cmd(":w!") vim.api.nvim_win_close(scratch_win, true) CloseAndDeleteBuffer(scratch_buf) scratch_win = nil @@ -667,11 +673,11 @@ end function WriteScratchBufferToFile(buf, file_path) if buf and vim.api.nvim_buf_is_valid(buf) then local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false) - local content = table.concat(lines, '\n') + local content = table.concat(lines, "\n") local escaped_file_path = vim.fn.fnameescape(file_path) -- Write the buffer content to the file - local file = io.open(escaped_file_path, 'w') + local file = io.open(escaped_file_path, "w") if file then file:write(content) file:close() @@ -694,13 +700,13 @@ function OpenScratchBuffer(file_path) else -- Insert initial content vim.api.nvim_buf_set_lines(buf, 0, -1, true, { - '# Quick Notes - ' .. scratch_date, - '--------------------------', - '', + "# Quick Notes - " .. scratch_date, + "--------------------------", + "", }) -- Save the initial content to the file - vim.cmd(':w') + vim.cmd(":w") end return buf @@ -709,24 +715,24 @@ end -- Function to open the scratch buffer in a window function OpenScratchWindow(buf, current_window_type) if buf and vim.api.nvim_buf_is_valid(buf) then - if current_window_type == 'float' then + if current_window_type == "float" then local opts = { - relative = 'win', + relative = "win", width = 120, height = 10, - border = 'single', + border = "single", row = 20, col = 20, } scratch_win = vim.api.nvim_open_win(buf, true, opts) -- Go to the last line of the buffer vim.api.nvim_win_set_cursor(scratch_win, { vim.api.nvim_buf_line_count(buf), 1 }) - elseif current_window_type == 'vertical' then - vim.cmd('vsplit') + elseif current_window_type == "vertical" then + vim.cmd("vsplit") vim.api.nvim_win_set_buf(0, buf) scratch_win = 0 - elseif current_window_type == 'horizontal' then - vim.cmd('split') + elseif current_window_type == "horizontal" then + vim.cmd("split") vim.api.nvim_win_set_buf(0, buf) scratch_win = 0 end @@ -736,26 +742,26 @@ end -------------------------------------------------- -- Intercept file open -local augroup = vim.api.nvim_create_augroup('user-autocmds', { clear = true }) +local augroup = vim.api.nvim_create_augroup("user-autocmds", { clear = true }) local intercept_file_open = true -vim.api.nvim_create_user_command('InterceptToggle', function() +vim.api.nvim_create_user_command("InterceptToggle", function() intercept_file_open = not intercept_file_open - local intercept_state = '`Enabled`' + local intercept_state = "`Enabled`" if not intercept_file_open then - intercept_state = '`Disabled`' + intercept_state = "`Disabled`" end - vim.notify('Intercept file open set to ' .. intercept_state, vim.log.levels.INFO, { - title = 'Intercept File Open', + vim.notify("Intercept file open set to " .. intercept_state, vim.log.levels.INFO, { + title = "Intercept File Open", ---@param win integer The window handle on_open = function(win) - vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), 'filetype', 'markdown') + vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), "filetype", "markdown") end, }) -end, { desc = 'Toggles intercepting BufNew to open files in custom programs' }) +end, { desc = "Toggles intercepting BufNew to open files in custom programs" }) -- NOTE: Add "BufReadPre" to the autocmd events to also intercept files given on the command line, e.g. -- `nvim myfile.txt` -vim.api.nvim_create_autocmd({ 'BufNew' }, { +vim.api.nvim_create_autocmd({ "BufNew" }, { group = augroup, callback = function(args) ---@type string @@ -764,9 +770,9 @@ vim.api.nvim_create_autocmd({ 'BufNew' }, { local bufnr = args.buf ---@type string? The file extension if detected - local extension = vim.fn.fnamemodify(path, ':e') + local extension = vim.fn.fnamemodify(path, ":e") ---@type string? The filename if detected - local filename = vim.fn.fnamemodify(path, ':t') + local filename = vim.fn.fnamemodify(path, ":t") ---Open a given file path in a given program and remove the buffer for the file. ---@param buf integer The buffer handle for the opening buffer @@ -774,17 +780,17 @@ vim.api.nvim_create_autocmd({ 'BufNew' }, { ---@param fname string The file name used in notifications ---@param prog string The program to execute against the file path local function open_in_prog(buf, fpath, fname, prog) - vim.notify(string.format('Opening `%s` in `%s`', fname, prog), vim.log.levels.INFO, { - title = 'Open File in External Program', + vim.notify(string.format("Opening `%s` in `%s`", fname, prog), vim.log.levels.INFO, { + title = "Open File in External Program", ---@param win integer The window handle on_open = function(win) - vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), 'filetype', 'markdown') + vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), "filetype", "markdown") end, }) - local mods = require('user.mods') + local mods = require("user.mods") local nvim_ver = mods.get_nvim_version() - local version_major, version_minor = string.match(nvim_ver, '(%d+)%.(%d+)') + local version_major, version_minor = string.match(nvim_ver, "(%d+)%.(%d+)") version_major = tonumber(version_major) version_minor = tonumber(version_minor) @@ -797,21 +803,21 @@ vim.api.nvim_create_autocmd({ 'BufNew' }, { end local extension_callbacks = { - ['pdf'] = function(buf, fpath, fname) - open_in_prog(buf, fpath, fname, 'zathura') + ["pdf"] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, "zathura") end, - ['epub'] = function(buf, fpath, fname) - open_in_prog(buf, fpath, fname, 'zathura') + ["epub"] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, "zathura") end, - ['mobi'] = 'pdf', - ['png'] = function(buf, fpath, fname) - open_in_prog(buf, fpath, fname, 'vimiv') + ["mobi"] = "pdf", + ["png"] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, "vimiv") end, - ['jpg'] = 'png', - ['mp4'] = function(buf, fpath, fname) - open_in_prog(buf, fpath, fname, 'vlc') + ["jpg"] = "png", + ["mp4"] = function(buf, fpath, fname) + open_in_prog(buf, fpath, fname, "vlc") end, - ['gif'] = 'mp4', + ["gif"] = "mp4", } ---Get the extension callback for a given extension. Will do a recursive lookup if an extension callback is actually @@ -820,15 +826,15 @@ vim.api.nvim_create_autocmd({ 'BufNew' }, { ---@return fun(bufnr: integer, path: string, filename: string?) extension_callback The extension callback to invoke, expects a buffer handle, file path, and filename. local function extension_lookup(ext) local callback = extension_callbacks[ext] - if type(callback) == 'string' then + if type(callback) == "string" then callback = extension_lookup(callback) end return callback end - if extension ~= nil and not extension:match('^%s*$') and intercept_file_open then + if extension ~= nil and not extension:match("^%s*$") and intercept_file_open then local callback = extension_lookup(extension) - if type(callback) == 'function' then + if type(callback) == "function" then callback(bufnr, path, filename) end end @@ -838,10 +844,10 @@ vim.api.nvim_create_autocmd({ 'BufNew' }, { -------------------------------------------------- -- Delete [No Name] buffers -vim.api.nvim_create_autocmd('BufHidden', { - desc = 'Delete [No Name] buffers', +vim.api.nvim_create_autocmd("BufHidden", { + desc = "Delete [No Name] buffers", callback = function(event) - if event.file == '' and vim.bo[event.buf].buftype == '' and not vim.bo[event.buf].modified then + if event.file == "" and vim.bo[event.buf].buftype == "" and not vim.bo[event.buf].modified then vim.schedule(function() pcall(vim.api.nvim_buf_delete, event.buf, {}) end) @@ -856,127 +862,127 @@ local codeRunnerEnabled = false function M.toggleCodeRunner() codeRunnerEnabled = not codeRunnerEnabled if codeRunnerEnabled then - print('Code Runner enabled') + print("Code Runner enabled") M.RunCode() -- Execute when enabled else - print('Code Runner disabled') + print("Code Runner disabled") -- Close the terminal window when disabled local buffers = vim.fn.getbufinfo() for _, buf in ipairs(buffers) do - local type = vim.api.nvim_buf_get_option(buf.bufnr, 'buftype') - if type == 'terminal' then - vim.api.nvim_command('silent! bdelete ' .. buf.bufnr) + local type = vim.api.nvim_buf_get_option(buf.bufnr, "buftype") + if type == "terminal" then + vim.api.nvim_command("silent! bdelete " .. buf.bufnr) end end end end local function substitute(cmd) - cmd = cmd:gsub('%%', vim.fn.expand('%')) - cmd = cmd:gsub('$fileBase', vim.fn.expand('%:r')) - cmd = cmd:gsub('$filePath', vim.fn.expand('%:p')) - cmd = cmd:gsub('$file', vim.fn.expand('%')) - cmd = cmd:gsub('$dir', vim.fn.expand('%:p:h')) - cmd = cmd:gsub('#', vim.fn.expand('#')) - cmd = cmd:gsub('$altFile', vim.fn.expand('#')) + cmd = cmd:gsub("%%", vim.fn.expand("%")) + cmd = cmd:gsub("$fileBase", vim.fn.expand("%:r")) + cmd = cmd:gsub("$filePath", vim.fn.expand("%:p")) + cmd = cmd:gsub("$file", vim.fn.expand("%")) + cmd = cmd:gsub("$dir", vim.fn.expand("%:p:h")) + cmd = cmd:gsub("#", vim.fn.expand("#")) + cmd = cmd:gsub("$altFile", vim.fn.expand("#")) return cmd end function M.RunCode() if not codeRunnerEnabled then - print('Code Runner is currently disabled. Toggle it on to execute code.') + print("Code Runner is currently disabled. Toggle it on to execute code.") return end - local file_extension = vim.fn.expand('%:e') - local selected_cmd = '' + local file_extension = vim.fn.expand("%:e") + local selected_cmd = "" local supported_filetypes = { html = { - default = '%', + default = "%", }, c = { - default = 'gcc % -o $fileBase && ./$fileBase', - debug = 'gcc -g % -o $fileBase && ./$fileBase', + default = "gcc % -o $fileBase && ./$fileBase", + debug = "gcc -g % -o $fileBase && ./$fileBase", }, cs = { - default = 'dotnet run', + default = "dotnet run", }, cpp = { - default = 'g++ % -o $fileBase && ./$fileBase', - debug = 'g++ -g % -o ./$fileBase', - competitive = 'g++ -std=c++17 -Wall -DAL -O2 % -o $fileBase && $fileBase Date: Fri, 1 Mar 2024 17:21:36 +0200 Subject: Add nvim-surround settings for markdown --- after/ftplugin/markdown.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua index 718a871..9a6427f 100644 --- a/after/ftplugin/markdown.lua +++ b/after/ftplugin/markdown.lua @@ -7,6 +7,7 @@ vim.wo.colorcolumn = "0" vim.wo.conceallevel = 3 vim.opt.softtabstop = 2 -- Tab key indents by 2 spaces. vim.opt.shiftwidth = 2 -- >> indents by 2 spaces. +-- vim.g.markdown_recommended_style = 0 -- prevents markdown from changing tabs to 4 spaces vim.b[0].undo_ftplugin = "setlocal nospell nowrap nolinebreak nobreakindent conceallevel=0" @@ -14,3 +15,23 @@ vim.cmd([[ autocmd FileType markdown iabbrev `` `` ]]) +require("nvim-surround").buffer_setup({ + surrounds = { + -- ["e"] = { + -- add = function() + -- local env = require("nvim-surround.config").get_input ("Environment: ") + -- return { { "\\begin{" .. env .. "}" }, { "\\end{" .. env .. "}" } } + -- end, + -- }, + ["b"] = { + add = { "**", "**" }, + find = "**.-**", + delete = "^(**)().-(**)()$", + }, + ["i"] = { + add = { "_", "_" }, + find = "_.-_", + delete = "^(_)().-(_)()$", + }, + }, +}) -- cgit v1.2.3 From 13b6952bf65988b1cbc0b1482aa1ace448a2b2d6 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 1 Mar 2024 17:22:21 +0200 Subject: Completion for latex added --- lua/plugins/cmp.lua | 342 ++++++++++++++++++++++++++++------------------------ 1 file changed, 182 insertions(+), 160 deletions(-) diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index edf57de..fe212fc 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -1,24 +1,22 @@ - -- Setup nvim-cmp. vim.opt.completeopt = "menu,menuone,noselect" --vim.g.completeopt = "menu,menuone,noselect,noinsert" local cmp_status_ok, cmp = pcall(require, "cmp") if not cmp_status_ok then - return + return end --local WIDE_HEIGHT = 40 local opts = { - -- whether to highlight the currently hovered symbol - -- disable if your cpu usage is higher than you want it - -- or you just hate the highlight - -- default: true - highlight_hovered_item = true, - show_guides = true, + -- whether to highlight the currently hovered symbol + -- disable if your cpu usage is higher than you want it + -- or you just hate the highlight + -- default: true + highlight_hovered_item = true, + show_guides = true, } require("symbols-outline").setup(opts) - --local snippets_paths = function() -- local plugins = { "friendly-snippets" } -- local paths = {} @@ -69,27 +67,27 @@ local kind_icons = { TypeParameter = "", } cmp.setup({ - snippet = { - --expand = function(args) - -- require("luasnip").lsp_expand(args.body) - --end, + snippet = { + --expand = function(args) + -- require("luasnip").lsp_expand(args.body) + --end, expand = function(args) local luasnip = require("luasnip") if not luasnip then - return + return end luasnip.lsp_expand(args.body) end, - }, - mapping = cmp.mapping.preset.insert({ --- [""] = cmp.mapping.confirm({ --- behavior = cmp.ConfirmBehavior.Replace, --- select = true, --- }), + }, + mapping = cmp.mapping.preset.insert({ + -- [""] = cmp.mapping.confirm({ + -- behavior = cmp.ConfirmBehavior.Replace, + -- select = true, + -- }), --[""] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), --[""] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), - [''] = cmp.mapping.confirm({ select = true }), - --[""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm({ select = true }), + --[""] = cmp.mapping.close(), --[''] = cmp.mapping({ -- i = cmp.mapping.abort(), -- c = cmp.mapping.close(), @@ -118,30 +116,30 @@ cmp.setup({ -- end, --}), --- [""] = cmp.mapping({ --- i = function() --- if cmp.visible() then --- require("notify")("visible") --- cmp.abort() --- else --- require("notify")("not visible") --- cmp.complete() --- end --- end, --- c = function() --- if cmp.visible() then --- require("notify")("visible") --- cmp.close() --- else --- require("notify")("not visible") --- cmp.complete() --- end --- end, --- }), + -- [""] = cmp.mapping({ + -- i = function() + -- if cmp.visible() then + -- require("notify")("visible") + -- cmp.abort() + -- else + -- require("notify")("not visible") + -- cmp.complete() + -- end + -- end, + -- c = function() + -- if cmp.visible() then + -- require("notify")("visible") + -- cmp.close() + -- else + -- require("notify")("not visible") + -- cmp.complete() + -- end + -- end, + -- }), --[''] = cmp.config.disable, - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), --[''] = function(fallback) -- if cmp.visible() then -- cmp.mapping.confirm({ select = true })(fallback) @@ -149,60 +147,60 @@ cmp.setup({ -- cmp.mapping.complete()(fallback) -- end --end - }), + }), sources = cmp.config.sources({ - --{ name = "nvim_lua" }, + --{ name = "nvim_lua" }, { name = "luasnip" }, - --{ name = 'luasnip', option = { use_show_condition = false } }, - { name = "gh_issues" }, - { name = "nvim_lsp", max_item_count = 6 }, + --{ name = 'luasnip', option = { use_show_condition = false } }, + { name = "gh_issues" }, + { name = "nvim_lsp", max_item_count = 6 }, { name = "nvim_lua" }, - --{ name = "luasnip" }, - --{ name = "luasnip", keyword_length = 4 }, - --{ name = "buffer", keyword_length = 3 }, - { name = "path" }, - { name = "buffer", max_item_count = 6 }, + --{ name = "luasnip" }, + --{ name = "luasnip", keyword_length = 4 }, + --{ name = "buffer", keyword_length = 3 }, + { name = "path" }, + { name = "buffer", max_item_count = 6 }, --{ name = "buffer", option = { get_bufnrs = function() -- return vim.api.nvim_list_bufs() --end --}}, - { name = "cmp_git"}, - { name = "spell"}, + { name = "cmp_git" }, + { name = "spell" }, { name = "zsh" }, { name = "treesitter" }, { name = "calc" }, { name = "nvim_lsp_signature_help" }, --{ name = "cmdline" }, --{ name = 'treesitter' }, - --{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this - --{name = 'luasnip', keyword_length = 2}, - }), - formatting = { - --formatting = { - --local icons = kind_icons - --format = function(entry, vim_item) - ----vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - ----vim_item.kind = lspkind.presets.default[vim_item.kind] - --vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind - ----vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) - --vim_item.menu = ({ - ----nvim_lsp = "LSP", - ----luasnip = "snip", - ----buffer = "buf", - ----path = "path", - ----cmdline = "cmd", - --buffer = "[buf]", - --nvim_lsp = "[LSP]", - --nvim_lua = "[api]", - --path = "[path]", - --luasnip = "[snip]", - --cmdline = "[cmd]", - --gh_issues = "[issues]", - --})[entry.source.name] - --return vim_item - --end, - format = lspkind.cmp_format { + --{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this + --{name = 'luasnip', keyword_length = 2}, + }), + formatting = { + --formatting = { + --local icons = kind_icons + --format = function(entry, vim_item) + ----vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + ----vim_item.kind = lspkind.presets.default[vim_item.kind] + --vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + ----vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind) + --vim_item.menu = ({ + ----nvim_lsp = "LSP", + ----luasnip = "snip", + ----buffer = "buf", + ----path = "path", + ----cmdline = "cmd", + --buffer = "[buf]", + --nvim_lsp = "[LSP]", + --nvim_lua = "[api]", + --path = "[path]", + --luasnip = "[snip]", + --cmdline = "[cmd]", + --gh_issues = "[issues]", + --})[entry.source.name] + --return vim_item + --end, + format = lspkind.cmp_format({ with_text = true, menu = { nvim_lsp = "[LSP]", @@ -216,19 +214,18 @@ cmp.setup({ treesitter = "[treesitter]", calc = "[calc]", nvim_lsp_signature_help = "[signature]", - cmdline = "[cmd]" - + cmdline = "[cmd]", }, - }, - --}, + }), + --}, -- -- - --fields = { "abbr", "kind", "menu" }, - -- format = 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) - -- }) + --fields = { "abbr", "kind", "menu" }, + -- format = 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) + -- }) --format = require('lspkind').cmp_format { -- with_text = true, -- menu = { @@ -241,92 +238,117 @@ cmp.setup({ -- }, --}, }, - --format = function(entry, vim_item) - -- -- Kind icons - -- --vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - -- vim_item.kind = lspkind.presets.default[vim_item.kind] - -- -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind - -- vim_item.menu = ({ - -- nvim_lsp = "LSP", - -- luasnip = "Snip", - -- buffer = "Buf", - -- path = "Path", - -- cmdline = "Cmd", - -- })[entry.source.name] - -- return vim_item - --end, + --format = function(entry, vim_item) + -- -- Kind icons + -- --vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = lspkind.presets.default[vim_item.kind] + -- -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + -- vim_item.menu = ({ + -- nvim_lsp = "LSP", + -- luasnip = "Snip", + -- buffer = "Buf", + -- path = "Path", + -- cmdline = "Cmd", + -- })[entry.source.name] + -- return vim_item + --end, confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, event = {}, - experimental = { - ghost_text = true, -- this feature conflicts with copilot.vim's preview. - hl_group = 'Nontext', - --native_menu = false, - }, + experimental = { + ghost_text = true, -- this feature conflicts with copilot.vim's preview. + hl_group = "Nontext", + --native_menu = false, + }, - view = { - entries = { name = 'custom', selection_order = 'top_down' }, - }, + view = { + entries = { name = "custom", selection_order = "top_down" }, + }, - window = { - --completion = cmp.config.window.bordered(), - completion = { - border = { '', '', '', ' ', '', '', '', ' ' }, - --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, - --border = { '', '', '', '', '', '', '', '' }, - --border = "CmpBorder", - winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None', - --winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", - }, - --documentation = cmp.config.window.bordered(), - documentation = { - --max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)), - --max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))), - border = { '', '', '', ' ', '', '', '', ' ' }, - --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, - winhighlight = 'FloatBorder:NormalFloat', - }, + window = { + --completion = cmp.config.window.bordered(), + completion = { + border = { "", "", "", " ", "", "", "", " " }, + --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + --border = { '', '', '', '', '', '', '', '' }, + --border = "CmpBorder", + winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None", + --winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None", + }, + --documentation = cmp.config.window.bordered(), + documentation = { + --max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)), + --max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))), + border = { "", "", "", " ", "", "", "", " " }, + --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + winhighlight = "FloatBorder:NormalFloat", }, + }, }) - -cmp.setup.cmdline({ '/', '?' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, +cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, }, }) cmp.setup.cmdline(":", { mapping = { - [""] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), - [""] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }), - [""] = cmp.mapping(cmp.mapping.confirm({ select = true }), { 'i', 'c' }), - [""] = cmp.mapping(cmp.mapping.close(), { 'i', 'c' }), - [""] = 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(cmp.mapping.select_prev_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.confirm({ select = true }), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.close(), { "i", "c" }), + [""] = 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.select_prev_item(), --[""] = cmp.mapping.select_next_item(), --[''] = cmp.mapping.confirm({ select = true }), - --[""] = cmp.mapping.close(), + --[""] = cmp.mapping.close(), ----[''] = cmp.config.disable, - --[""] = cmp.mapping.scroll_docs(-4), - --[""] = cmp.mapping.scroll_docs(4), - --[""] = cmp.mapping.complete(), + --[""] = cmp.mapping.scroll_docs(-4), + --[""] = cmp.mapping.scroll_docs(4), + --[""] = cmp.mapping.complete(), }, - sources = cmp.config.sources({ - { name = "path" }, - }, { - --{ name = "cmdline" }, + sources = cmp.config.sources({ + { name = "path" }, + }, { + --{ name = "cmdline" }, { name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 }, - }) + }), }) - +return { + "micangl/cmp-vimtex", + config = function() + require("cmp_vimtex").setup({ + additional_information = { + info_in_menu = true, + info_in_window = true, + info_max_length = 60, + match_against_info = true, + symbols_in_menu = true, + }, + bibtex_parser = { + enabled = true, + }, + search = { + browser = "xdg-open", + default = "google_scholar", + search_engines = { + google_scholar = { + name = "Google Scholar", + get_url = require("cmp_vimtex").url_default_format("https://scholar.google.com/scholar?hl=en&q=%s"), + }, + -- Other search engines. + }, + }, + }) + end, +} -- cgit v1.2.3 From 521d5622bf9348e49f6769753b669175463ab5de Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Mar 2024 19:42:15 +0200 Subject: Install "lukas-reineke/indent-blankline.nvim" --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 2ad3db6..3af12f7 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -264,6 +264,7 @@ return packer.startup(function(use) use("kyazdani42/nvim-web-devicons") -- use("onsails/lspkind-nvim") -- use({ "kevinhwang91/nvim-ufo", requires = "kevinhwang91/promise-async" }) -- Fold code + use("lukas-reineke/indent-blankline.nvim") use({ "luukvbaal/statuscol.nvim", config = function() -- cgit v1.2.3 From f7a22326bf2d58626a32bda10832856f4508850a Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Mar 2024 19:42:37 +0200 Subject: Enable indent-blankline plugin --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index a94213e..409f7c8 100644 --- a/init.lua +++ b/init.lua @@ -100,6 +100,7 @@ local modules = { "plugins.notify", "plugins.overseer", "plugins.vimtex", + "plugins.indent-blankline", --"plugins.modify-blend", } -- cgit v1.2.3 From 216da32c6bddb80defaac46b3d21a35f22c3a5f4 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Mar 2024 19:42:54 +0200 Subject: Add indent-blankline config/plugin --- lua/plugins/indent-blankline.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lua/plugins/indent-blankline.lua diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..25a2da0 --- /dev/null +++ b/lua/plugins/indent-blankline.lua @@ -0,0 +1,24 @@ +--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) + +require("ibl").setup({ indent = { highlight = highlight } }) -- cgit v1.2.3 From c68754cd1760da7c89ccaab9fb65572d5399c881 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 6 Mar 2024 19:43:19 +0200 Subject: Removed rustfmt --- lua/plugins/lsp.lua | 178 +++++++++++++++++++++++++++------------------------- 1 file changed, 93 insertions(+), 85 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index b081cb4..286e0d2 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,30 +1,32 @@ -local lspconfig = require('lspconfig') -local mason_lspconfig = require('mason-lspconfig') -local null_ls = require('null-ls') +local lspconfig = require("lspconfig") +local mason_lspconfig = require("mason-lspconfig") +local null_ls = require("null-ls") -- local lsp_lines = require('lsp_lines') -require('mason').setup() -require('mason-null-ls').setup({ handlers = {}, ensure_installed = nil, automatic_installation = true, automatic_setup = true }) +require("mason").setup() +require("mason-null-ls").setup({ handlers = {}, ensure_installed = nil, automatic_installation = true, + automatic_setup = true }) local keymap = vim.keymap local cmd = vim.cmd -local border = { { '┌', 'FloatBorder' }, { '─', 'FloatBorder' }, { '┐', 'FloatBorder' }, { '│', 'FloatBorder' }, { '┘', 'FloatBorder' }, { '─', 'FloatBorder' }, { '└', 'FloatBorder' }, { '│', 'FloatBorder' } } +local border = { { "┌", "FloatBorder" }, { "─", "FloatBorder" }, { "┐", "FloatBorder" }, { "│", "FloatBorder" }, + { "┘", "FloatBorder" }, { "─", "FloatBorder" }, { "└", "FloatBorder" }, { "│", "FloatBorder" } } -- Set up LSP servers if not done before if not vim.g.lsp_setup_done then -- Clear existing LSP clients for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do - local clients = require('user.mods').get_lsp_clients(bufnr) + local clients = require("user.mods").get_lsp_clients(bufnr) for _, client in ipairs(clients) do client.stop() end end - local signs = { Error = ' ', Warn = '▲', Info = '􀅳', Hint = '⚑' } + local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } --  for type, icon in pairs(signs) do - local hl = 'DiagnosticSign' .. type + local hl = "DiagnosticSign" .. type vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) end @@ -47,7 +49,7 @@ if not vim.g.lsp_setup_done then virtual_lines = false, float = { show_header = true, - source = 'if_many', -- border = 'rounded', + source = "if_many", -- border = 'rounded', border = border, focusable = true, }, @@ -55,15 +57,16 @@ if not vim.g.lsp_setup_done then severity_sort = true, -- default to false }) - vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = false, virtual_text = false, signs = true, update_in_insert = false }) + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, + { underline = false, virtual_text = false, signs = true, update_in_insert = false }) - 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' }) + 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" }) -- Use an on_attach function to only map the following keys after the language server attaches to the current buffer local on_attach = function(client, bufnr) -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") local map = function(mode, l, r, opts) opts = opts or {} opts.silent = true @@ -72,40 +75,41 @@ if not vim.g.lsp_setup_done then keymap.set(mode, l, r, opts) end -- Mappings - map('n', 'K', 'lua vim.lsp.buf.hover()') + map("n", "K", "lua vim.lsp.buf.hover()") -- map("n", "gd", "lua vim.lsp.buf.definition()") - map('n', 'gd', "lua require('goto-preview').goto_preview_definition()") + map("n", "gd", "lua require('goto-preview').goto_preview_definition()") -- map("n", "gi", "lua vim.lsp.buf.implementation()") - map('n', 'gi', "lua require('goto-preview').goto_preview_implementation()") + map("n", "gi", "lua require('goto-preview').goto_preview_implementation()") -- map("n", "gr", "lua vim.lsp.buf.references()") - map('n', 'gr', "lua require('goto-preview').goto_preview_references()") - map('n', 'gD', 'lua vim.lsp.buf.declaration()') -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. - map('n', 'k', 'lua vim.lsp.buf.signature_help()') + map("n", "gr", "lua require('goto-preview').goto_preview_references()") + map("n", "gD", "lua vim.lsp.buf.declaration()") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. + map("n", "k", "lua vim.lsp.buf.signature_help()") -- map("n", "gt", "lua vim.lsp.buf.type_definition()") - map('n', 'gt', "lua require('goto-preview').goto_preview_type_definition()") - map('n', 'gn', 'lua vim.lsp.buf.rename()') - map('n', 'ga', 'lua vim.lsp.buf.code_action()') - map('n', 'gf', 'lua vim.lsp.buf.format()') - map('n', 'go', 'lua vim.diagnostic.open_float()') - map('n', 'go', ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") - map('n', 'gq', 'lua vim.diagnostic.setloclist()') - map('n', '[d', 'lua vim.diagnostic.goto_prev()') - map('n', ']d', 'lua vim.diagnostic.goto_next()') - map('n', 'gs', 'lua vim.lsp.buf.document_symbol()') - map('n', 'gw', 'lua vim.lsp.buf.workspace_symbol()') - map('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()') - map('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()') - map('n', 'wl', function() + map("n", "gt", "lua require('goto-preview').goto_preview_type_definition()") + map("n", "gn", "lua vim.lsp.buf.rename()") + map("n", "ga", "lua vim.lsp.buf.code_action()") + map("n", "gf", "lua vim.lsp.buf.format()") + map("n", "go", "lua vim.diagnostic.open_float()") + map("n", "go", + ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") + map("n", "gq", "lua vim.diagnostic.setloclist()") + map("n", "[d", "lua vim.diagnostic.goto_prev()") + map("n", "]d", "lua vim.diagnostic.goto_next()") + map("n", "gs", "lua vim.lsp.buf.document_symbol()") + map("n", "gw", "lua vim.lsp.buf.workspace_symbol()") + map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") + map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") + map("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end) -- TODO: Use the nicer new API for autocommands - cmd('augroup lsp_aucmds') + cmd("augroup lsp_aucmds") if client.server_capabilities.documentHighlightProvider then - cmd('au CursorHold lua vim.lsp.buf.document_highlight()') - cmd('au CursorMoved lua vim.lsp.buf.clear_references()') + cmd("au CursorHold lua vim.lsp.buf.document_highlight()") + cmd("au CursorMoved lua vim.lsp.buf.clear_references()") end - cmd('augroup END') + cmd("augroup END") end -- Toggle diagnostics visibility @@ -130,11 +134,11 @@ if not vim.g.lsp_setup_done then ]]) -- Suppress error messages from lang servers - vim.lsp.set_log_level('debug') + vim.lsp.set_log_level("debug") local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require('cmp_nvim_lsp').default_capabilities() + capabilities = require("cmp_nvim_lsp").default_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities.offsetEncoding = { 'utf-8', 'utf-16' } + capabilities.offsetEncoding = { "utf-8", "utf-16" } local function prefer_null_ls_fmt(client) client.server_capabilities.documentHighlightProvider = true @@ -149,41 +153,44 @@ if not vim.g.lsp_setup_done then clangd = { on_attach = on_attach, capabilites = capabilities, - cmd = { 'clangd', '--offset-encoding=utf-16', '--cross-file-rename', '--header-insertion=never', '--suggest-missing-includes' }, + cmd = { "clangd", "--offset-encoding=utf-16", "--cross-file-rename", "--header-insertion=never", + "--suggest-missing-includes" }, init_options = { clangdFileStatus = true, }, root_files = { - '.clangd', - '.clang-tidy', - '.clang-format', - 'compile_commands.json', - 'compile_flags.txt', - 'configure.ac', -- AutoTools + ".clangd", + ".clang-tidy", + ".clang-format", + "compile_commands.json", + "compile_flags.txt", + "configure.ac", -- AutoTools }, }, - cssls = { filetypes = { 'css', 'scss', 'less', 'sass' }, root_dir = lspconfig.util.root_pattern('package.json', '.git') }, -- ghcide = {}, + cssls = { filetypes = { "css", "scss", "less", "sass" }, + root_dir = lspconfig.util.root_pattern("package.json", ".git") }, -- ghcide = {}, html = {}, - jsonls = { prefer_null_ls = true, cmd = { '--stdio' } }, + jsonls = { prefer_null_ls = true, cmd = { "--stdio" } }, intelephense = {}, julials = { on_new_config = function(new_config, _) - local julia = vim.fn.expand('~/.julia/environments/nvim-lspconfig/bin/julia') + local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") if lspconfig.util.path.is_file(julia) then new_config.cmd[1] = julia end end, settings = { julia = { format = { indent = 2 } } }, }, - pyright = { settings = { python = { formatting = { provider = 'yapf' }, linting = { pytypeEnabled = true } } } }, + pyright = { settings = { python = { formatting = { provider = "yapf" }, linting = { pytypeEnabled = true } } } }, rust_analyzer = { settings = { - ['rust-analyzer'] = { cargo = { allFeatures = true }, checkOnSave = { command = 'clippy', extraArgs = { '--no-deps' } } }, + ["rust-analyzer"] = { cargo = { allFeatures = true }, checkOnSave = { command = "clippy", + extraArgs = { "--no-deps" } } }, }, }, dartls = { - cmd = { 'dart', 'language-server', '--protocol=lsp' }, - filetypes = { 'dart' }, + cmd = { "dart", "language-server", "--protocol=lsp" }, + filetypes = { "dart" }, init_options = { closingLabels = true, flutterOutline = true, @@ -200,20 +207,20 @@ if not vim.g.lsp_setup_done then debounce_text_changes = 500, settings = { Lua = { - runtime = { version = 'LuaJIT', path = vim.split(package.path, ';') }, - diagnostics = { enable = true, globals = { 'vim' } }, + runtime = { version = "LuaJIT", path = vim.split(package.path, ";") }, + diagnostics = { enable = true, globals = { "vim" } }, workspace = { maxPreload = 2000, preloadFileSize = 50000, checkThirdParty = false }, }, }, }, sqlls = {}, tsserver = { - capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), + capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), on_attach = function(client) client.server_capabilities.document_formatting = false client.server_capabilities.document_range_formatting = false end, - filetypes = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx' }, + filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" }, }, vimls = {}, yamlls = {}, @@ -269,7 +276,7 @@ if not vim.g.lsp_setup_done then -- null_ls setup local builtins = null_ls.builtins - local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -- local eslint_opts = { -- -- condition = function(utils) @@ -299,10 +306,10 @@ if not vim.g.lsp_setup_done then update_in_insert = false, severity_sort = true, }, - diagnostics_format = '[#{c}] #{m} (#{s})', -- this will run every time the source runs, + diagnostics_format = "[#{c}] #{m} (#{s})", -- this will run every time the source runs, -- so you should prefer caching results if possible }), - builtins.diagnostics.zsh.with({ filetypes = 'zsh', 'sh' }), + builtins.diagnostics.zsh.with({ filetypes = "zsh", "sh" }), builtins.diagnostics.todo_comments, builtins.diagnostics.teal, -- null_ls.builtins.diagnostics.vale, @@ -313,44 +320,45 @@ if not vim.g.lsp_setup_done then builtins.diagnostics.flake8, builtins.diagnostics.eslint_d.with({ condition = function(utils) - return utils.root_has_file('.eslintrc.json') + return utils.root_has_file(".eslintrc.json") end, }), builtins.formatting.eslint_d, -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, -- Formatting - builtins.formatting.shfmt.with({ filetypes = { 'bash', 'zsh', 'sh' }, extra_args = { '-i', '2', '-ci' } }), + builtins.formatting.shfmt.with({ filetypes = { "bash", "zsh", "sh" }, extra_args = { "-i", "2", "-ci" } }), builtins.formatting.shellharden, - builtins.formatting.trim_whitespace.with({ filetypes = { 'tmux', 'teal', 'zsh' } }), -- builtins.formatting.beautysh, - builtins.formatting.beautysh.with({ filetypes = 'zsh' }), + builtins.formatting.trim_whitespace.with({ filetypes = { "tmux", "teal", "zsh" } }), -- builtins.formatting.beautysh, + builtins.formatting.beautysh.with({ filetypes = "zsh" }), builtins.formatting.clang_format.with({ - filetypes = { 'c', 'cpp', 'cs', 'java', 'cuda', 'proto' }, + filetypes = { "c", "cpp", "cs", "java", "cuda", "proto" }, extra_args = { - '--style', - '{BasedOnStyle: Google, IndentWidth: 4, BreakBeforeBinaryOperators: NonAssignment, AllowShortFunctionsOnASingleLine: None}', + "--style", + "{BasedOnStyle: Google, IndentWidth: 4, BreakBeforeBinaryOperators: NonAssignment, AllowShortFunctionsOnASingleLine: None}", }, }), - builtins.formatting.rustfmt, + --builtins.formatting.rustfmt, builtins.formatting.sql_formatter, -- null_ls.builtins.formatting.cmake_format, builtins.formatting.isort, builtins.formatting.htmlbeautifier, -- null_ls.builtins.formatting.prettier, builtins.formatting.prettierd, builtins.formatting.prettier.with({ - filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'json', 'yaml', 'markdown', 'html', 'css', 'scss', 'less', 'graphql', 'vue', 'svelte' }, - extra_args = { '--single-quote', '--tab-width 4', '--print-width 200' }, + filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", + "css", "scss", "less", "graphql", "vue", "svelte" }, + extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, }), - builtins.formatting.rustfmt, -- builtins.formatting.stylua, -- builtins.formatting.lua_format, builtins.formatting.stylua.with({ - filetypes = { 'lua' }, - command = 'stylua', - args = { '--quote_style', 'AutoPreferSingle', '--indent-width', '2', '--column-width', '160', '--indent-type', 'Spaces', '-' }, + filetypes = { "lua" }, + command = "stylua", + args = { "--quote_style", "AutoPreferSingle", "--indent-width", "2", "--column-width", "160", "--indent-type", + "Spaces", "-" }, }), -- builtins.formatting.dart_format, - builtins.formatting.dart_format.with({ filetypes = { 'dart' } }), + builtins.formatting.dart_format.with({ filetypes = { "dart" } }), builtins.formatting.trim_whitespace, builtins.formatting.yapf, -- null_ls.builtins.formatting.black @@ -378,9 +386,9 @@ if not vim.g.lsp_setup_done then sources = sources, update_in_insert = true, on_attach = function(client, bufnr) - if client.supports_method('textDocument/formatting') then + if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd('BufWritePre', { + vim.api.nvim_create_autocmd("BufWritePre", { group = augroup, buffer = bufnr, callback = function() @@ -392,7 +400,7 @@ if not vim.g.lsp_setup_done then }) -- Install all the null-ls sources using Mason - local registry = require('mason-registry') + local registry = require("mason-registry") for _, source_name in ipairs(sources) do local ok, pkg = pcall(registry.get_package, source_name) if ok then @@ -413,17 +421,17 @@ if not vim.g.lsp_setup_done then -- end -- end -- end - vim.api.nvim_create_user_command('NullLsToggle', function() + vim.api.nvim_create_user_command("NullLsToggle", function() -- you can also create commands to disable or enable sources - require('null-ls').toggle({}) + require("null-ls").toggle({}) end, {}) local null_ls_stop = function() local null_ls_client - local clients = require('user.mods').get_lsp_clients(bufnr) + local clients = require("user.mods").get_lsp_clients(bufnr) for _, client in ipairs(clients) do - if client.name == 'null-ls' then + if client.name == "null-ls" then null_ls_client = client end end @@ -434,7 +442,7 @@ if not vim.g.lsp_setup_done then null_ls_client.stop() end - vim.api.nvim_create_user_command('NullLsStop', null_ls_stop, {}) + vim.api.nvim_create_user_command("NullLsStop", null_ls_stop, {}) vim.g.lsp_setup_done = true end -- cgit v1.2.3 From 341009091c6d309b766645beca7a42adcb7e661a Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 3 Apr 2024 23:27:39 +0200 Subject: File formatted with double quotation marks instead of single --- lua/plugins/dap.lua | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 3189f4f..98ae3fd 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -1,11 +1,11 @@ -local dap = require('dap') +local dap = require("dap") -- options -dap.defaults.fallback.switchbuf = 'uselast' +dap.defaults.fallback.switchbuf = "uselast" dap.defaults.fallback.focus_terminal = true dap.defaults.fallback.external_terminal = { - command = '/usr/bin/wezterm', - args = { '-e' }, + command = "/usr/bin/wezterm", + args = { "-e" }, } -- Autocmds @@ -18,31 +18,31 @@ vim.api.nvim_create_autocmd("FileType", { }) dap.adapters.cppdbg = { - id = 'cppdbg', - type = 'executable', + id = "cppdbg", + type = "executable", --command = vim.fn.stdpath('data') .. '/mason/bin/OpenDebugAD7', - command = os.getenv("HOME") .. '/apps/cpptools/extension/debugAdapters/bin/OpenDebugAD7', + command = os.getenv("HOME") .. "/apps/cpptools/extension/debugAdapters/bin/OpenDebugAD7", --command = cpptools:get_install_path() .. '/extension/debugAdapters/bin/OpenDebugAD7' } dap.adapters.codelldb = { - type = 'server', - port = '${port}', + type = "server", + port = "${port}", --host = "localhost", --host = '127.0.0.1', --port = 13000, -- 💀 Use the port printed out or specified with `--port` executable = { --command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb', command = os.getenv("HOME") .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", - args = { '--port', '${port}' }, + args = { "--port", "${port}" }, }, --detached = true, } dap.adapters.lldb = { - type = 'executable', - command = '/usr/bin/lldb-vscode', - name = "lldb" + type = "executable", + command = "/usr/bin/lldb-vscode", + name = "lldb", } dap.configurations.cpp = { { @@ -51,9 +51,9 @@ dap.configurations.cpp = { --type = "cppdbg", type = "codelldb", request = "launch", - cwd = '${workspaceFolder}', + cwd = "${workspaceFolder}", program = function() - return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") end, --program = '${file}', --program = function() @@ -122,16 +122,16 @@ dap.configurations.rust = dap.configurations.cpp --} dap.adapters.python = { - type = 'executable', - command = vim.trim(vim.fn.system('which python')), - args = { '-m', 'debugpy.adapter' }, + type = "executable", + command = vim.trim(vim.fn.system("which python")), + args = { "-m", "debugpy.adapter" }, } dap.configurations.python = { { -- The first three options are required by nvim-dap - type = 'python', -- the type here established the link to the adapter definition: `dap.adapters.python` - request = 'launch', + type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python` + request = "launch", name = "Launch file", -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options program = "${file}", -- This configuration will launch the current file if used. @@ -139,7 +139,7 @@ dap.configurations.python = { }, } -local dapui = require('dapui') +local dapui = require("dapui") --local dap_ui_status_ok, dapui = pcall(require, "dapui") --if not dap_ui_status_ok then -- return @@ -210,14 +210,13 @@ if not vim.g.loaded_dapui then vim.g.loaded_dapui = true end - -- Signs local sign = vim.fn.sign_define sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" }) sign("DapBreakpointCondition", { text = "◆", texthl = "DapBreakpointCondition", linehl = "", numhl = "" }) -- -sign("DapBreakpointRejected", { text = 'R', texthl = 'DiagnosticError', numhl = 'DiagnosticError' }) +sign("DapBreakpointRejected", { text = "R", texthl = "DiagnosticError", numhl = "DiagnosticError" }) sign("DapLogPoint", { text = "L", texthl = "DapLogPoint", linehl = "", numhl = "" }) -sign('DapStopped', { text = '', texthl = 'DiagnosticSignHint', numbhl = '', linehl = '' }) +sign("DapStopped", { text = "", texthl = "DiagnosticSignHint", numbhl = "", linehl = "" }) --sign('DapBreakpoint', { text = '', texthl = 'DiagnosticSignError', numbhl = '', linehl = '' }) --sign("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) @@ -238,7 +237,7 @@ dap.listeners.before.disconnect["dapui_config"] = function() dapui.close() end -require("nvim-dap-virtual-text").setup { +require("nvim-dap-virtual-text").setup({ enabled = true, enabled_commands = true, highlight_changed_variables = true, @@ -250,5 +249,5 @@ require("nvim-dap-virtual-text").setup { filter_references_pattern = " Date: Wed, 3 Apr 2024 23:28:35 +0200 Subject: File formatting, removed whitespace --- lua/user/pack.lua | 85 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 3af12f7..7ed86db 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -53,17 +53,17 @@ packer.init({ -- Install plugins here return packer.startup(function(use) -- Defaults - use("wbthomason/packer.nvim") -- Have packer manage itself (package manager) - use("nvim-lua/plenary.nvim") -- Useful lua functions used by lots of plugins + use("wbthomason/packer.nvim") -- Have packer manage itself (package manager) + use("nvim-lua/plenary.nvim") -- Useful lua functions used by lots of plugins use("lewis6991/impatient.nvim") -- Faster loading/startup times -- Tree-sitter use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) -- For language parsing, examples: highlighting, folding, jumping, refactoring... - use("nvim-treesitter/nvim-treesitter-refactor") -- Refactor module for nvim-treesitter + use("nvim-treesitter/nvim-treesitter-refactor") -- Refactor module for nvim-treesitter -- lsp - use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters - use("neovim/nvim-lspconfig") -- Collection of LSP configs + use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters + use("neovim/nvim-lspconfig") -- Collection of LSP configs use("williamboman/mason-lspconfig.nvim") -- Bridges mason.nvim with nvim-lspconfig to help use them together use({ "https://git.sr.ht/~whynothugo/lsp_lines.nvim", @@ -75,7 +75,7 @@ return packer.startup(function(use) -- Debugger use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim - use("rcarriga/nvim-dap-ui") -- UI for nvim-dap + use("rcarriga/nvim-dap-ui") -- UI for nvim-dap --use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} } use("theHamsta/nvim-dap-virtual-text") use("gabrielpoca/replacer.nvim") @@ -106,32 +106,32 @@ return packer.startup(function(use) }) -- Completion - use("hrsh7th/nvim-cmp") -- Completion engine plugin - use("hrsh7th/cmp-nvim-lsp") -- Completion source for nvim-lsp - use("hrsh7th/cmp-buffer") -- Completion source for content of current buffer - use("hrsh7th/cmp-path") -- Completion source for paths - use("hrsh7th/cmp-cmdline") -- Completion source for command-line - use("petertriho/cmp-git") -- Completion source for git - use("tamago324/cmp-zsh") -- Completion source for zsh - use("f3fora/cmp-spell") -- Completion source for spell-checking - use("hrsh7th/cmp-calc") -- Completion source for math calculation - use("saadparwaiz1/cmp_luasnip") -- Completion source for snippets, specifically for luasnip + use("hrsh7th/nvim-cmp") -- Completion engine plugin + use("hrsh7th/cmp-nvim-lsp") -- Completion source for nvim-lsp + use("hrsh7th/cmp-buffer") -- Completion source for content of current buffer + use("hrsh7th/cmp-path") -- Completion source for paths + use("hrsh7th/cmp-cmdline") -- Completion source for command-line + use("petertriho/cmp-git") -- Completion source for git + use("tamago324/cmp-zsh") -- Completion source for zsh + use("f3fora/cmp-spell") -- Completion source for spell-checking + use("hrsh7th/cmp-calc") -- Completion source for math calculation + use("saadparwaiz1/cmp_luasnip") -- Completion source for snippets, specifically for luasnip use("hrsh7th/cmp-nvim-lsp-signature-help") -- Completion source for displaying function signatures with the current parameter emphasized use("rcarriga/cmp-dap") -- Snippets - use("L3MON4D3/LuaSnip") -- Snippet engine + use("L3MON4D3/LuaSnip") -- Snippet engine use("rafamadriz/friendly-snippets") -- Collection of snippets to use -- Git - use("tpope/vim-fugitive") -- + use("tpope/vim-fugitive") -- --use("dinhhuy258/git.nvim") -- For git blame & browse - use("kdheepak/lazygit.nvim") -- Terminal UI for git commands + use("kdheepak/lazygit.nvim") -- Terminal UI for git commands use("lewis6991/gitsigns.nvim") -- Git decorations -- File explorer/fuzzy finder use("kyazdani42/nvim-tree.lua") -- File explorer - use("ibhagwan/fzf-lua") -- Fuzzy finder + use("ibhagwan/fzf-lua") -- Fuzzy finder use("ThePrimeagen/harpoon") --use("nvim-telescope/telescope.nvim") -- Fuzzy finder with lots of features/extendabilities use({ @@ -147,14 +147,14 @@ return packer.startup(function(use) { "nvim-telescope/telescope-fzf-native.nvim", run = "make" }, }, }) - use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm - use("nvim-telescope/telescope-ui-select.nvim") -- - use("nvim-telescope/telescope-project.nvim") -- - use("nvim-telescope/telescope-media-files.nvim") -- - use("nvim-telescope/telescope-file-browser.nvim") -- + use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm + use("nvim-telescope/telescope-ui-select.nvim") -- + use("nvim-telescope/telescope-project.nvim") -- + use("nvim-telescope/telescope-media-files.nvim") -- + use("nvim-telescope/telescope-file-browser.nvim") -- use({ "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" }) -- Search emoji(s) and other symbols use("nvim-telescope/telescope-dap.nvim") - use("axkirillov/telescope-changed-files") -- + use("axkirillov/telescope-changed-files") -- use("smartpde/telescope-recent-files") use("rmagatti/auto-session") use("rmagatti/session-lens") @@ -169,7 +169,7 @@ return packer.startup(function(use) }) use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete", "Mkdir" } }) -- Handy unix commands inside Vim (Rename, Move etc.) --use("tpope/vim-obsession") -- - use("tpope/vim-unimpaired") -- + use("tpope/vim-unimpaired") -- --use("tpope/vim-surround") -- use({ "kylechui/nvim-surround", @@ -182,9 +182,9 @@ return packer.startup(function(use) "myusuf3/numbers.vim", -- vim.cmd("let g:numbers_exclude = ['dashboard']"), }) - use("windwp/nvim-autopairs") -- - use("numToStr/Comment.nvim") -- - use("akinsho/toggleterm.nvim") -- + use("windwp/nvim-autopairs") -- + use("numToStr/Comment.nvim") -- + use("akinsho/toggleterm.nvim") -- use("tweekmonster/startuptime.vim") -- use("qpkorr/vim-bufkill") use({ @@ -202,9 +202,9 @@ return packer.startup(function(use) require("flit").setup() end, }) - use("folke/which-key.nvim") -- - use("folke/zen-mode.nvim") -- - use("romainl/vim-cool") -- + use("folke/which-key.nvim") -- + use("folke/zen-mode.nvim") -- + use("romainl/vim-cool") -- use("antoinemadec/FixCursorHold.nvim") -- use({ "folke/trouble.nvim", @@ -261,8 +261,8 @@ return packer.startup(function(use) use("ribru17/bamboo.nvim") -- UI - use("kyazdani42/nvim-web-devicons") -- - use("onsails/lspkind-nvim") -- + use("kyazdani42/nvim-web-devicons") -- + use("onsails/lspkind-nvim") -- use({ "kevinhwang91/nvim-ufo", requires = "kevinhwang91/promise-async" }) -- Fold code use("lukas-reineke/indent-blankline.nvim") use({ @@ -272,8 +272,8 @@ return packer.startup(function(use) require("statuscol").setup({ relculright = true, segments = { - { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, - { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, }, }) @@ -284,7 +284,7 @@ return packer.startup(function(use) --event = 'VimEnter', requires = { "nvim-tree/nvim-web-devicons" }, }) - use("rcarriga/nvim-notify") -- Notification plugin + use("rcarriga/nvim-notify") -- Notification plugin use("karb94/neoscroll.nvim") -- Faster/smooth scrolling --use("MunifTanjim/prettier.nvim") -- Prettier plugin for Neovim's built-in LSP client use({ @@ -332,11 +332,16 @@ return packer.startup(function(use) --requires = 'kyazdani42/nvim-web-devicons', --event = 'VimEnter', }) - + use({ + "samodostal/image.nvim", + config = function() + require("image").setup({}) + end, + }) -- Language specific tools use("simrat39/rust-tools.nvim") -- Rust tooling ecosystem use({ - "saecki/crates.nvim", -- + "saecki/crates.nvim", -- requires = { "nvim-lua/plenary.nvim" }, config = function() require("crates").setup() -- cgit v1.2.3