aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--X11/openbox/rc.xml2
-rw-r--r--vim/init/basic.vim8
-rw-r--r--vim/init/config.vim30
-rw-r--r--vim/init/keymaps.vim58
-rw-r--r--vim/mini.lua6
5 files changed, 66 insertions, 38 deletions
diff --git a/X11/openbox/rc.xml b/X11/openbox/rc.xml
index b3765e0..4b13081 100644
--- a/X11/openbox/rc.xml
+++ b/X11/openbox/rc.xml
@@ -110,7 +110,7 @@
110 xdotool search --name @OPENBOX_CONFIG windowactivate || \ 110 xdotool search --name @OPENBOX_CONFIG windowactivate || \
111 alacritty --title @OPENBOX_CONFIG \ 111 alacritty --title @OPENBOX_CONFIG \
112 -o "window.dimensions.lines=32" \ 112 -o "window.dimensions.lines=32" \
113 -o "window.dimensions.columns=90" \ 113 -o "window.dimensions.columns=70" \
114 -e nvim ~/.config/openbox/rc.xml \ 114 -e nvim ~/.config/openbox/rc.xml \
115 ' 115 '
116 </command> 116 </command>
diff --git a/vim/init/basic.vim b/vim/init/basic.vim
index 17a97da..c4dfa61 100644
--- a/vim/init/basic.vim
+++ b/vim/init/basic.vim
@@ -9,7 +9,6 @@
9" Usage: type --- for foldmark 9" Usage: type --- for foldmark
10augroup filetype_vim 10augroup filetype_vim
11 autocmd! 11 autocmd!
12 execute "autocmd FileType vim :inoreabbrev <buffer> --- ----------------{".."{{<CR>\" }"."}}"
13 autocmd FileType vim setlocal foldmethod=marker foldlevel=0 12 autocmd FileType vim setlocal foldmethod=marker foldlevel=0
14augroup END 13augroup END
15 14
@@ -56,7 +55,7 @@ set autoread
56autocmd FocusGained,BufEnter .* checktime 55autocmd FocusGained,BufEnter .* checktime
57 56
58" spell 57" spell
59set spell 58set nospell
60set spellfile="/tmp/spell" 59set spellfile="/tmp/spell"
61 60
62" }}} 61" }}}
@@ -72,6 +71,9 @@ set display=lastline
72set lazyredraw 71set lazyredraw
73set whichwrap=b,s 72set whichwrap=b,s
74 73
74" Tab
75set showtabline=2
76
75" Side column 77" Side column
76set number relativenumber 78set number relativenumber
77 79
@@ -168,6 +170,8 @@ set foldenable " Allow fold
168set foldmethod=indent " Fold contents by indent 170set foldmethod=indent " Fold contents by indent
169set foldlevel=2 171set foldlevel=2
170set fillchars=fold:\ ,foldopen:▽,foldsep:│,foldclose:▶ 172set fillchars=fold:\ ,foldopen:▽,foldsep:│,foldclose:▶
173set foldopen-=search fdo-=mark
174
171let g:defaut_foldcolumn = "" 175let g:defaut_foldcolumn = ""
172if has('nvim') 176if has('nvim')
173 let g:defaut_foldcolumn = "auto:3" 177 let g:defaut_foldcolumn = "auto:3"
diff --git a/vim/init/config.vim b/vim/init/config.vim
index e4403fb..318bc58 100644
--- a/vim/init/config.vim
+++ b/vim/init/config.vim
@@ -18,9 +18,9 @@ augroup TerminalSize
18 au! 18 au!
19 function! LayoutForSmallTerminal(bound) 19 function! LayoutForSmallTerminal(bound)
20 if &lines < a:bound || g:alacritty_extra_padding 20 if &lines < a:bound || g:alacritty_extra_padding
21 silent! set cmdheight=0 laststatus=0 showtabline=0 nowrap scrolloff=1 21 silent! set laststatus=0 showtabline=0 signcolumn=0 nowrap scrolloff=1
22 else 22 else
23 silent! set cmdheight& laststatus& showtabline=2 scrolloff=3 23 silent! set laststatus& showtabline& signcolumn& scrolloff&
24 endif 24 endif
25 endfunc 25 endfunc
26 autocmd VimEnter,VimResized * silent call LayoutForSmallTerminal(20) 26 autocmd VimEnter,VimResized * silent call LayoutForSmallTerminal(20)
@@ -148,6 +148,7 @@ augroup InitFileTypes
148 augroup Config_Markdown 148 augroup Config_Markdown
149 au! 149 au!
150 au FileType markdown call InitMarkdown() 150 au FileType markdown call InitMarkdown()
151 au FileType markdown let b:in_frontmatter = 0
151 152
152 function! InitMarkdown() 153 function! InitMarkdown()
153 setlocal wrap sw=2 ts=2 154 setlocal wrap sw=2 ts=2
@@ -159,12 +160,25 @@ augroup InitFileTypes
159 syn match DetailsEnd '^</details>' conceal cchar=E 160 syn match DetailsEnd '^</details>' conceal cchar=E
160 endfunc 161 endfunc
161 162
162 " Fold by heading level
163 function! MarkdownLevel() 163 function! MarkdownLevel()
164 " For frontmatter
165 if v:lnum == 1 && getline(1) =~ '^---'
166 let b:in_frontmatter = 1
167 return '>1'
168 endif
169 if b:in_frontmatter
170 if getline(v:lnum) =~ '^---'
171 let b:in_frontmatter = 0
172 return '<1'
173 else
174 return '='
175 endif
176 endif
177
178 " Fold for heading and the following contents
164 let hash_num = matchstr(getline(v:lnum), '^#\+') 179 let hash_num = matchstr(getline(v:lnum), '^#\+')
165 if !empty(hash_num) 180 if !empty(hash_num)
166 " HEADING 181 " HEADING
167 " return ">"..(len(hash_num) - 1)
168 return len(hash_num) == 1 ? 0 : '>1' 182 return len(hash_num) == 1 ? 0 : '>1'
169 else 183 else
170 " Contents 184 " Contents
@@ -173,8 +187,14 @@ augroup InitFileTypes
173 endfunc 187 endfunc
174 188
175 function! MarkdownFoldTextHeading() 189 function! MarkdownFoldTextHeading()
190 " For frontmatter
191 if v:foldstart == 1 && getline(v:foldstart) =~ '^---'
192 return '===FrontMatter==='
193 endif
194
195 " For heading, foltext()
176 let origin = split(MarkdownFoldText()[2:], ' ') 196 let origin = split(MarkdownFoldText()[2:], ' ')
177 let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g') 197 let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g')
178 let lines = join(origin[-2:], ' ')[1:-2] 198 let lines = join(origin[-2:], ' ')[1:-2]
179 let fills = repeat('.', 48 - len(heading) - len(lines)) 199 let fills = repeat('.', 48 - len(heading) - len(lines))
180 return heading.." "..fills.." "..lines 200 return heading.." "..fills.." "..lines
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim
index ce6cf84..a423c20 100644
--- a/vim/init/keymaps.vim
+++ b/vim/init/keymaps.vim
@@ -48,21 +48,6 @@ nnoremap <C-g> 1<C-g>
48vnoremap Tz :!trans -t zh-TW -b<CR> 48vnoremap Tz :!trans -t zh-TW -b<CR>
49vnoremap Te :!trans -t en-US -b<CR> 49vnoremap Te :!trans -t en-US -b<CR>
50 50
51let g:alacritty_extra_padding = 0
52function! ToggleWinPadding()
53 if g:alacritty_extra_padding
54 !alacritty msg config --window-id $WINDOWID --reset
55 else
56 redir => output | hi LineNr | redir END
57 let bg_color = matchstr(output, 'guibg=\zs[^\s]\+\ze')
58 exe "hi EndOfBuffer guifg="..bg_color.." guibg="..bg_color
59 exe "!alacritty msg config --window-id $WINDOWID window.padding.x=300 'colors.primary.background=\"\\"..bg_color.."\"'"
60 endif
61
62 let g:alacritty_extra_padding = !g:alacritty_extra_padding
63endfunc
64nnoremap <leader>z <Cmd>silent call ToggleWinPadding()<CR>
65
66" }}} 51" }}}
67" WORKING_DIR {{{ 52" WORKING_DIR {{{
68 53
@@ -190,6 +175,7 @@ vnoremap Y "+y
190" Delete mark 175" Delete mark
191function! DeleteMark(mark) 176function! DeleteMark(mark)
192 let mark = nr2char(a:mark) 177 let mark = nr2char(a:mark)
178 echo mark
193 if mark =~ '[a-Z]' 179 if mark =~ '[a-Z]'
194 execute "delmarks " . mark 180 execute "delmarks " . mark
195 endif 181 endif
@@ -214,7 +200,7 @@ function! ToggleFoldForMarks(offset)
214 " Get list of lines which has mark 200 " Get list of lines which has mark
215 let line_list = [] 201 let line_list = []
216 for info in getmarklist(bufnr()) 202 for info in getmarklist(bufnr())
217 if match(info.mark, "[a-z]") == 1 203 if info.mark =~ "[a-z]"
218 call add(line_list, info.pos[1]) 204 call add(line_list, info.pos[1])
219 endif 205 endif
220 endfor 206 endfor
@@ -250,8 +236,12 @@ endfunction
250nnoremap <expr> z' ":\<C-u>call ToggleFoldForMarks("..v:count..")\<CR>" 236nnoremap <expr> z' ":\<C-u>call ToggleFoldForMarks("..v:count..")\<CR>"
251 237
252function! ChangeUnfold(downward, count) 238function! ChangeUnfold(downward, count)
253 " Only do this if foldmethod is manual or count is given 239 " Only do this if foldmethod is manual
254 if &foldmethod != 'manual' || !a:count | return | endif 240 if &foldmethod != 'manual' | return | endif
241
242 " If count is not given, reverse direction
243 let downward = a:count ? a:downward : !a:downward
244 let move = a:count ? a:count : -1
255 245
256 " Move to fold upward/downward 246 " Move to fold upward/downward
257 if downward 247 if downward
@@ -263,13 +253,12 @@ function! ChangeUnfold(downward, count)
263 let foldend = foldclosedend('.') 253 let foldend = foldclosedend('.')
264 254
265 " Change folding area 255 " Change folding area
266 norm! zd
267 let move = (a:count ? a:count : 1)
268 if downward 256 if downward
269 let foldstart += move 257 let foldstart += move
270 else 258 else
271 let foldend -= move 259 let foldend -= move
272 endif 260 endif
261 norm! zd
273 exe foldstart..","..foldend.."fold" 262 exe foldstart..","..foldend.."fold"
274 263
275 " Get back to origin cursor position 264 " Get back to origin cursor position
@@ -291,6 +280,25 @@ nnoremap S S<ESC>
291" }}} 280" }}}
292" TERMINAL {{{ 281" TERMINAL {{{
293 282
283" Use <leader>z to toggle
284let g:alacritty_extra_padding = 0
285function! ToggleWinPadding()
286 if g:alacritty_extra_padding
287 !alacritty msg config --window-id $WINDOWID --reset
288 hi EndOfBuffer None
289 hi MsgArea None
290 else
291 redir => output | hi LineNr | redir END
292 let bg_color = matchstr(output, 'guibg=\zs[^\s]\+\ze')
293 exe "hi EndOfBuffer guifg="..bg_color.." guibg="..bg_color
294 exe "hi MsgArea guibg="..bg_color
295 exe "!alacritty msg config --window-id $WINDOWID window.padding.x=300 'colors.primary.background=\"\\"..bg_color.."\"'"
296 endif
297
298 let g:alacritty_extra_padding = !g:alacritty_extra_padding
299endfunc
300nnoremap <leader>z <Cmd>silent call ToggleWinPadding()<CR>
301
294" In case ALT key is not working 302" In case ALT key is not working
295" execute "set <M-2>=\e2" 303" execute "set <M-2>=\e2"
296" execute "set <M-1>=\e1" 304" execute "set <M-1>=\e1"
@@ -722,16 +730,8 @@ nnoremap <C-t>s <Cmd>TigStatus<CR>
722nnoremap <C-t>b <Cmd>TigBlame<CR> 730nnoremap <C-t>b <Cmd>TigBlame<CR>
723 731
724" }}} 732" }}}
725" Tmp: Markdown items (temproray solution) {{{
726
727" Toggle list item in markdown: "- [ ] XXX" -> "XXX" -> "- XXX" -> "- [ ] XXX"
728" autocmd FileType markdown nnoremap <buffer> <leader>i V:!sed -E '/^ *- \[.\]/ { s/^( *)- \[.\] */\1/; q; }; /^ *[^[:space:]-]/ { s/^( *)/\1- /; q; }; /^ *- / { s/^( *)- /\1- [ ] /; q; }'<CR><CR>
729" autocmd FileType markdown nnoremap <buffer> <leader>I V:!sed -E 's/^( *)/\1- [ ] /'<CR><CR>
730
731" Toggle task status: "- [ ] " -> "- [x]" -> "- [.] " -> "- [ ] "
732" nnoremap <leader>x V:!sed -E '/^ *- \[ \]/ { s/^( *)- \[ \]/\1- [x]/; q; }; /^ *- \[\x\]/ { s/^( *)- \[\x\]/\1- [.]/; q; }; /^ *- \[\.\]/ { s/^( *)- \[\.\]/\1- [ ]/; q; }'<CR><CR>
733" }}}
734" Tmp: Common system command {{{ 733" Tmp: Common system command {{{
734
735" Show date selector 735" Show date selector
736nnoremap <leader>dd :r !sh -c 'LANG=en zenity --calendar --date-format="\%Y.\%m.\%d" 2>/dev/null'<CR><CR> 736nnoremap <leader>dd :r !sh -c 'LANG=en zenity --calendar --date-format="\%Y.\%m.\%d" 2>/dev/null'<CR><CR>
737nnoremap <leader>dD :r !sh -c 'LANG=en zenity --calendar --date-format="\%a \%b \%d" 2>/dev/null'<CR><CR> 737nnoremap <leader>dD :r !sh -c 'LANG=en zenity --calendar --date-format="\%a \%b \%d" 2>/dev/null'<CR><CR>
diff --git a/vim/mini.lua b/vim/mini.lua
index 750c94e..1b5507d 100644
--- a/vim/mini.lua
+++ b/vim/mini.lua
@@ -337,7 +337,7 @@ Add {
337} 337}
338require('marks').setup { 338require('marks').setup {
339} 339}
340vim.cmd("hi MarkSignHL guifg=#f85e84 guibg=#37343a") 340vim.cmd("hi MarkSignHL gui=bold guifg=#f85e84 guibg=#37343a")
341-- }}} 341-- }}}
342 342
343-- Install Lazy {{{ 343-- Install Lazy {{{
@@ -511,6 +511,10 @@ require("lazy").setup({
511 511
512 return opts 512 return opts
513 end, 513 end,
514 config = function()
515 require('lualine').setup(opts)
516 vim.cmd('set laststatus=0')
517 end
514 }, 518 },
515 -- }}} 519 -- }}}
516 -- Telescope {{{ 520 -- Telescope {{{