From 08e78f806cfcc7751a9db83b37aad054230c1920 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 26 Jul 2023 21:07:27 +0200 Subject: Add NullLsToggle keybinding --- lua/user/keys.lua | 188 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 133 insertions(+), 55 deletions(-) (limited to 'lua') diff --git a/lua/user/keys.lua b/lua/user/keys.lua index 7fb712f..88b3822 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -24,22 +24,22 @@ map("i", "jk", "") map("i", "kj", "") -- 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 + elseif vim.o.buftype == "quickfix" then return ":quit" - elseif - vim.o.buftype == 'help' then + elseif vim.o.buftype == "help" then return ":close" else return "q" @@ -108,10 +108,10 @@ map("i", "", "") map("i", "", "") -- Map Alt+(h/j/k/l) in command mode to move directional -vim.api.nvim_set_keymap('c', '', '', { noremap = true }) -vim.api.nvim_set_keymap('c', '', '', { noremap = true }) -vim.api.nvim_set_keymap('c', '', '', { noremap = true }) -vim.api.nvim_set_keymap('c', '', '', { noremap = true }) +vim.api.nvim_set_keymap("c", "", "", { noremap = true }) +vim.api.nvim_set_keymap("c", "", "", { noremap = true }) +vim.api.nvim_set_keymap("c", "", "", { noremap = true }) +vim.api.nvim_set_keymap("c", "", "", { noremap = true }) -- Create tab, edit and move between them map("n", "n", ":tabnew") @@ -171,8 +171,11 @@ map("i", "", "") 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 @@ -186,17 +189,33 @@ map("v", "p", '"_dP') 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})', {}) + 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})', {}) + 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})', {}) + 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 -- Substitute globally and locally in the selected region. @@ -207,8 +226,8 @@ map("v", "ss", ":s//g") 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() @@ -233,23 +252,21 @@ map("n", "", "za") --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", "|_") -- Toggle statusline -map('n', '', ':call ToggleHiddenAll()') +map("n", "", ":call ToggleHiddenAll()") -- Open last closed buffer map("n", "", ":call OpenLastClosed()") - ---------------- Plugin Operations ---------------- -- Packer map("n", "Pc", "PackerCompile") @@ -259,10 +276,10 @@ 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") @@ -272,7 +289,7 @@ map({ "n", "t" }, "tv", "lua Vertical_term_toggle()") -- LazyGit 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) @@ -305,28 +322,70 @@ map("n", "gm", ":Gmove") --end -- Telescope -map("n", "ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = false } end) -- find all files +map("n", "ff", function() + require("telescope.builtin").find_files({ hidden = true, no_ignore = false }) +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", + "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", + "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 scripts -map("n", "fw", [[lua require'plugins.telescope'.find_projects()]]) -- find projects -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", "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 scripts +map( + "n", + "fw", + [[lua require'plugins.telescope'.find_projects()]] +) -- find projects +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", "f/", "lua require('plugins.telescope').curbuf()") -- 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" } +) -- FZF map("n", "fz", "lua require('fzf-lua').files()") @@ -335,7 +394,7 @@ map("n", "fz", "lua require('fzf-lua').files()") map("n", "f", ":NvimTreeToggle", {}) -- Undotree -map('n', 'u', vim.cmd.UndotreeToggle) +map("n", "u", vim.cmd.UndotreeToggle) -- Markdown-preview map("n", "md", "MarkdownPreviewToggle") @@ -345,10 +404,19 @@ map("n", "mg", "Glow") 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", "TroubleToggle") @@ -358,15 +426,18 @@ map("n", "tq", "TroubleToggle quickfix") map("n", "tl", "TroubleToggle loclist") map("n", "gR", "TroubleToggle lsp_references") +-- Null-ls +map("n", "ls", "NullLsToggle") + -- Replacer -map('n', 'qr', ':lua require("replacer").run()') +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() + require("plugins.quickfix").close() else - require('plugins.quickfix').open() + require("plugins.quickfix").open() --require("quickfix").open() end end, { desc = "Toggle quickfix window" }) @@ -380,13 +451,17 @@ if not (dap_ok and dap_ui_ok) then return end -vim.fn.sign_define('DapBreakpoint', { text = '🐞' }) +vim.fn.sign_define("DapBreakpoint", { text = "🐞" }) -- Start debugging session 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. @@ -394,7 +469,9 @@ map("n", "dC", dap.continue) --map("n", "dC", dap.close) --map("n", "dt", dap.terminate) map("n", "dt", ui.toggle) -map("n", "dd", function() dap.disconnect({ terminateDebuggee = true }) end) +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) @@ -404,8 +481,9 @@ map("n", "dB", function() 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", "de", function() + require("dapui").float_element() +end, { desc = "Open Element" }) map("n", "dq", function() require("dapui").close() require("dap").repl.close() -- cgit v1.2.3