irongit

A readme explaining how to make neovim work fast

moved comment folding into it's own file

huncholanehuncholaneauthored
parent 63e787ecommit cf5570c98c4777ef18a0a8e27eb5c5bc45fcf2a4Browse files

3 files changed, +59 -45

+3-0bashrc.sh
@@ -20,3 +20,6 @@ function wezterm_osc7_cwd() {
2020 printf "\033]7;file://%s%s\033\\" "$(hostname)" "$PWD"
2121 }
2222 PROMPT_COMMAND="wezterm_osc7_cwd; $PROMPT_COMMAND"
23+
24+# remove stupid zone identifier files
25+alias rmzf='sudo find . -name "*.Identifier" -type f -delete'
+0-45lua/config/autocmds/init.lua
@@ -90,48 +90,3 @@ vim.api.nvim_create_user_command("SetTabs", function(opts)
9090 vim.notify("Invalid number", vim.log.levels.ERROR)
9191 end
9292 end, { desc = "Set tab width for current buffer.", nargs = 1 })
93-
94--- use comments for fold expression
95--- use comments for fold expression
96--- use comments for fold expression
97--- use comments for fold expression
98-_G.CommentFoldExpr = function()
99- local line = vim.fn.getline(vim.v.lnum)
100- local ft = vim.bo.filetype
101- local cs = vim.bo.commentstring:gsub("%%s", ""):gsub(" ", ""):gsub("([^%w])", "%%%1")
102- local should_fold = line:match("^%s*" .. cs) or _G.in_docstring
103- -- python docstrings
104- if ft == "python" then
105- if line:match('""".*"""') then
106- return "0"
107- end
108- if line:match('"""') then
109- if _G.in_docstring then
110- _G.in_docstring = false
111- else
112- _G.in_docstring = true
113- should_fold = true
114- end
115- end
116- end
117- if should_fold then
118- return 1
119- end
120- return 0
121-end
122-local foldexpr = "v:lua.CommentFoldExpr()"
123-vim.api.nvim_create_user_command("UseFoldTreesitter", function()
124- vim.opt_local.foldexpr = foldexpr
125-end, { desc = "Set fold expression to treesitter" })
126-vim.api.nvim_create_user_command("UseFoldComment", function()
127- foldexpr = "v:lua.CommentFoldExpr()"
128- vim.opt_local.foldexpr = foldexpr
129-end, { desc = "Set foldexpr to comments" })
130-vim.api.nvim_create_autocmd({ "BufReadPost", "FileType" }, {
131- group = general,
132- pattern = "*",
133- callback = function()
134- vim.opt_local.foldmethod = "expr"
135- vim.opt_local.foldexpr = foldexpr
136- end,
137-})
+56-0lua/plugins/folding.lua
@@ -0,0 +1,56 @@
1+-- use comments for fold expression
2+-- use comments for fold expression
3+-- use comments for fold expression
4+-- use comments for fold expression
5+_G.CommentFoldExpr = function()
6+ local line = vim.fn.getline(vim.v.lnum)
7+ local ft = vim.bo.filetype
8+ local cs = vim.bo.commentstring:gsub("%%s", ""):gsub(" ", ""):gsub("([^%w])", "%%%1")
9+ local should_fold = line:match("^%s*" .. cs) or _G.in_docstring
10+ -- python docstrings
11+ if ft == "python" then
12+ if line:match('""".*"""') then
13+ return "0"
14+ end
15+ if line:match('"""') then
16+ if _G.in_docstring then
17+ _G.in_docstring = false
18+ else
19+ _G.in_docstring = true
20+ should_fold = true
21+ end
22+ end
23+ end
24+ -- lua docstrings
25+ if ft == "lua" then
26+ if line:match("--%[%[") then
27+ _G.in_docstring = true
28+ should_fold = true
29+ end
30+ if line:match("--%]%]") and _G.in_docstring then
31+ _G.in_docstring = false
32+ end
33+ end
34+ if should_fold then
35+ return 1
36+ end
37+ return 0
38+end
39+local foldexpr = "v:lua.CommentFoldExpr()"
40+vim.api.nvim_create_user_command("UseFoldTreesitter", function()
41+ vim.opt_local.foldexpr = foldexpr
42+end, { desc = "Set fold expression to treesitter" })
43+vim.api.nvim_create_user_command("UseFoldComment", function()
44+ foldexpr = "v:lua.CommentFoldExpr()"
45+ vim.opt_local.foldexpr = foldexpr
46+end, { desc = "Set foldexpr to comments" })
47+vim.api.nvim_create_autocmd({ "BufReadPost", "FileType" }, {
48+ group = general,
49+ pattern = "*",
50+ callback = function()
51+ vim.opt_local.foldmethod = "expr"
52+ vim.opt_local.foldexpr = foldexpr
53+ end,
54+})
55+
56+return {}