A readme explaining how to make neovim work fast
telescope now focuses on the same level as neotree
3 files changed, +37 -17
+16-16lua/config/autocmds/init.lua
| @@ -97,7 +97,23 @@ end, { desc = "Set tab width for current buffer.", nargs = 1 }) | ||
| 97 | 97 | -- use comments for fold expression |
| 98 | 98 | _G.CommentFoldExpr = function() |
| 99 | 99 | local line = vim.fn.getline(vim.v.lnum) |
| 100 | + local ft = vim.bo.filetype | |
| 100 | 101 | local cs = vim.bo.commentstring:gsub("%%s", ""):gsub(" ", ""):gsub("([^%w])", "%%%1") |
| 102 | + -- fold python docstrings | |
| 103 | + if ft == "python" then | |
| 104 | + if line:match('""".*"""') then | |
| 105 | + return "=" | |
| 106 | + elseif line:match('"""') then | |
| 107 | + if _G.in_docstring then | |
| 108 | + _G.in_docstring = false | |
| 109 | + return "s1" -- end fold | |
| 110 | + else | |
| 111 | + _G.in_docstring = true | |
| 112 | + return "a1" -- begin fold | |
| 113 | + end | |
| 114 | + end | |
| 115 | + end | |
| 116 | + -- dynamically fold comments | |
| 101 | 117 | if line:match("^%s*" .. cs) then |
| 102 | 118 | return 1 |
| 103 | 119 | else |
| @@ -120,19 +136,3 @@ vim.api.nvim_create_autocmd({ "BufReadPost", "FileType" }, { | ||
| 120 | 136 | vim.opt_local.foldexpr = foldexpr |
| 121 | 137 | end, |
| 122 | 138 | }) |
| 123 | - | |
| 124 | --- wezterm config target from ~/.bashrc | |
| 125 | -local WEZTERM_CONFIG_TARGET = os.getenv("WEZTERM_CONFIG_TARGET") or vim.fn.expand("~/.wezterm.lua") | |
| 126 | - | |
| 127 | --- update wezterm config wheneverver a file ending in .wezterm.lua | |
| 128 | --- is saved. This uses WEZTERM_TARGET_CONFIG from environment variables | |
| 129 | -vim.api.nvim_create_autocmd("BufWritePost", { | |
| 130 | - group = general, | |
| 131 | - desc = "Copies wezterm.lua to the target on save", | |
| 132 | - pattern = "*wezterm.lua", | |
| 133 | - callback = function() | |
| 134 | - vim.notify("Saved wezterm.lua, copying to " .. WEZTERM_CONFIG_TARGET) | |
| 135 | - local src = vim.fn.expand("%:p") | |
| 136 | - vim.system({ "cp", src, WEZTERM_CONFIG_TARGET }) | |
| 137 | - end, | |
| 138 | -}) |
+15-0lua/config/keymaps/init.lua
| @@ -56,3 +56,18 @@ vim.keymap.set("n", "zk", function() | ||
| 56 | 56 | vim.cmd("normal zx") |
| 57 | 57 | vim.cmd("normal zM") |
| 58 | 58 | end, { desc = "Forcefully fold comments" }) |
| 59 | + | |
| 60 | +-- leader space to neovim directory | |
| 61 | +vim.keymap.set("n", "<leader><Space>", function() | |
| 62 | + local neotree = require("neo-tree.sources.manager").get_state("filesystem") | |
| 63 | + local root = neotree.path or vim.fn.getcwd() -- fallback if somehow nil | |
| 64 | + require("telescope.builtin").find_files({ cwd = root }) | |
| 65 | +end, { desc = "Find files from Neo-tree root" }) | |
| 66 | + | |
| 67 | +-- live grep for neovim directory instead of | |
| 68 | +-- the entire project | |
| 69 | +vim.keymap.set("n", "<leader>/", function() | |
| 70 | + local neotree = require("neo-tree.sources.manager").get_state("filesystem") | |
| 71 | + local root = neotree and neotree.path or vim.fn.getcwd() | |
| 72 | + require("telescope.builtin").live_grep({ cwd = root }) | |
| 73 | +end, { desc = "Live grep Neo-tree root" }) |
+6-1wezterm.lua
| @@ -32,6 +32,9 @@ config.keys = { | ||
| 32 | 32 | -- debug |
| 33 | 33 | { key = "d", mods = "CTRL|SHIFT", action = act.ShowDebugOverlay }, |
| 34 | 34 | |
| 35 | + -- quit all | |
| 36 | + { key = "q", mods = "CTRL|SHIFT", action = act.QuitApplication }, | |
| 37 | + | |
| 35 | 38 | -- Show the launcher in fuzzy selection mode and have it list all workspaces |
| 36 | 39 | -- and allow activating one. |
| 37 | 40 | { |
| @@ -73,7 +76,7 @@ config.keys = { | ||
| 73 | 76 | { |
| 74 | 77 | key = "g", |
| 75 | 78 | mods = "CTRL|SHIFT", |
| 76 | - action = act.SpawnCommandInNewTab({ args = { "lazygit" } }), | |
| 79 | + action = act.SpawnCommandInNewWindow({ args = { "lazygit" } }), | |
| 77 | 80 | }, |
| 78 | 81 | } |
| 79 | 82 | |
| @@ -87,4 +90,6 @@ wezterm.on("window-config-reloaded", function(_, _) | ||
| 87 | 90 | wezterm.log_info("Successfully loaded config") |
| 88 | 91 | end) |
| 89 | 92 | |
| 93 | +require("workspaces") | |
| 94 | + | |
| 90 | 95 | return config |