From bf691f8190f200f6ca509e23b9e46432e7eb24c8 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 24 Feb 2023 13:01:32 +0200 Subject: Install "wfxr/minimap.vim" --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 957fac8..f7222b5 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -156,6 +156,7 @@ return packer.startup(function(use) use("folke/which-key.nvim") -- use("folke/zen-mode.nvim") -- use("romainl/vim-cool") -- + use("wfxr/minimap.vim") use("antoinemadec/FixCursorHold.nvim") -- use({ "folke/trouble.nvim", -- cgit v1.2.3 From 0bfbf87f0fb45f6e929e3e7d4f39da091d6b0242 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 24 Feb 2023 13:01:47 +0200 Subject: Made mapping for MinimapToggle --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index c957e05..86b430e 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -309,3 +309,6 @@ end, { desc = "Toggle quickfix window" }) -- Dashboard map("n", "db", "Dashboard") + +-- Minimap +map("n", "mm", "MinimapToggle") -- cgit v1.2.3 From 5f06a5a25954e300bff5f7546abad9e00a876a68 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 24 Feb 2023 13:01:58 +0200 Subject: Source minimap.lua --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index c2dff0a..d0e6fad 100644 --- a/init.lua +++ b/init.lua @@ -78,6 +78,7 @@ local modules = { "plugins.heirline", "plugins.toggleterm", "plugins.trouble", + "plugins.minimap", --"plugins.modify-blend", --"plugins.dap", --"plugins.floatterm", -- cgit v1.2.3 From 957514d3fbbe2e1c36df506e69abe289553650e0 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 24 Feb 2023 13:02:09 +0200 Subject: Turned on async = true --- lua/plugins/null-ls.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index b96d883..640ae0e 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -6,13 +6,13 @@ require("null-ls").setup({ --debug = true, disabled_filetypes = { "PKGBUILD" }, timeout_ms = 5000, - --async = true, + async = true, debounce = 150, - log = { - enable = true, - level = 'warn', - use_console = 'async', - }, + --log = { + -- enable = true, + -- level = 'warn', + -- use_console = 'async', + --}, update_in_insert = false, --fallback_severity = vim.diagnostic.severity.ERROR, --log_level = "warn", -- cgit v1.2.3 From 39298e2ca705bbee51aab08d520e2f0ac3cf7dfb Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 24 Feb 2023 13:02:24 +0200 Subject: Add minimap configuration --- lua/plugins/minimap.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lua/plugins/minimap.lua diff --git a/lua/plugins/minimap.lua b/lua/plugins/minimap.lua new file mode 100644 index 0000000..d4114da --- /dev/null +++ b/lua/plugins/minimap.lua @@ -0,0 +1,11 @@ +vim.cmd([[ + let g:minimap_width = 30 + "let g:minimap_auto_start = 1 + "let g:minimap_auto_start_win_enter = 1 +]]) +vim.api.nvim_create_autocmd('QuitPre', { + pattern = '*', + desc = 'Close minimap on exit', + -- group = group, + command = 'MinimapClose', +}) -- cgit v1.2.3 From 872807ed448528b1aa74068c8fe40b334f4d5854 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 25 Feb 2023 15:24:19 +0200 Subject: Removed "wfxr/minimap.vim" --- lua/user/pack.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index f7222b5..957fac8 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -156,7 +156,6 @@ return packer.startup(function(use) use("folke/which-key.nvim") -- use("folke/zen-mode.nvim") -- use("romainl/vim-cool") -- - use("wfxr/minimap.vim") use("antoinemadec/FixCursorHold.nvim") -- use({ "folke/trouble.nvim", -- cgit v1.2.3 From 26befca140881c4eb12aa8daa4171c0b050df3e5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 25 Feb 2023 15:24:36 +0200 Subject: Removed minimap plugin --- init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/init.lua b/init.lua index d0e6fad..c2dff0a 100644 --- a/init.lua +++ b/init.lua @@ -78,7 +78,6 @@ local modules = { "plugins.heirline", "plugins.toggleterm", "plugins.trouble", - "plugins.minimap", --"plugins.modify-blend", --"plugins.dap", --"plugins.floatterm", -- cgit v1.2.3 From 2ff26b44aaf4f4e39676db11daac92cfd54a128f Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 25 Feb 2023 15:24:56 +0200 Subject: Removed minimap plugin/mapping --- lua/user/keys.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 86b430e..c957e05 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -309,6 +309,3 @@ end, { desc = "Toggle quickfix window" }) -- Dashboard map("n", "db", "Dashboard") - --- Minimap -map("n", "mm", "MinimapToggle") -- cgit v1.2.3 From a36202a16ed4069cb01f4e61f2ed6d9ddd553445 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 25 Feb 2023 15:25:09 +0200 Subject: Removed minimap plugin --- lua/plugins/minimap.lua | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 lua/plugins/minimap.lua diff --git a/lua/plugins/minimap.lua b/lua/plugins/minimap.lua deleted file mode 100644 index d4114da..0000000 --- a/lua/plugins/minimap.lua +++ /dev/null @@ -1,11 +0,0 @@ -vim.cmd([[ - let g:minimap_width = 30 - "let g:minimap_auto_start = 1 - "let g:minimap_auto_start_win_enter = 1 -]]) -vim.api.nvim_create_autocmd('QuitPre', { - pattern = '*', - desc = 'Close minimap on exit', - -- group = group, - command = 'MinimapClose', -}) -- cgit v1.2.3 From c448931832df372af9e00511405bb364b4f2480d Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 28 Feb 2023 09:45:05 +0200 Subject: Add new file (Text) option --- lua/plugins/dashboard.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index dd50c65..f78a8b8 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -28,14 +28,20 @@ db.setup({ key = "f", }, { - desc = " Text", - group = "DiagnosticHint", - action = "Telescope live_grep", + desc = " Text", + group = "Label", + action = 'enew', key = "t", }, + { + desc = " Grep", + group = "Label", + action = "Telescope live_grep", + key = "g", + }, { desc = " Scheme", - group = "Number", + group = "Label", action = "Telescope colorscheme", key = "s", }, -- cgit v1.2.3 From 154e1d827b81669be3a803b7009f58b03d81bd27 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 28 Feb 2023 09:45:26 +0200 Subject: Add Config option --- lua/plugins/dashboard.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index f78a8b8..9ac48a3 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -45,6 +45,12 @@ db.setup({ action = "Telescope colorscheme", key = "s", }, + { + desc = ' Config', + group = "Number", + action = ':edit ~/.config.nvim/init.lua', + key = "c", + }, }, }, hide = { -- cgit v1.2.3 From fe63dd23c59b268b58f1fe335645032a398d891b Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 1 Mar 2023 07:45:13 +0200 Subject: Changed color of shortcuts --- lua/plugins/dashboard.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lua/plugins/dashboard.lua b/lua/plugins/dashboard.lua index 9ac48a3..c6c610d 100644 --- a/lua/plugins/dashboard.lua +++ b/lua/plugins/dashboard.lua @@ -20,34 +20,40 @@ db.setup({ }, disable_move = false, shortcut = { - { desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, + { desc = " Plugins", group = "Number", action = "PackerStatus", key = "p" }, + --{ desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, { desc = " Files", - group = "Label", + group = "Number", + --group = "Label", action = "Telescope find_files", key = "f", }, { desc = " Text", - group = "Label", + group = "Number", + --group = "Label", action = 'enew', key = "t", }, { desc = " Grep", - group = "Label", + group = "Number", + --group = "Label", action = "Telescope live_grep", key = "g", }, { desc = " Scheme", - group = "Label", + group = "Number", + --group = "Label", action = "Telescope colorscheme", key = "s", }, { desc = ' Config', group = "Number", + --group = "Label", action = ':edit ~/.config.nvim/init.lua', key = "c", }, -- cgit v1.2.3 From 4de8a5c8b8c6d677a4bdc306e408b425ce43af5d Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 07:09:00 +0200 Subject: Replaced "jayp0521/mason-null-ls.nvim" with "jay-bau/mason-null-ls.nvim" --- lua/user/pack.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 957fac8..dc500d5 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -72,7 +72,7 @@ return packer.startup(function(use) use("gabrielpoca/replacer.nvim") -- Linters/Formatters - use("jayp0521/mason-null-ls.nvim") + use("jay-babu/mason-null-ls.nvim") --use({"jayp0521/mason-null-ls.nvim", -- config = function() -- require('mason-null-ls.nvim').setup({ @@ -82,7 +82,7 @@ return packer.startup(function(use) --}) use({ "jose-elias-alvarez/null-ls.nvim", -- Provides LSP: linters, formatters, diagnostics, code actions and etc... - requires = { "jayp0521/mason-null-ls.nvim" }, + requires = { "jay-babu/mason-null-ls.nvim" }, }) -- Completion @@ -208,10 +208,10 @@ return packer.startup(function(use) use({ "kosayoda/nvim-lightbulb", -- requires = "antoinemadec/FixCursorHold.nvim", }) - use({ + use({ "SmiteshP/nvim-navic", -- Statusline/Winbar component that uses LSP to show current code context - requires = "neovim/nvim-lspconfig", - }) + requires = "neovim/nvim-lspconfig" + }) use({ 'rebelot/heirline.nvim', -- Statusline that is highly configurable requires = 'kyazdani42/nvim-web-devicons', -- cgit v1.2.3 From 7197d1ff801e8137defe5194a30478dc943b6cd8 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 07:10:01 +0200 Subject: Installed 'ThePrimeagen/harpoon' --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index dc500d5..a543419 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -111,6 +111,7 @@ return packer.startup(function(use) -- File explorer/fuzzy finder 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-fzf-native.nvim", run = "make" }) -- Support fzf syntax/algorithm use("nvim-telescope/telescope-ui-select.nvim") -- -- cgit v1.2.3 From 888892c7a52e557dcc69d73c7cf83dd2b665bea5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 07:12:19 +0200 Subject: Installed colorscheme "IneptusMechanicus/mechanicus.nvim" --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index a543419..53162e6 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -178,6 +178,7 @@ return packer.startup(function(use) use("ayu-theme/ayu-vim") use("joshdick/onedark.vim") use("NTBBloodbath/doom-one.nvim") + use("IneptusMechanicus/mechanicus.nvim") -- UI use("kyazdani42/nvim-web-devicons") -- -- cgit v1.2.3 From 24dd9379de690edba46dfe469cc41de7ca2630fc Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 07:45:42 +0200 Subject: Add .bashrc to function M.find_configs() --- lua/plugins/telescope.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 6cd41ae..28e0619 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -281,6 +281,7 @@ function M.find_configs() "~/.config/bspwm", "~/.config/sxhkd", "~/.config/picom", + "~/.bashrc", }, -- cwd = "~/.config/nvim/", file_ignore_patterns = { -- cgit v1.2.3 From fcc4a111f55e6ee14cd0b4e25fd8f851172f96b9 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 14:01:43 +0200 Subject: Fixed null-ls from non-stop updating --- lua/plugins/null-ls.lua | 250 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 167 insertions(+), 83 deletions(-) diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index 640ae0e..06dd45b 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -2,89 +2,173 @@ -- -- null-language-server i.e. a sort of language server which does not provide any services such as formatting and diagnostics you expect from a language server. Instead it will need to install corresponding external “sources” and then hook these sources into the neovim lsp client through null-ls. -- -require("null-ls").setup({ - --debug = true, - disabled_filetypes = { "PKGBUILD" }, - timeout_ms = 5000, - async = true, - debounce = 150, - --log = { - -- enable = true, - -- level = 'warn', - -- use_console = 'async', - --}, - update_in_insert = false, - --fallback_severity = vim.diagnostic.severity.ERROR, - --log_level = "warn", - --on_attach = nil, - --on_init = nil, - --on_exit = nil, - sources = { - --require("null-ls").builtins.formatting.shfmt, -- shell script formatting - require("null-ls").builtins.diagnostics.dotenv_linter, - --require("null-ls").builtins.diagnostics.editorconfig_checker, - require("null-ls").builtins.formatting.shfmt.with({ - filetypes = { "bash", "zsh", "sh" }, - extra_args = { "-i", "2", "-ci" }, - }), - require("null-ls").builtins.formatting.prettier, -- markdown formatting - --require("null-ls").builtins.diagnostics.shellcheck, -- shell script diagnostics - require("null-ls").builtins.diagnostics.shellcheck.with({ - diagnostic_config = { - -- see :help vim.diagnostic.config() - underline = true, - virtual_text = false, - signs = true, - update_in_insert = false, - severity_sort = true, - }, - diagnostics_format = "[#{c}] #{m} (#{s})", - -- this will run every time the source runs, - -- so you should prefer caching results if possible - }), --- require("null-ls").builtins.formatting.stylua, -- lua formatting --- require("null-ls").builtins.formatting.prettier.with({ -- markdown, html/js formatting --- filetypes = { "html", "css", "javascript", "javascriptreact", "markdown", "json", "yaml" }, --- }), --- require("null-ls").builtins.formatting.black, --- require("null-ls").builtins.formatting.prettierd, --- require("null-ls").builtins.diagnostics.cspell.with { --- filetypes = { "python", "rust", "typescript" }, --- }, --- --require("null-ls").builtins.diagnostics.luacheck, --- --require("null-ls").builtins.diagnostics.eslint, --- --require("null-ls").builtins.diagnostics.eslint_d, --- require("null-ls").builtins.diagnostics.mdl, --- require("null-ls").builtins.diagnostics.vint, --- require("null-ls").builtins.completion.spell, +local null_ls = require "null-ls" +local builtins = null_ls.builtins + +local eslint_opts = { + -- condition = function(utils) + -- return utils.root_has_file ".eslintrc.js" or utils.root_has_file ".eslintrc" or utils.root_has_file ".eslintrc.json" + -- end, + -- diagnostics_format = "#{m} [#{c}]", + prefer_local = true, +} + +local sources = { + builtins.formatting.stylua, + 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.clang_format, + builtins.formatting.rustfmt, + builtins.formatting.sql_formatter, + builtins.formatting.prettierd.with { + filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", "css", "scss", "less", "graphql", "vue", "svelte" }, + condition = function(utils) + return utils.root_has_file ".prettierrc" or utils.root_has_file ".prettierrc.js" or utils.root_has_file ".prettierrc.json" or utils.root_has_file "prettier.config.js" or utils.root_has_file "prettier.config.cjs" + end, + }, + + builtins.diagnostics.dotenv_linter, + builtins.diagnostics.shellcheck.with({ -- shell script diagnostics + diagnostic_config = { + -- see :help vim.diagnostic.config() + underline = true, + virtual_text = false, + signs = true, + update_in_insert = false, + severity_sort = true, + }, + diagnostics_format = "[#{c}] #{m} (#{s})", + -- this will run every time the source runs, + -- so you should prefer caching results if possible + }), + builtins.diagnostics.eslint_d.with(eslint_opts), + builtins.diagnostics.todo_comments, + + builtins.code_actions.shellcheck, -- shell script code actions + builtins.code_actions.eslint_d.with(eslint_opts), + builtins.code_actions.gitsigns, + builtins.code_actions.gitrebase, + builtins.hover.dictionary, + builtins.hover.printenv, +} + +local M = {} + +M.setup = function(on_attach) + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + + null_ls.setup { + sources = sources, + debug = false, + on_attach = function(client, bufnr) + on_attach(client, bufnr) + -- Format on save + -- vim.cmd [[autocmd BufWritePost lua vim.lsp.buf.formatting()]] + + -- if client.supports_method "textDocument/formatting" then + -- vim.api.nvim_clear_autocmds { group = augroup, buffer = bufnr } + -- vim.api.nvim_create_autocmd("BufWritePre", { + -- group = augroup, + -- buffer = bufnr, + -- callback = function() + -- -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead + -- vim.lsp.buf.format { bufnr = bufnr } + -- end, + -- }) + -- end + end, + } +end + +return M + +--require("null-ls").setup({ +-- --debug = true, +-- disabled_filetypes = { "PKGBUILD" }, +-- timeout_ms = 5000, +-- async = true, +-- debounce = 150, +-- --log = { +-- -- enable = true, +-- -- level = 'warn', +-- -- use_console = 'async', +-- --}, +-- update_in_insert = false, +-- --fallback_severity = vim.diagnostic.severity.ERROR, +-- --log_level = "warn", +-- --on_attach = nil, +-- --on_init = nil, +-- --on_exit = nil, +-- sources = { +-- --require("null-ls").builtins.formatting.shfmt, -- shell script formatting +-- require("null-ls").builtins.diagnostics.dotenv_linter, +-- --require("null-ls").builtins.diagnostics.editorconfig_checker, +-- require("null-ls").builtins.formatting.shfmt.with({ +-- filetypes = { "bash", "zsh", "sh" }, +-- extra_args = { "-i", "2", "-ci" }, +-- }), +-- require("null-ls").builtins.formatting.prettier, -- markdown formatting +-- --require("null-ls").builtins.diagnostics.shellcheck, -- shell script diagnostics +-- require("null-ls").builtins.diagnostics.shellcheck.with({ +-- diagnostic_config = { +-- -- see :help vim.diagnostic.config() +-- underline = true, +-- virtual_text = false, +-- signs = true, +-- update_in_insert = false, +-- severity_sort = true, +-- }, +-- diagnostics_format = "[#{c}] #{m} (#{s})", +-- -- this will run every time the source runs, +-- -- so you should prefer caching results if possible +-- }), +---- require("null-ls").builtins.formatting.stylua, -- lua formatting +---- require("null-ls").builtins.formatting.prettier.with({ -- markdown, html/js formatting +---- filetypes = { "html", "css", "javascript", "javascriptreact", "markdown", "json", "yaml" }, +---- }), +---- require("null-ls").builtins.formatting.black, +---- require("null-ls").builtins.formatting.prettierd, +---- require("null-ls").builtins.diagnostics.cspell.with { +---- filetypes = { "python", "rust", "typescript" }, +---- }, +---- --require("null-ls").builtins.diagnostics.luacheck, +---- --require("null-ls").builtins.diagnostics.eslint, +---- --require("null-ls").builtins.diagnostics.eslint_d, +---- require("null-ls").builtins.diagnostics.mdl, +---- require("null-ls").builtins.diagnostics.vint, +---- require("null-ls").builtins.completion.spell, +---- require("null-ls").builtins.formatting.clang_format, +---- require("null-ls").builtins.formatting.rustfmt, +---- require("null-ls").builtins.formatting.sql_formatter, +---- --require("null-ls").builtins.formatting.google_java_format, +---- require("null-ls").builtins.diagnostics.cppcheck, +-- require("null-ls").builtins.formatting.shellharden, +---- --require("null-ls").builtins.code_actions.eslint_d, +-- require("null-ls").builtins.code_actions.shellcheck, -- shell script code actions -- require("null-ls").builtins.formatting.clang_format, -- require("null-ls").builtins.formatting.rustfmt, +-- --require("null-ls").builtins.formatting.beautysh, -- require("null-ls").builtins.formatting.sql_formatter, --- --require("null-ls").builtins.formatting.google_java_format, --- require("null-ls").builtins.diagnostics.cppcheck, - require("null-ls").builtins.formatting.shellharden, --- --require("null-ls").builtins.code_actions.eslint_d, - require("null-ls").builtins.code_actions.shellcheck, -- shell script code actions - require("null-ls").builtins.formatting.clang_format, - require("null-ls").builtins.formatting.rustfmt, - --require("null-ls").builtins.formatting.beautysh, - require("null-ls").builtins.formatting.sql_formatter, - require("null-ls").builtins.diagnostics.todo_comments, - --require("null-ls").builtins.diagnostics.zsh, - require("null-ls").builtins.hover.dictionary, - require("null-ls").builtins.hover.printenv, - }, - -- default_timeout = 5000, - -- diagnostics_format = '[#{c}] #{m} (#{s})', - -- fallback_severity = vim.diagnostic.severity.ERROR, - -- log = { - -- enable = true, - -- level = 'warn', - -- use_console = 'async', - -- }, - --on_attach = nil, - --on_init = nil, - --on_exit = nil, - --update_in_insert = false, - --update_in_leave = false, -}) +-- require("null-ls").builtins.diagnostics.todo_comments, +-- --require("null-ls").builtins.diagnostics.zsh, +-- require("null-ls").builtins.hover.dictionary, +-- require("null-ls").builtins.hover.printenv, +-- }, +-- -- default_timeout = 5000, +-- -- diagnostics_format = '[#{c}] #{m} (#{s})', +-- -- fallback_severity = vim.diagnostic.severity.ERROR, +-- -- log = { +-- -- enable = true, +-- -- level = 'warn', +-- -- use_console = 'async', +-- -- }, +-- --on_attach = nil, +-- --on_init = nil, +-- --on_exit = nil, +-- --update_in_insert = false, +-- --update_in_leave = false, +--}) -- cgit v1.2.3 From c6ccab7f680f4a873d996cd9e535752e9a82c8ac Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 14:46:23 +0200 Subject: Re-enabled auto command to return to same line when reopening --- lua/user/opts.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index c1b5027..2bbf776 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -248,12 +248,12 @@ vim.cmd([[ " Only show in insert mode ]]) -- Line Return ---vim.cmd([[ " Return to the same line when we reopen a file --- augroup line_return --- au! --- au BufReadPost * --- \ if line("'\"") > 0 && line("'\"") <= line("$") | --- \ execute 'normal! g`"zvzz' | --- \ endif --- augroup END ---]]) +vim.cmd([[ " Return to the same line when we reopen a file + augroup line_return + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif + augroup END +]]) -- cgit v1.2.3 From 05a9818bfbeb5ed10486d0a7c832a3155bb449a5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 14:55:10 +0200 Subject: Clean config --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index c2dff0a..14ba5e6 100644 --- a/init.lua +++ b/init.lua @@ -26,10 +26,10 @@ -- -------------------------------------------------------------------------- -- --- Initialize config with this one liner in the terminal (use in commandline) +-- Initialize config with this one liner in the terminal --nvim --headless -c 'call mkdir(stdpath("config"), "p") | exe "edit" stdpath("config") . "/init.lua" | write | quit' --- See startup time (use in commandline) +-- Command to see startup time --nvim --startuptime startup.log -c exit && tail -100 startup.log -- Load impatient (Faster loading times) -- cgit v1.2.3 From cce36b1fc55f03874f31ebe860f1e2042fa055ef Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 14:55:34 +0200 Subject: Buffer close confirm set to false --- lua/user/opts.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 2bbf776..1e60795 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -154,7 +154,7 @@ vim.opt.wrapscan = true -- " Searches wrap around end-of-file. --vim.opt.foldmethod = "expr" -- vim.opt.foldmethod = "manual" vim.opt.foldlevel = 3 -vim.opt.confirm = true +vim.opt.confirm = false vim.opt.shortmess:append("sI") --vim.opt.shortmess = "a" --vim.opt.shortmess = "sI" -- cgit v1.2.3 From 4cbb1cc38084300469b2dd01fc01e369babfbb31 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 15:35:28 +0200 Subject: Made focusable = true for diagnostic.open_float --- lua/plugins/lsp.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 7962308..b1a4635 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -60,8 +60,8 @@ local on_attach = function(client, bufnr) map("n", "gn", "lua vim.lsp.buf.rename()") map("n", "ga", "lua vim.lsp.buf.code_action()") map("n", "gf", "lua vim.lsp.buf.formatting()") - --map("n", "go", "lua vim.diagnostic.open_float()") - map("n", "go", ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") + map("n", "go", "lua vim.diagnostic.open_float()") + map("n", "go", ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") 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()") @@ -301,7 +301,7 @@ vim.diagnostic.config({ show_header = true, source = 'if_many', border = 'rounded', - focusable = false, + focusable = true, }, update_in_insert = false, -- default to false severity_sort = false, -- default to false -- cgit v1.2.3 From 50d0c70863f61eb5f5e2387a43cc2a8971468c2f Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 15:35:56 +0200 Subject: Add diagnostics for vimscript (vint) --- lua/plugins/null-ls.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index 06dd45b..8e7ddd7 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -47,6 +47,7 @@ local sources = { }), builtins.diagnostics.eslint_d.with(eslint_opts), builtins.diagnostics.todo_comments, + builtins.diagnostics.vint, builtins.code_actions.shellcheck, -- shell script code actions builtins.code_actions.eslint_d.with(eslint_opts), -- cgit v1.2.3 From d3db66035ac76623ccf525640cdac22fedce57ab Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 3 Mar 2023 15:36:59 +0200 Subject: Use q to quit on floating windows otherwise still use it for macros (conditional) --- lua/user/keys.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index c957e05..f2ce98d 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -29,6 +29,16 @@ map("n", "", "luafile ~/.config/nvim/init.lua | :echom ('Nv --------------- Extended Operations --------------- +-- Use q to quit on floating windows otherwise still use it for macros +map('n', 'q', function() + local config = vim.api.nvim_win_get_config(0) + if config.relative ~= "" then -- is_floating_window? + return ":close" + else + return "q" + end +end, {expr = true, replace_keycodes = true}) + -- Combine buffers list with buffer name map("n", "b", ":buffers:buffer") -- cgit v1.2.3 From a1bac9ceb9630ba86dca8f84921fd391ecd3d7c8 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 07:37:12 +0200 Subject: Removed colorsheme "IneptusMechanicus/mechanicus" --- lua/user/pack.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 53162e6..a543419 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -178,7 +178,6 @@ return packer.startup(function(use) use("ayu-theme/ayu-vim") use("joshdick/onedark.vim") use("NTBBloodbath/doom-one.nvim") - use("IneptusMechanicus/mechanicus.nvim") -- UI use("kyazdani42/nvim-web-devicons") -- -- cgit v1.2.3 From d228af7c82c755c63ac392d469d768e64d7fd9bd Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 07:44:30 +0200 Subject: Add quickfix to conditional mapping for 'q' --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index f2ce98d..9999138 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -34,6 +34,9 @@ map('n', 'q', function() local config = vim.api.nvim_win_get_config(0) if config.relative ~= "" then -- is_floating_window? return ":close" + elseif + vim.o.buftype == 'quickfix' then + return ":close" else return "q" end -- cgit v1.2.3 From 221fe79747bc9e2ffb9e2019d72b822eec2577dd Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 07:46:28 +0200 Subject: Add help to conditional 'q' mapping --- lua/user/keys.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 9999138..e918594 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -37,6 +37,9 @@ map('n', 'q', function() elseif vim.o.buftype == 'quickfix' then return ":close" + elseif + vim.o.buftype == 'help' then + return ":close" else return "q" end -- cgit v1.2.3 From 2e31d4001428c9a672abfca01b44c0584b10803b Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 08:14:00 +0200 Subject: Add mapping to toggle plugin "lsp_lines" --- lua/user/keys.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index e918594..55b7f01 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -325,3 +325,7 @@ end, { desc = "Toggle quickfix window" }) -- Dashboard map("n", "db", "Dashboard") + +-- +map("", "l", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) + -- cgit v1.2.3 From 54791ebf276f93ae27dc0b39261dacc69dfb1c72 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 08:44:10 +0200 Subject: Add "https://git.sr.ht/~whynothugo/lsp_lines.nvim" --- lua/user/pack.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index a543419..0fa3a69 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -65,6 +65,12 @@ return packer.startup(function(use) use("williamboman/mason.nvim") -- Package manager to install and manage LSP servers, DAP servers, linters and formatters use("williamboman/mason-lspconfig.nvim") -- Bridges mason.nvim with nvim-lspconfig to help use them together use("neovim/nvim-lspconfig") -- Collection of LSP configs + use({ + "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + config = function() + require("lsp_lines").setup() + end, + }) -- Debugger use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim -- cgit v1.2.3 From 22bf56135ec434fd6bfcac1a1ce76a98ae462a71 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 08:48:13 +0200 Subject: Add "rmagatti/goto-preview" --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 0fa3a69..0bcb006 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -71,6 +71,7 @@ return packer.startup(function(use) require("lsp_lines").setup() end, }) + use("rmagatti/goto-preview") -- Debugger use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim -- cgit v1.2.3 From 35dcc1b1cc3bb633007d771f5afcf040796c2f7e Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 10:36:42 +0200 Subject: Fixed spelling @ enable_moveright --- lua/plugins/autopairs.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua index fc39d2e..90c6d35 100644 --- a/lua/plugins/autopairs.lua +++ b/lua/plugins/autopairs.lua @@ -1,4 +1,3 @@ --- Setup nvim-cmp. local status_ok, npairs = pcall(require, "nvim-autopairs") if not status_ok then return @@ -18,9 +17,9 @@ npairs.setup { disable_filetype = { "TelescopePrompt", "spectre_panel" }, disable_in_macro = true, disable_in_visualblock = true, - enalbe_moveright = true, + enable_moveright = true, enable_afterquote = true, -- add bracket pairs after quote - enable_check_bracket_line = true, --- check bracket in same line + 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 = { -- cgit v1.2.3 From 55e0e7187b4bbc4775c7e314cbb214be9b8f0560 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 10:38:31 +0200 Subject: Fixed error messages on leaving floating windows on conditional 'q' mapping by using silent command --- lua/user/keys.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 55b7f01..02b466d 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -33,10 +33,10 @@ map("n", "", "luafile ~/.config/nvim/init.lua | :echom ('Nv map('n', 'q', function() local config = vim.api.nvim_win_get_config(0) if config.relative ~= "" then -- is_floating_window? - return ":close" + return ":silent! close!" elseif vim.o.buftype == 'quickfix' then - return ":close" + return ":quit" elseif vim.o.buftype == 'help' then return ":close" -- cgit v1.2.3 From a810d4eefeb3661e309147c34aa716a3905de384 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 4 Mar 2023 11:24:44 +0200 Subject: Add tmp folder to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 308d183..e890cff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ plugin/packer_compiled.lua startup.log +tmp -- cgit v1.2.3 From 30a76694d898a9b99dc06c5ff74ad43b9d9bea3b Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 5 Mar 2023 23:52:20 +0200 Subject: Disabled backup and undofile --- lua/user/opts.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 1e60795..65eaa23 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -43,7 +43,7 @@ vim.g.python3_host_prog = "/usr/bin/python3" -- vim.g.loaded_python3_provider = 1 -- vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file vim.o.autochdir = true ---vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals" -- +--vim.o.writeany= true -- Colors vim.opt.termguicolors = true @@ -122,11 +122,14 @@ vim.opt.report = 0 -- Always report changed lines. ---- it'll get replaced by the default stline). --vim.opt.stl = " " --- Backup/undo +-- Backup/undo/swap +local prefix = vim.env.XDG_CONFIG_HOME or vim.fn.expand("~/.config") +vim.opt.undodir = { prefix .. "/nvim/tmp/.undo//" } +vim.opt.backupdir = { prefix .. "/nvim/tmp/.backup//" } +vim.opt.directory = { prefix .. "/nvim/tmp/.swp//" } vim.opt.backup = false -- ---vim.opt.noswapfile = true -- ---vim.opt.undofile = true -- -vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" } -- +vim.opt.undofile = false -- +vim.opt.swapfile = true -- -- Format --vim.opt.textwidth = 80 -- @@ -225,8 +228,12 @@ vim.opt.wildignore:append({ "*/node_modules/*" }) -- vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" -- Sessions -vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" +--vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" +--vim.opt.sessionoptions = "curdir,folds,help,options,tabpages,winsize,winpos,terminal,globals" -- +--vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" +vim.opt.sessionoptions:remove({ "blank", "buffers", "globals" }) +vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup -- Cursorline vim.cmd([[ " Only show cursorline in the current window and in normal mode augroup cline -- cgit v1.2.3 From 1dfe25c30dda2910f1cd1d43f4c97e6224cbf433 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 5 Mar 2023 23:52:57 +0200 Subject: autocommand to add timestamp to backup files --- lua/user/opts.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 65eaa23..26dc60d 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -130,6 +130,15 @@ vim.opt.directory = { prefix .. "/nvim/tmp/.swp//" } vim.opt.backup = false -- vim.opt.undofile = false -- vim.opt.swapfile = true -- +-- Add timestamp as extension for backup files +vim.api.nvim_create_autocmd('BufWritePre', { + group = vim.api.nvim_create_augroup('timestamp_backupext', { clear = true }), + desc = 'Add timestamp to backup extension', + pattern = '*', + callback = function() + vim.opt.backupext = '-' .. vim.fn.strftime('%Y%m%d%H%M') + end, +}) -- Format --vim.opt.textwidth = 80 -- -- cgit v1.2.3 From 34ab0dc6afd8f5082920e494f6503e0c743244ae Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 5 Mar 2023 23:53:59 +0200 Subject: Mapping for messages and clear messages --- lua/user/keys.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 02b466d..40c75d1 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -59,6 +59,17 @@ map("n", "d", ":bd") -- List marks map("n", "m", ":marks") +-- Messages +map("n", "M", ":messages") + +-- Clear messages + +-- Clear messages or just refresh/redraw the screen +map("n", "u", ":echo '' | redraw") + +-- Unsets the 'last search pattern' register by hitting return +--map("n", "", "!silent :noh") + -- Toggle set number map("n", "$", ":NumbersToggle") map("n", "%", ":NumbersOnOff") @@ -157,18 +168,12 @@ map("v", "p", '"_dP') -- visual mode to select text to swap with map("v", "", "`.``gvP``P") --- Clear messages or just refresh/redraw the screen -map("n", "u", ":echo '' | redraw") - -- Change Working Directory to current project 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 %') --- Unsets the 'last search pattern' register by hitting return ---map("n", "", "!silent :noh") - -- Toggle completion map("n", "tc", ":lua require('user.mods').toggle_completion()") -- cgit v1.2.3 From 7831db235aff252d2912e9cc67cab16bda6f0489 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 5 Mar 2023 23:54:26 +0200 Subject: Mapping to diff files --- lua/user/keys.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 40c75d1..db4fac2 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -152,6 +152,23 @@ map("n", "", ':let save_a=@a"add"ap:let @a=save_a') -- Search and replace map("v", "sr", 'y:%s/"//gc') +vim.cmd([[ +let g:diff_is_open = 0 + +function! ToggleDiff() + if g:diff_is_open + windo diffoff + let g:diff_is_open = 0 + else + windo diffthis + let g:diff_is_open = 1 + endif +endfunction + +" Diff this +nnoremap dt call ToggleDiff() +]]) + -- Map delete to Ctrl+l map("i", "", "") -- cgit v1.2.3 From 3ee4d4f0b0f89abcbbe68113fa2a16fe3311ea62 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 5 Mar 2023 23:54:46 +0200 Subject: Add goto-preview mappings --- lua/plugins/lsp.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index b1a4635..855818f 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -48,15 +48,18 @@ local on_attach = function(client, bufnr) opts.buffer = bufnr keymap.set(mode, l, r, opts) end - -- Mappings map("n", "K", "lua vim.lsp.buf.hover()") - map("n", "gd", "lua vim.lsp.buf.definition()") - map("n", "gi", "lua vim.lsp.buf.implementation()") - map("n", "gr", "lua vim.lsp.buf.references()") + --map("n", "gd", "lua vim.lsp.buf.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", "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", "gt", "lua vim.lsp.buf.type_definition()") + --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.formatting()") @@ -297,6 +300,7 @@ vim.diagnostic.config({ underline = false, signs = true, virtual_text = false, + virtual_lines = { only_current_line = true }, float = { show_header = true, source = 'if_many', -- cgit v1.2.3 From bc022c0180fc07fd619e472440049a6f8ed97974 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 5 Mar 2023 23:54:59 +0200 Subject: Add goto-preview plugin --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 14ba5e6..ec29d65 100644 --- a/init.lua +++ b/init.lua @@ -68,6 +68,7 @@ local modules = { "plugins.neoscroll", "plugins.null-ls", "plugins.lsp", + "plugins.goto-preview", "plugins.autopairs", "plugins.web-devicons", "plugins.navic", -- cgit v1.2.3 From d086e37f2b805938f4c8803dc9d9a9d09920038c Mon Sep 17 00:00:00 2001 From: srdusr Date: Sun, 5 Mar 2023 23:55:14 +0200 Subject: Add goto-preview setup --- lua/plugins/goto-preview.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lua/plugins/goto-preview.lua diff --git a/lua/plugins/goto-preview.lua b/lua/plugins/goto-preview.lua new file mode 100644 index 0000000..d4d2c67 --- /dev/null +++ b/lua/plugins/goto-preview.lua @@ -0,0 +1,18 @@ +require('goto-preview').setup { + width = 120; -- Width of the floating window + height = 15; -- Height of the floating window + border = {"↖", "─" ,"┐", "│", "┘", "─", "└", "│"}; -- Border characters of the floating window + default_mappings = false; -- Bind default mappings + debug = false; -- Print debug information + opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false; -- Binds arrow keys to resizing the floating window. + post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + references = { -- Configure the telescope UI for slowing the references cycling window. + telescope = require("telescope.themes").get_dropdown({ hide_preview = false }) + }; + -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. + focus_on_open = true; -- Focus the floating window when opening it. + dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. + force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden +} -- cgit v1.2.3 From e1644d31eb87ae13674c227f5c29d2f4ad54cc3d Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 6 Mar 2023 21:08:28 +0200 Subject: Add no_ignore = true option to M.find_scripts --- lua/plugins/telescope.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 28e0619..f02b711 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -301,6 +301,7 @@ end function M.find_scripts() require("telescope.builtin").find_files { hidden = true, + no_ignore = true, prompt_title = " Find Notes", path_display = { "smart" }, search_dirs = { -- cgit v1.2.3 From d521aeba59dd4dc19acb3598df0cc42ae8307586 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 6 Mar 2023 21:09:11 +0200 Subject: Changed prompt_title to Find Scripts --- lua/plugins/telescope.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index f02b711..95a5dd6 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -302,7 +302,7 @@ function M.find_scripts() require("telescope.builtin").find_files { hidden = true, no_ignore = true, - prompt_title = " Find Notes", + prompt_title = " Find Scripts", path_display = { "smart" }, search_dirs = { "~/.local/bin/scripts", -- cgit v1.2.3 From 703f8d230992c1d06e35d57c06cfba575394ca60 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 6 Mar 2023 21:15:56 +0200 Subject: Clean config by moving Toggle Diff function to utils.vim --- lua/user/keys.lua | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index db4fac2..7e2c2c3 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -152,22 +152,8 @@ map("n", "", ':let save_a=@a"add"ap:let @a=save_a') -- Search and replace map("v", "sr", 'y:%s/"//gc') -vim.cmd([[ -let g:diff_is_open = 0 - -function! ToggleDiff() - if g:diff_is_open - windo diffoff - let g:diff_is_open = 0 - else - windo diffthis - let g:diff_is_open = 1 - endif -endfunction - -" Diff this -nnoremap dt call ToggleDiff() -]]) +-- Toggle Diff +map("n", "dt", "call utils#ToggleDiff()") -- Map delete to Ctrl+l map("i", "", "") -- cgit v1.2.3 From e30014d22bf8bf29a5d7a23bbdde407e9dc876c3 Mon Sep 17 00:00:00 2001 From: srdusr Date: Mon, 6 Mar 2023 21:18:36 +0200 Subject: Better description on Conditional q mapping --- lua/user/keys.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 7e2c2c3..689ff13 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -29,7 +29,7 @@ map("n", "", "luafile ~/.config/nvim/init.lua | :echom ('Nv --------------- Extended Operations --------------- --- Use q to quit on floating windows otherwise still use it for macros +-- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros map('n', 'q', function() local config = vim.api.nvim_win_get_config(0) if config.relative ~= "" then -- is_floating_window? -- cgit v1.2.3 From 8bd00156cc6c19b312ce282b478f3240305ff580 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 7 Mar 2023 14:19:48 +0200 Subject: Allowed changing cwd if on new repo --- keys.lua | 348 +++++++++++++++++++++++++++++++++++++++++++++ lua/plugins/toggleterm.lua | 37 ++++- 2 files changed, 383 insertions(+), 2 deletions(-) create mode 100644 keys.lua diff --git a/keys.lua b/keys.lua new file mode 100644 index 0000000..72ca59f --- /dev/null +++ b/keys.lua @@ -0,0 +1,348 @@ +--[[ key.lua ]] + +------------- Shorten Function Names -------------- +local keymap = vim.keymap +local map = function(mode, l, r, opts) + opts = opts or {} + opts.silent = true + opts.noremap = true + keymap.set(mode, l, r, opts) +end +local term_opts = { noremap = true, silent = false } + + +--------------- Standard Operations --------------- +-- Semi-colon as leader key +vim.g.mapleader = ";" + +-- Jump to next match on line using `.` instead of `;` NOTE: commented out in favour of "ggandor/flit.nvim" +--map("n", ".", ";") + +-- Repeat last command using `` instead of `.` NOTE: commented out in favour of "ggandor/flit.nvim" +--map("n", "", ".") + +-- "jj" to exit insert-mode +map("i", "jj", "") + +-- Reload nvim config +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 +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" + else + return "q" + end +end, {expr = true, replace_keycodes = true}) + +-- Combine buffers list with buffer name +map("n", "b", ":buffers:buffer") + +-- Buffer confirmation +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") + +-- List marks +map("n", "m", ":marks") + +-- Messages +map("n", "M", ":messages") + +-- Clear messages + +-- Clear messages or just refresh/redraw the screen +map("n", "u", ":echo '' | redraw") + +-- Unsets the 'last search pattern' register by hitting return +--map("n", "", "!silent :noh") + +-- Toggle set number +map("n", "$", ":NumbersToggle") +map("n", "%", ":NumbersOnOff") + +-- Easier split navigations, just ctrl-j instead of ctrl-w then j +--map("n", "", "") +--map("n", "", "") +--map("n", "", "") +--map("n", "", "") + +-- Split window +map("n", "h", ":split") +map("n", "v", ":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 Alt+(h/j/k/l) in insert mode to move directional +map("i", "", "") +map("i", "", "") +map("i", "", "") +map("i", "", "") + +-- Map Alt+(h/j/k/l) in command mode to move directional +map("c", "", "") +map("c", "", "") +map("c", "", "") +map("c", "", "") + +-- Map Alt+(h/j/k/l) in selection mode to move directional +map("s", "", "") +map("s", "", "") +map("s", "", "") +map("s", "", "") + +-- Create tab, edit and move between them +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") + +-- Move to the next and previous item in the quickfixlist +--map("n", "]c", "cnext") +--map("n", "[c", "cprevious") + +-- 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) + +-- 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') + +-- Search and replace +map("v", "sr", 'y:%s/"//gc') + +-- Toggle Diff +map("n", "dt", "call utils#ToggleDiff()") + +-- Map delete to Ctrl+l +map("i", "", "") + +-- Clear screen +map("n", "", "!clear") + +-- Change file to an executable +map("n", "x", ":!chmod +x %") + +-- Paste without replace clipboard +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") + +-- Open the current file in the default program (on Mac this should just be just `open`) +map('n', 'o', ':!xdg-open %') + +-- Toggle completion +map("n", "tc", ":lua require('user.mods').toggle_completion()") + +-- Disable default completion. +map('i', '', '') +map('i', '', '') + +-- Set line wrap +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") + else + 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 }) + +-- Use space to toggle fold +--utils.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 # +]]) + +-- Toggle transparency +map('n', 'tb', ':call utils#Toggle_transparent_background()') + +-- Toggle zoom +map("n", "z", ":call utils#ZoomToggle()") +map("n", "z", "|_") + +-- Toggle statusline +map('n', '', ':call ToggleHiddenAll()') + +-- Open last closed buffer +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") + +-- Tmux navigation (aserowy/tmux.nvim) +map('n', '', 'NavigatorLeft') +map('n', '', 'NavigatorRight') +map('n', '', 'NavigatorUp') +map('n', '', 'NavigatorDown') + +-- ToggleTerm +--map("n", "tt", "ToggleTerm") + +-- LazyGit +--map({"n", "t"}, "gg", +map({"n", "t"}, "gg", function() + local config = vim.api.nvim_win_get_config(0) + if config.relative ~= "" then -- is_floating_window? + return "lua LazyGitCurrentFile" + --return "lua require('user.mods').lazygit_at_buffer()" + else + return "lua Lazygit_toggle()" + end +end, {expr = true, replace_keycodes = true}) + +-- Fugitive git bindings +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", "gd", ":Gdiff") +map("n", "ge", ":Gedit") +--map("n", "gr", ":Gread") +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", "gb", ":Git branch") +--map("n", "go", ":Git checkout") +--map("n", "gps", ":Dispatch! git push") +--map("n", "gpl", ":Dispatch! git pull") +-- map[""] = { "ToggleTerm", desc = "Toggle terminal" } +-- map["tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" } +-- map["tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" } +-- map["tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" } +-- map["tp"] = { function() toggle_term_cmd "python" end, desc = "ToggleTerm python" } +-- map["tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } +-- map["tf"] = { "ToggleTerm direction=float", desc = "ToggleTerm float" } +-- map["th"] = { "ToggleTerm size=10 direction=horizontal", desc = "ToggleTerm horizontal split" } +-- map["tv"] = { "ToggleTerm size=80 direction=vertical", desc = "ToggleTerm vertical split" } +--end + +-- Telescope +map("n", "ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end) -- find all files +map("n", "fF", "lua require('telescope.builtin').find_files()") -- find files with hidden option +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", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") +map("n", "cf", "Telescope changed_files") +map("n", "fp", "Telescope pickers") +map("n", "fr", "lua require('telescope.builtin').registers({})") -- registers picker +map("n", "fd", "lua require('telescope.builtin').diagnostics()") +map("n", "fk", "lua require('telescope.builtin').keymaps()") +map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes +map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes +map("n", "f.", [[lua require'plugins.telescope'.find_configs()]]) -- find configs +map("n", "fs", [[lua require'plugins.telescope'.find_scripts()]]) -- find notes +map("n", "fm", "lua require('telescope').extensions.media_files.media_files({})") -- find media files +map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find media files + +-- FZF +map("n", "fz", "lua require('fzf-lua').files()") + +-- Nvim-tree +map("n", "f", ":NvimTreeToggle", {}) + +-- Markdown-preview +map("n", "md", "MarkdownPreviewToggle") +map("n", "mg", "Glow") + +-- Autopairs +map("n", "ww", "lua require('user.mods').Toggle_autopairs()") + +-- Zen-mode toggle +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) + +-- Trouble (UI to show diagnostics) +map("n", "t", "TroubleToggle") +map("n", "tw", "TroubleToggle workspace_diagnostics") +map("n", "td", "TroubleToggle document_diagnostics") +map("n", "tq", "TroubleToggle quickfix") +map("n", "tl", "TroubleToggle loclist") +map("n", "gR", "TroubleToggle lsp_references") + +-- Replacer +map('n', 'qr', ':lua require("replacer").run()') + +-- Quickfix +map("n", "q", function() + if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then + require('plugins.quickfix').close() + else + require('plugins.quickfix').open() + --require("quickfix").open() + end +end, { desc = "Toggle quickfix window" }) + +-- Dashboard +map("n", "db", "Dashboard") + +-- +map("", "l", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) + diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index 5875fc6..0be6548 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -2,7 +2,6 @@ local status_ok, toggleterm = pcall(require, "toggleterm") if not status_ok then return end - toggleterm.setup({ --size = function(term) -- if term.direction == "horizontal" then @@ -13,6 +12,7 @@ toggleterm.setup({ --end, --size = 20, open_mapping = [[tt]], + --autochdir = true, hide_numbers = true, shade_filetypes = {}, shade_terminals = false, @@ -92,6 +92,7 @@ local lazygit = Terminal:new({ width = 150, height = 40 }, + ---- Function to run on opening the terminal --on_open = function(term) -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', 'q', 'close', @@ -106,10 +107,42 @@ local lazygit = Terminal:new({ -- vim.cmd("startinsert!") --end }) +local cur_cwd = vim.fn.getcwd() function Lazygit_toggle() - lazygit:toggle() + -- cwd is the root of project. if cwd is changed, change the git. + local cwd = vim.fn.getcwd() + if cwd ~= cur_cwd then + cur_cwd = cwd + lazygit:close() + lazygit = Terminal:new({ + cmd = "lazygit", + dir = "git_dir", + direction = "float", + on_open = float_handler, + float_opts = { + border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, + width = 150, + height = 40 + }, + }) + end + lazygit:toggle() end +--function Lazygit_toggle() +-- lazygit:toggle() +--end + +--vim.keymap.set({"n", "t"}, "gg", function() +-- -- custom function to find the git directory for the current buffer +-- --local git_root = project_utils.git_root() or vim.fn.getcwd() +-- local git_root = vim.fn.getcwd() +-- +-- lazygit.cmd = 'gitui -d ' .. git_root +-- --"lua lazygit_toggle()" +-- lazygit:toggle() +--end, { desc = 'Toggle gitui' }) + local node = Terminal:new({ cmd = "node", hidden = true }) -- cgit v1.2.3 From 4fa215ac3f0e3b9ebe17840785643736d6005990 Mon Sep 17 00:00:00 2001 From: srdusr Date: Tue, 7 Mar 2023 14:23:05 +0200 Subject: Removed duplicate keys.lua --- keys.lua | 348 --------------------------------------------------------------- 1 file changed, 348 deletions(-) delete mode 100644 keys.lua diff --git a/keys.lua b/keys.lua deleted file mode 100644 index 72ca59f..0000000 --- a/keys.lua +++ /dev/null @@ -1,348 +0,0 @@ ---[[ key.lua ]] - -------------- Shorten Function Names -------------- -local keymap = vim.keymap -local map = function(mode, l, r, opts) - opts = opts or {} - opts.silent = true - opts.noremap = true - keymap.set(mode, l, r, opts) -end -local term_opts = { noremap = true, silent = false } - - ---------------- Standard Operations --------------- --- Semi-colon as leader key -vim.g.mapleader = ";" - --- Jump to next match on line using `.` instead of `;` NOTE: commented out in favour of "ggandor/flit.nvim" ---map("n", ".", ";") - --- Repeat last command using `` instead of `.` NOTE: commented out in favour of "ggandor/flit.nvim" ---map("n", "", ".") - --- "jj" to exit insert-mode -map("i", "jj", "") - --- Reload nvim config -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 -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" - else - return "q" - end -end, {expr = true, replace_keycodes = true}) - --- Combine buffers list with buffer name -map("n", "b", ":buffers:buffer") - --- Buffer confirmation -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") - --- List marks -map("n", "m", ":marks") - --- Messages -map("n", "M", ":messages") - --- Clear messages - --- Clear messages or just refresh/redraw the screen -map("n", "u", ":echo '' | redraw") - --- Unsets the 'last search pattern' register by hitting return ---map("n", "", "!silent :noh") - --- Toggle set number -map("n", "$", ":NumbersToggle") -map("n", "%", ":NumbersOnOff") - --- Easier split navigations, just ctrl-j instead of ctrl-w then j ---map("n", "", "") ---map("n", "", "") ---map("n", "", "") ---map("n", "", "") - --- Split window -map("n", "h", ":split") -map("n", "v", ":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 Alt+(h/j/k/l) in insert mode to move directional -map("i", "", "") -map("i", "", "") -map("i", "", "") -map("i", "", "") - --- Map Alt+(h/j/k/l) in command mode to move directional -map("c", "", "") -map("c", "", "") -map("c", "", "") -map("c", "", "") - --- Map Alt+(h/j/k/l) in selection mode to move directional -map("s", "", "") -map("s", "", "") -map("s", "", "") -map("s", "", "") - --- Create tab, edit and move between them -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") - --- Move to the next and previous item in the quickfixlist ---map("n", "]c", "cnext") ---map("n", "[c", "cprevious") - --- 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) - --- 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') - --- Search and replace -map("v", "sr", 'y:%s/"//gc') - --- Toggle Diff -map("n", "dt", "call utils#ToggleDiff()") - --- Map delete to Ctrl+l -map("i", "", "") - --- Clear screen -map("n", "", "!clear") - --- Change file to an executable -map("n", "x", ":!chmod +x %") - --- Paste without replace clipboard -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") - --- Open the current file in the default program (on Mac this should just be just `open`) -map('n', 'o', ':!xdg-open %') - --- Toggle completion -map("n", "tc", ":lua require('user.mods').toggle_completion()") - --- Disable default completion. -map('i', '', '') -map('i', '', '') - --- Set line wrap -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") - else - 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 }) - --- Use space to toggle fold ---utils.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 # -]]) - --- Toggle transparency -map('n', 'tb', ':call utils#Toggle_transparent_background()') - --- Toggle zoom -map("n", "z", ":call utils#ZoomToggle()") -map("n", "z", "|_") - --- Toggle statusline -map('n', '', ':call ToggleHiddenAll()') - --- Open last closed buffer -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") - --- Tmux navigation (aserowy/tmux.nvim) -map('n', '', 'NavigatorLeft') -map('n', '', 'NavigatorRight') -map('n', '', 'NavigatorUp') -map('n', '', 'NavigatorDown') - --- ToggleTerm ---map("n", "tt", "ToggleTerm") - --- LazyGit ---map({"n", "t"}, "gg", -map({"n", "t"}, "gg", function() - local config = vim.api.nvim_win_get_config(0) - if config.relative ~= "" then -- is_floating_window? - return "lua LazyGitCurrentFile" - --return "lua require('user.mods').lazygit_at_buffer()" - else - return "lua Lazygit_toggle()" - end -end, {expr = true, replace_keycodes = true}) - --- Fugitive git bindings -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", "gd", ":Gdiff") -map("n", "ge", ":Gedit") ---map("n", "gr", ":Gread") -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", "gb", ":Git branch") ---map("n", "go", ":Git checkout") ---map("n", "gps", ":Dispatch! git push") ---map("n", "gpl", ":Dispatch! git pull") --- map[""] = { "ToggleTerm", desc = "Toggle terminal" } --- map["tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" } --- map["tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" } --- map["tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" } --- map["tp"] = { function() toggle_term_cmd "python" end, desc = "ToggleTerm python" } --- map["tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } --- map["tf"] = { "ToggleTerm direction=float", desc = "ToggleTerm float" } --- map["th"] = { "ToggleTerm size=10 direction=horizontal", desc = "ToggleTerm horizontal split" } --- map["tv"] = { "ToggleTerm size=80 direction=vertical", desc = "ToggleTerm vertical split" } ---end - --- Telescope -map("n", "ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end) -- find all files -map("n", "fF", "lua require('telescope.builtin').find_files()") -- find files with hidden option -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", "ffc", "lua require('telescope.builtin').current_buffer_fuzzy_find()") -map("n", "cf", "Telescope changed_files") -map("n", "fp", "Telescope pickers") -map("n", "fr", "lua require('telescope.builtin').registers({})") -- registers picker -map("n", "fd", "lua require('telescope.builtin').diagnostics()") -map("n", "fk", "lua require('telescope.builtin').keymaps()") -map("n", "fn", [[lua require'plugins.telescope'.find_notes()]]) -- find notes -map("n", "fgn", [[lua require'plugins.telescope'.grep_notes()]]) -- search notes -map("n", "f.", [[lua require'plugins.telescope'.find_configs()]]) -- find configs -map("n", "fs", [[lua require'plugins.telescope'.find_scripts()]]) -- find notes -map("n", "fm", "lua require('telescope').extensions.media_files.media_files({})") -- find media files -map("n", "fi", "lua require('telescope').extensions.notify.notify({})") -- find media files - --- FZF -map("n", "fz", "lua require('fzf-lua').files()") - --- Nvim-tree -map("n", "f", ":NvimTreeToggle", {}) - --- Markdown-preview -map("n", "md", "MarkdownPreviewToggle") -map("n", "mg", "Glow") - --- Autopairs -map("n", "ww", "lua require('user.mods').Toggle_autopairs()") - --- Zen-mode toggle -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) - --- Trouble (UI to show diagnostics) -map("n", "t", "TroubleToggle") -map("n", "tw", "TroubleToggle workspace_diagnostics") -map("n", "td", "TroubleToggle document_diagnostics") -map("n", "tq", "TroubleToggle quickfix") -map("n", "tl", "TroubleToggle loclist") -map("n", "gR", "TroubleToggle lsp_references") - --- Replacer -map('n', 'qr', ':lua require("replacer").run()') - --- Quickfix -map("n", "q", function() - if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then - require('plugins.quickfix').close() - else - require('plugins.quickfix').open() - --require("quickfix").open() - end -end, { desc = "Toggle quickfix window" }) - --- Dashboard -map("n", "db", "Dashboard") - --- -map("", "l", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) - -- cgit v1.2.3 From 81339d7e4dc38a82a492cca077f4d76dc855e7c7 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 8 Mar 2023 09:10:46 +0200 Subject: Enabled opt.sessionoptions --- lua/user/opts.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/user/opts.lua b/lua/user/opts.lua index 26dc60d..78a84a4 100644 --- a/lua/user/opts.lua +++ b/lua/user/opts.lua @@ -237,10 +237,10 @@ vim.opt.wildignore:append({ "*/node_modules/*" }) -- vim.opt.shada = "!,'1000,f1,<1000,s100,:1000,/1000,h" -- Sessions ---vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" +vim.opt.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" --vim.opt.sessionoptions = "curdir,folds,help,options,tabpages,winsize,winpos,terminal,globals" -- --vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" -vim.opt.sessionoptions:remove({ "blank", "buffers", "globals" }) +--vim.opt.sessionoptions:remove({ "blank", "buffers", "globals" }) vim.opt.clipboard:append({ "unnamedplus" }) -- Install xclip or this will slowdown startup -- Cursorline -- cgit v1.2.3 From 8c6b1a59acec18c2e4ec34fa586421b9ab7bd587 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 8 Mar 2023 09:13:59 +0200 Subject: Fixed not reloading git directories on different project files and toggling between standard toggleterm/lazygit terminals --- lua/plugins/toggleterm.lua | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua index 0be6548..a9bd450 100644 --- a/lua/plugins/toggleterm.lua +++ b/lua/plugins/toggleterm.lua @@ -77,12 +77,11 @@ end -- if you only want these mappings for toggle term use term://*toggleterm#* instead vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') ---vim.cmd("autocmd! TermOpen term://*toggleterm#* lua set_terminal_keymaps()") - local Terminal = require("toggleterm.terminal").Terminal local lazygit = Terminal:new({ cmd = "lazygit", count = 5, + id = 1000, dir = "git_dir", direction = "float", on_open = float_handler, @@ -107,18 +106,18 @@ local lazygit = Terminal:new({ -- vim.cmd("startinsert!") --end }) -local cur_cwd = vim.fn.getcwd() function Lazygit_toggle() -- cwd is the root of project. if cwd is changed, change the git. local cwd = vim.fn.getcwd() - if cwd ~= cur_cwd then - cur_cwd = cwd + if cwd ~= Cur_cwd then + Cur_cwd = cwd lazygit:close() lazygit = Terminal:new({ cmd = "lazygit", dir = "git_dir", direction = "float", + hidden = true, on_open = float_handler, float_opts = { border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, @@ -129,20 +128,6 @@ function Lazygit_toggle() end lazygit:toggle() end ---function Lazygit_toggle() --- lazygit:toggle() ---end - ---vim.keymap.set({"n", "t"}, "gg", function() --- -- custom function to find the git directory for the current buffer --- --local git_root = project_utils.git_root() or vim.fn.getcwd() --- local git_root = vim.fn.getcwd() --- --- lazygit.cmd = 'gitui -d ' .. git_root --- --"lua lazygit_toggle()" --- lazygit:toggle() ---end, { desc = 'Toggle gitui' }) - local node = Terminal:new({ cmd = "node", hidden = true }) -- cgit v1.2.3