diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-08-05 18:41:51 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-08-05 18:41:51 +0800 |
commit | b57c461014f585655d897abf0e0ac982807396b7 (patch) | |
tree | d3b10761cb75d52ff41b0822bc646c9d1c08d935 | |
parent | cc96870ff94afba7b0f2dc18f0209611ff7201f7 (diff) |
Update
-rw-r--r-- | alias | 4 | ||||
-rw-r--r-- | vim/init/basic.vim | 35 | ||||
-rw-r--r-- | vim/init/config.vim | 24 | ||||
-rw-r--r-- | vim/init/keymaps.vim | 71 | ||||
-rw-r--r-- | vim/mini.lua | 212 |
5 files changed, 210 insertions, 136 deletions
@@ -409,11 +409,11 @@ alias sample.osm='curl https://api.openstreetmap.org/api/0.6/node/3428095932' | |||
409 | alias sample.poly='curl -O http://download.geofabrik.de/asia/taiwan.poly' | 409 | alias sample.poly='curl -O http://download.geofabrik.de/asia/taiwan.poly' |
410 | alias sample.gpkg='curl -O http://www.geopackage.org/data/sample1_1.gpkg' | 410 | alias sample.gpkg='curl -O http://www.geopackage.org/data/sample1_1.gpkg' |
411 | alias sample.mvt='curl -O https://demotiles.maplibre.org/tiles/5/25/14.pbf' | 411 | alias sample.mvt='curl -O https://demotiles.maplibre.org/tiles/5/25/14.pbf' |
412 | alias sample.lorem='curl http://metaphorpsum.com/paragraphs/4/16' | 412 | alias sample.lorem='curl -s http://metaphorpsum.com/paragraphs/4/16' |
413 | lorem() { | 413 | lorem() { |
414 | paragraph=${1:-4} | 414 | paragraph=${1:-4} |
415 | sentences=${2:-6} | 415 | sentences=${2:-6} |
416 | curl http://metaphorpsum.com/paragraphs/$paragraph/$sentences | 416 | curl -s http://metaphorpsum.com/paragraphs/$paragraph/$sentences |
417 | } | 417 | } |
418 | alias sample.wmts='curl -O https://gis.sinica.edu.tw/tileserver/wmts' | 418 | alias sample.wmts='curl -O https://gis.sinica.edu.tw/tileserver/wmts' |
419 | sample.image() { curl -Lo random.png https://picsum.photos/seed/`date +%s`/${1:-500}/${2:-500}; } | 419 | sample.image() { curl -Lo random.png https://picsum.photos/seed/`date +%s`/${1:-500}/${2:-500}; } |
diff --git a/vim/init/basic.vim b/vim/init/basic.vim index c4dfa61..fd20476 100644 --- a/vim/init/basic.vim +++ b/vim/init/basic.vim | |||
@@ -4,6 +4,17 @@ | |||
4 | " Used for general usecases. No keymap and personal preference | 4 | " Used for general usecases. No keymap and personal preference |
5 | "====================================================================== | 5 | "====================================================================== |
6 | 6 | ||
7 | " Initial for terminal emulator {{{ | ||
8 | augroup Enter | ||
9 | au! | ||
10 | function! SetEmulaterBackground() | ||
11 | redir => output | hi Normal | redir END | ||
12 | let bg_color = matchstr(output, 'guibg=\zs[^\s]\+\ze') | ||
13 | exe "!alacritty msg config 'colors.primary.background=\"\\"..bg_color.."\"'" | ||
14 | endfunc | ||
15 | autocmd VimEnter * call SetEmulaterBackground() | ||
16 | augroup END | ||
17 | "}}} | ||
7 | " For Vimscript {{{ | 18 | " For Vimscript {{{ |
8 | 19 | ||
9 | " Usage: type --- for foldmark | 20 | " Usage: type --- for foldmark |
@@ -27,7 +38,9 @@ augroup tabinfo | |||
27 | endfunc | 38 | endfunc |
28 | function! RemoveBufFromTabs() | 39 | function! RemoveBufFromTabs() |
29 | for tab in gettabinfo() | 40 | for tab in gettabinfo() |
30 | call filter(tab.variables.bufs, "v:val != "..expand('<abuf>')) | 41 | if has_key(t:, 'bufs') |
42 | call filter(tab.variables.bufs, "v:val != "..expand('<abuf>')) | ||
43 | endif | ||
31 | endfor | 44 | endfor |
32 | endfunc | 45 | endfunc |
33 | 46 | ||
@@ -78,7 +91,7 @@ set showtabline=2 | |||
78 | set number relativenumber | 91 | set number relativenumber |
79 | 92 | ||
80 | " Cursor | 93 | " Cursor |
81 | set cursorline | 94 | " set cursorline |
82 | set guicursor=n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20 | 95 | set guicursor=n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20 |
83 | set matchtime=2 | 96 | set matchtime=2 |
84 | 97 | ||
@@ -95,7 +108,7 @@ set errorformat+=[%f:%l]\ ->\ %m,[%f:%l]:%m | |||
95 | set splitright | 108 | set splitright |
96 | 109 | ||
97 | " Set signcolumn | 110 | " Set signcolumn |
98 | set signcolumn=auto:3 | 111 | set signcolumn=yes:3 |
99 | " Custom sign from help page :h sign | 112 | " Custom sign from help page :h sign |
100 | sign define piet text=>> texthl=Search | 113 | sign define piet text=>> texthl=Search |
101 | 114 | ||
@@ -107,7 +120,7 @@ sign define piet text=>> texthl=Search | |||
107 | " Don't wrap line when typing CJK characters | 120 | " Don't wrap line when typing CJK characters |
108 | " Don't add spaces for CJK | 121 | " Don't add spaces for CJK |
109 | " Don't add comment at next line | 122 | " Don't add comment at next line |
110 | autocmd Filetype * set fo+=mB fo-=cro | 123 | autocmd Filetype * set formatoptions+=mB formatoptions-=cro |
111 | 124 | ||
112 | set shiftwidth=2 | 125 | set shiftwidth=2 |
113 | set autoindent smartindent | 126 | set autoindent smartindent |
@@ -140,10 +153,9 @@ set suffixesadd=.md " Enable reference markdown file without | |||
140 | " }}} | 153 | " }}} |
141 | " SEARCH {{{ | 154 | " SEARCH {{{ |
142 | 155 | ||
143 | set ignorecase " Search case without case sensation | 156 | set ignorecase smartcase " Search case without case sensation |
144 | set smartcase | 157 | set hlsearch " Highlight all matched texts |
145 | set hlsearch " Highlight all matched texts | 158 | set incsearch " Show matched strings when typing |
146 | set incsearch " Show matched strings when typing | ||
147 | 159 | ||
148 | " }}} | 160 | " }}} |
149 | " BUFFERS {{{ | 161 | " BUFFERS {{{ |
@@ -209,16 +221,17 @@ set writebackup | |||
209 | " HIGHLIGHT {{{ | 221 | " HIGHLIGHT {{{ |
210 | 222 | ||
211 | syntax enable | 223 | syntax enable |
212 | set conceallevel=1 | 224 | set syntax=filetype |
225 | set conceallevel=2 | ||
213 | 226 | ||
214 | " Defualt highlight for matched parenthesis is so weird in many colorscheme | 227 | " Defualt highlight for matched parenthesis is so weird in many colorscheme |
215 | " Why the background color is lighter than my caret !? | 228 | " Why the background color is lighter than my caret !? |
216 | " highlight MatchParen ctermfg=NONE ctermbg=darkgrey cterm=NONE | 229 | " highlight MatchParen ctermfg=NONE ctermbg=darkgrey cterm=NONE |
217 | highlight LuaParen ctermfg=NONE ctermbg=darkgrey cterm=NONE | 230 | hi LuaParen ctermfg=NONE ctermbg=darkgrey cterm=NONE |
218 | 231 | ||
219 | " Show trailing spaces | 232 | " Show trailing spaces |
220 | highlight ExtraWhitespace ctermbg=red guibg=red | ||
221 | match ExtraWhitespace /\s\+$/ | 233 | match ExtraWhitespace /\s\+$/ |
234 | hi ExtraWhitespace ctermbg=red guibg=red | ||
222 | 235 | ||
223 | " }}} | 236 | " }}} |
224 | " MISC {{{ | 237 | " MISC {{{ |
diff --git a/vim/init/config.vim b/vim/init/config.vim index 318bc58..3870ac4 100644 --- a/vim/init/config.vim +++ b/vim/init/config.vim | |||
@@ -20,7 +20,7 @@ augroup TerminalSize | |||
20 | if &lines < a:bound || g:alacritty_extra_padding | 20 | if &lines < a:bound || g:alacritty_extra_padding |
21 | silent! set laststatus=0 showtabline=0 signcolumn=0 nowrap scrolloff=1 | 21 | silent! set laststatus=0 showtabline=0 signcolumn=0 nowrap scrolloff=1 |
22 | else | 22 | else |
23 | silent! set laststatus& showtabline& signcolumn& scrolloff& | 23 | silent! set laststatus& showtabline=2 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) |
@@ -147,17 +147,23 @@ augroup InitFileTypes | |||
147 | 147 | ||
148 | augroup Config_Markdown | 148 | augroup Config_Markdown |
149 | au! | 149 | au! |
150 | au FileType markdown call InitMarkdown() | ||
151 | au FileType markdown let b:in_frontmatter = 0 | ||
152 | 150 | ||
153 | function! InitMarkdown() | 151 | au FileType markdown call InitMarkdownFile() |
152 | function! InitMarkdownFile() | ||
154 | setlocal wrap sw=2 ts=2 | 153 | setlocal wrap sw=2 ts=2 |
154 | |||
155 | let b:in_frontmatter = 0 | ||
155 | setlocal foldexpr=MarkdownLevel() foldmethod=expr | 156 | setlocal foldexpr=MarkdownLevel() foldmethod=expr |
156 | setlocal foldtext=MarkdownFoldTextHeading() | 157 | setlocal foldtext=MarkdownFoldTextHeading() |
157 | syn match Details '^<details>' conceal cchar=▶ | 158 | |
158 | syn match Summary '<summary>' conceal cchar= | 159 | call MarkdownHighlights() |
159 | syn match SummaryEnd '</summary>' conceal | 160 | endfunc |
160 | syn match DetailsEnd '^</details>' conceal cchar=E | 161 | |
162 | function MarkdownHighlights() | ||
163 | syn match MarkdownHtmlDetails '^<details>' conceal cchar=▶ | ||
164 | syn match MarkdownHtmlSummary '<summary>' conceal cchar= | ||
165 | syn match MarkdownHtmlSummaryEnd '</summary>' conceal | ||
166 | syn match MarkdownHtmlDetailsEnd '^</details>' conceal cchar=E | ||
161 | endfunc | 167 | endfunc |
162 | 168 | ||
163 | function! MarkdownLevel() | 169 | function! MarkdownLevel() |
@@ -196,7 +202,7 @@ augroup InitFileTypes | |||
196 | let origin = split(MarkdownFoldText()[2:], ' ') | 202 | let origin = split(MarkdownFoldText()[2:], ' ') |
197 | let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g') | 203 | let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g') |
198 | let lines = join(origin[-2:], ' ')[1:-2] | 204 | let lines = join(origin[-2:], ' ')[1:-2] |
199 | let fills = repeat('.', 48 - len(heading) - len(lines)) | 205 | let fills = repeat('.', 48 - strwidth(heading) - len(lines)) |
200 | return heading.." "..fills.." "..lines | 206 | return heading.." "..fills.." "..lines |
201 | endfunc | 207 | endfunc |
202 | 208 | ||
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index a423c20..e8cb61d 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim | |||
@@ -3,7 +3,7 @@ | |||
3 | "====================================================================== | 3 | "====================================================================== |
4 | " vim: sw=2 ts=2 foldmethod=marker foldmarker={{{,}}} | 4 | " vim: sw=2 ts=2 foldmethod=marker foldmarker={{{,}}} |
5 | 5 | ||
6 | " COMMON_MAPPING {{{ | 6 | " COMMON {{{ |
7 | 7 | ||
8 | " Space for searching | 8 | " Space for searching |
9 | map <space> / | 9 | map <space> / |
@@ -37,9 +37,7 @@ augroup vimrc_CRfix | |||
37 | augroup END | 37 | augroup END |
38 | 38 | ||
39 | " Spell | 39 | " Spell |
40 | nnoremap \s :set spell!<CR>:set spell?<CR> | 40 | nnoremap \sp :set spell!<CR>:set spell?<CR> |
41 | nnoremap <leader>ss ]s | ||
42 | nnoremap <leader>S [s | ||
43 | 41 | ||
44 | " Show full path by default | 42 | " Show full path by default |
45 | nnoremap <C-g> 1<C-g> | 43 | nnoremap <C-g> 1<C-g> |
@@ -48,6 +46,8 @@ nnoremap <C-g> 1<C-g> | |||
48 | vnoremap Tz :!trans -t zh-TW -b<CR> | 46 | vnoremap Tz :!trans -t zh-TW -b<CR> |
49 | vnoremap Te :!trans -t en-US -b<CR> | 47 | vnoremap Te :!trans -t en-US -b<CR> |
50 | 48 | ||
49 | nnoremap q: : | ||
50 | |||
51 | " }}} | 51 | " }}} |
52 | " WORKING_DIR {{{ | 52 | " WORKING_DIR {{{ |
53 | 53 | ||
@@ -158,6 +158,16 @@ inoremap <silent><M-9> <Esc>:tablast<CR> | |||
158 | " }}} | 158 | " }}} |
159 | 159 | ||
160 | " }}} | 160 | " }}} |
161 | " EDIT {{{ | ||
162 | |||
163 | " Move one line up and down | ||
164 | nnoremap <C-j> ddp | ||
165 | nnoremap <C-k> ddkP | ||
166 | |||
167 | " Clear current line | ||
168 | nnoremap S S<ESC> | ||
169 | |||
170 | " }}} | ||
161 | " REGISTER {{{ | 171 | " REGISTER {{{ |
162 | " Paste register 0 | 172 | " Paste register 0 |
163 | nnoremap <C-p> "0p | 173 | nnoremap <C-p> "0p |
@@ -176,7 +186,7 @@ vnoremap Y "+y | |||
176 | function! DeleteMark(mark) | 186 | function! DeleteMark(mark) |
177 | let mark = nr2char(a:mark) | 187 | let mark = nr2char(a:mark) |
178 | echo mark | 188 | echo mark |
179 | if mark =~ '[a-Z]' | 189 | if mark =~ '\a' |
180 | execute "delmarks " . mark | 190 | execute "delmarks " . mark |
181 | endif | 191 | endif |
182 | endfunc | 192 | endfunc |
@@ -259,7 +269,7 @@ function! ChangeUnfold(downward, count) | |||
259 | let foldend -= move | 269 | let foldend -= move |
260 | endif | 270 | endif |
261 | norm! zd | 271 | norm! zd |
262 | exe foldstart..","..foldend.."fold" | 272 | try | silent! exe foldstart..","..foldend.."fold" | endtry |
263 | 273 | ||
264 | " Get back to origin cursor position | 274 | " Get back to origin cursor position |
265 | norm! '' | 275 | norm! '' |
@@ -268,16 +278,6 @@ nnoremap <expr> z> ":\<C-u>call ChangeUnfold(1,"..v:count..")\<CR>" | |||
268 | nnoremap <expr> z< ":\<C-u>call ChangeUnfold(0,"..v:count..")\<CR>" | 278 | nnoremap <expr> z< ":\<C-u>call ChangeUnfold(0,"..v:count..")\<CR>" |
269 | 279 | ||
270 | "}}} | 280 | "}}} |
271 | " EDIT {{{ | ||
272 | |||
273 | " Move one line up and down | ||
274 | nnoremap <C-j> ddp | ||
275 | nnoremap <C-k> ddkP | ||
276 | |||
277 | " Clear current line | ||
278 | nnoremap S S<ESC> | ||
279 | |||
280 | " }}} | ||
281 | " TERMINAL {{{ | 281 | " TERMINAL {{{ |
282 | 282 | ||
283 | " Use <leader>z to toggle | 283 | " Use <leader>z to toggle |
@@ -285,13 +285,17 @@ let g:alacritty_extra_padding = 0 | |||
285 | function! ToggleWinPadding() | 285 | function! ToggleWinPadding() |
286 | if g:alacritty_extra_padding | 286 | if g:alacritty_extra_padding |
287 | !alacritty msg config --window-id $WINDOWID --reset | 287 | !alacritty msg config --window-id $WINDOWID --reset |
288 | call SetEmulaterBackground() | ||
288 | hi EndOfBuffer None | 289 | hi EndOfBuffer None |
289 | hi MsgArea None | 290 | hi MsgArea None |
290 | else | 291 | else |
291 | redir => output | hi LineNr | redir END | 292 | redir => output | hi LineNr | redir END |
292 | let bg_color = matchstr(output, 'guibg=\zs[^\s]\+\ze') | 293 | let bg_color = matchstr(output, 'guibg=\zs[^\s]\+\ze') |
293 | exe "hi EndOfBuffer guifg="..bg_color.." guibg="..bg_color | 294 | |
294 | exe "hi MsgArea guibg="..bg_color | 295 | try |
296 | exe "hi EndOfBuffer guifg="..bg_color.." guibg="..bg_color | ||
297 | exe "hi MsgArea guibg="..bg_color | ||
298 | endtry | ||
295 | exe "!alacritty msg config --window-id $WINDOWID window.padding.x=300 'colors.primary.background=\"\\"..bg_color.."\"'" | 299 | exe "!alacritty msg config --window-id $WINDOWID window.padding.x=300 'colors.primary.background=\"\\"..bg_color.."\"'" |
296 | endif | 300 | endif |
297 | 301 | ||
@@ -380,24 +384,16 @@ function! CloseBufferSafely() | |||
380 | if answer == "" | return | endif | 384 | if answer == "" | return | endif |
381 | endif | 385 | endif |
382 | 386 | ||
383 | let l:bufnr = bufnr() | 387 | let bufnr = bufnr() |
384 | |||
385 | if len(t:bufs) == 1 | 388 | if len(t:bufs) == 1 |
386 | " Close tab for last buffer | 389 | " Close tab for last buffer |
387 | tabclose | 390 | tabclose |
388 | else | 391 | else |
389 | " Switch to proper buffer | 392 | " Switch to proper buffer |
390 | let l:next_buf = get(t:bufs, bufnr('#')) ? bufnr('#') : filter(t:bufs, 'v:val != '..l:bufnr)[0] | 393 | let next_buf = get(t:bufs, bufnr('#')) ? bufnr('#') : filter(t:bufs, 'v:val != '..bufnr)[0] |
391 | exe "b "..l:next_buf | 394 | exe "b "..next_buf |
392 | call filter(t:bufs, 'v:val != '..l:bufnr) | 395 | call filter(t:bufs, 'v:val != '..bufnr) |
393 | endif | 396 | endif |
394 | |||
395 | " Delete buffer if every t:buf doesn't have it | ||
396 | for tab in gettabinfo() | ||
397 | if get(tab.variables.bufs, l:bufnr) | return | endif | ||
398 | endfor | ||
399 | exe "bd! "..l:bufnr | ||
400 | |||
401 | endfunction | 397 | endfunction |
402 | function! Bye() | 398 | function! Bye() |
403 | let windows = gettabinfo(tabpagenr())[0]['windows'] | 399 | let windows = gettabinfo(tabpagenr())[0]['windows'] |
@@ -493,10 +489,10 @@ endif | |||
493 | " MANAGE_TABS {{{ | 489 | " MANAGE_TABS {{{ |
494 | 490 | ||
495 | " Useful mappings for managing tabs | 491 | " Useful mappings for managing tabs |
496 | map <leader>tn :tabnew<CR> | 492 | nnoremap <leader>tn :tabnew<CR> |
497 | map <leader>tc :tabclose<CR> | 493 | nnoremap <leader>tc :tabclose<CR> |
498 | map <leader>tm :tabmove<SPACE> | 494 | nnoremap <leader>tm :tabmove<SPACE> |
499 | map <leader>to :tabonly<CR> | 495 | nnoremap <leader>to :tabonly<CR> |
500 | 496 | ||
501 | nnoremap <silent><m-h> :call Tab_MoveLeft()<CR> | 497 | nnoremap <silent><m-h> :call Tab_MoveLeft()<CR> |
502 | nnoremap <silent><m-l> :call Tab_MoveRight()<CR> | 498 | nnoremap <silent><m-l> :call Tab_MoveRight()<CR> |
@@ -508,7 +504,7 @@ autocmd TabLeave * let g:lasttab = tabpagenr() | |||
508 | 504 | ||
509 | " Opens a new tab with the current buffer's path | 505 | " Opens a new tab with the current buffer's path |
510 | " Super useful when editing files in the same directory | 506 | " Super useful when editing files in the same directory |
511 | map <leader>te :tabedit <C-r>=expand("%:p:h")<CR> | 507 | nnoremap <leader>te :tabedit <C-r>=expand("%:p:h")<CR> |
512 | 508 | ||
513 | " Tab move functions | 509 | " Tab move functions |
514 | function! Tvab_MoveLeft() | 510 | function! Tvab_MoveLeft() |
@@ -598,6 +594,11 @@ endfunction | |||
598 | " }}} | 594 | " }}} |
599 | " HIGHLIGHT {{{ | 595 | " HIGHLIGHT {{{ |
600 | 596 | ||
597 | nnoremap <expr> \sy exists("g:syntax_on") ? ":syntax off <CR>" : ":syntax enable<CR>" | ||
598 | |||
599 | " Toggle conceallevel0/2 | ||
600 | nnoremap <expr> \c ":set conceallevel="..(&cole ? 0 : 2).."<CR>:set cole?<CR>" | ||
601 | |||
601 | " Disable highlight when <leader><CR> is pressed | 602 | " Disable highlight when <leader><CR> is pressed |
602 | nnoremap <silent> <leader><CR> :noh<CR> | 603 | nnoremap <silent> <leader><CR> :noh<CR> |
603 | 604 | ||
diff --git a/vim/mini.lua b/vim/mini.lua index 1b5507d..8a19d63 100644 --- a/vim/mini.lua +++ b/vim/mini.lua | |||
@@ -325,20 +325,30 @@ require("mini.pairs").setup() | |||
325 | -- -- suda {{{ | 325 | -- -- suda {{{ |
326 | -- add { source = "lambdalisue/suda.vim" } | 326 | -- add { source = "lambdalisue/suda.vim" } |
327 | -- }}} | 327 | -- }}} |
328 | -- -- true-zen {{{ | ||
329 | -- Add({ | ||
330 | -- source = "Pocco81/true-zen.nvim", | ||
331 | -- }) | ||
332 | -- vim.keymap.set("n", "<leader>z", ":TZAtaraxis<CR>") | ||
333 | -- -- }}} | ||
334 | -- marks.nvim {{{ | 328 | -- marks.nvim {{{ |
335 | Add { | 329 | Add { |
336 | source = "chentoast/marks.nvim" | 330 | source = "chentoast/marks.nvim" |
337 | } | 331 | } |
338 | require('marks').setup { | 332 | require('marks').setup { |
333 | bookmark_0 = { | ||
334 | sign = "⚑", | ||
335 | virt_text = "hello world", | ||
336 | -- explicitly prompt for a virtual line annotation when setting a bookmark from this group. | ||
337 | -- defaults to false. | ||
338 | annotate = false, | ||
339 | }, | ||
339 | } | 340 | } |
340 | vim.cmd("hi MarkSignHL gui=bold guifg=#f85e84 guibg=#37343a") | 341 | vim.cmd("hi MarkSignHL gui=bold guifg=#f85e84 guibg=#37343a") |
341 | -- }}} | 342 | -- }}} |
343 | -- highlight-match-under-cursor {{{ | ||
344 | Add { | ||
345 | source = "adamheins/vim-highlight-match-under-cursor" | ||
346 | } | ||
347 | -- }}} | ||
348 | Add { | ||
349 | source ='shime/vim-livedown' | ||
350 | } | ||
351 | |||
342 | 352 | ||
343 | -- Install Lazy {{{ | 353 | -- Install Lazy {{{ |
344 | -- Bootstrap lazy.nvim | 354 | -- Bootstrap lazy.nvim |
@@ -513,7 +523,9 @@ require("lazy").setup({ | |||
513 | end, | 523 | end, |
514 | config = function() | 524 | config = function() |
515 | require('lualine').setup(opts) | 525 | require('lualine').setup(opts) |
516 | vim.cmd('set laststatus=0') | 526 | if vim.o.lines < 20 then |
527 | vim.o.laststatus=0 | ||
528 | end | ||
517 | end | 529 | end |
518 | }, | 530 | }, |
519 | -- }}} | 531 | -- }}} |
@@ -826,7 +838,7 @@ require("lazy").setup({ | |||
826 | persist_size = false, | 838 | persist_size = false, |
827 | direction = "float", | 839 | direction = "float", |
828 | }) | 840 | }) |
829 | -- | 841 | |
830 | vim.keymap.set({ "n", "t" }, "<A-i>", function() | 842 | vim.keymap.set({ "n", "t" }, "<A-i>", function() |
831 | vim.cmd("ToggleTerm direction=float") | 843 | vim.cmd("ToggleTerm direction=float") |
832 | end, { desc = "terminal toggle floating term" }) | 844 | end, { desc = "terminal toggle floating term" }) |
@@ -836,6 +848,10 @@ require("lazy").setup({ | |||
836 | vim.keymap.set({ "n", "t" }, "<A-v>", function() | 848 | vim.keymap.set({ "n", "t" }, "<A-v>", function() |
837 | vim.cmd("ToggleTerm direction=horizontal") | 849 | vim.cmd("ToggleTerm direction=horizontal") |
838 | end, { desc = "terminal toggle floating term" }) | 850 | end, { desc = "terminal toggle floating term" }) |
851 | vim.keymap.set("v", ",s", function() | ||
852 | require("toggleterm").send_lines_to_terminal("single_line", trim_spaces, { args = vim.v.count }) | ||
853 | vim.cmd("ToggleTerm direction=float") | ||
854 | end) | ||
839 | end, | 855 | end, |
840 | }, | 856 | }, |
841 | --}}} | 857 | --}}} |
@@ -945,68 +961,89 @@ require("lazy").setup({ | |||
945 | end, | 961 | end, |
946 | }, | 962 | }, |
947 | -- }}} | 963 | -- }}} |
948 | 964 | -- -- markview.nvim {{{ | |
949 | -- -- lspconfig {{{ | ||
950 | -- -- Use :help lspconfig-all to check servers | ||
951 | -- { | 965 | -- { |
952 | -- "neovim/nvim-lspconfig", | 966 | -- "OXY2DEV/markview.nvim", |
953 | -- lazy = false, | 967 | -- enable = false, |
954 | -- config = function() | 968 | -- ft = "markdown", |
955 | -- local lspconfig = require "lspconfig" | 969 | -- |
956 | -- -- | ||
957 | -- -- typescript | ||
958 | -- lspconfig.lua_ls.setup {} | ||
959 | -- lspconfig.tsserver.setup {} | ||
960 | -- lspconfig.vimls.setup {} | ||
961 | -- lspconfig.html.setup {} | ||
962 | -- -- | ||
963 | -- vim.keymap.set("n", "<leader>F", function() | ||
964 | -- vim.lsp.buf.format() | ||
965 | -- end, { desc = "format files" }) | ||
966 | -- end, | ||
967 | -- }, | ||
968 | -- -- }}} | ||
969 | -- -- Mason {{{ | ||
970 | -- { | ||
971 | -- "williamboman/mason.nvim", | ||
972 | -- dependencies = { | 970 | -- dependencies = { |
973 | -- "williamboman/mason-lspconfig.nvim", | 971 | -- -- You may not need this if you don't lazy load |
972 | -- -- Or if the parsers are in your $RUNTIMEPATH | ||
973 | -- "nvim-treesitter/nvim-treesitter", | ||
974 | -- | ||
975 | -- "nvim-tree/nvim-web-devicons" | ||
974 | -- }, | 976 | -- }, |
975 | -- config = function() | 977 | -- },-- }}} |
976 | -- require('mason').setup { | 978 | |
977 | -- automatically_installation = true, | 979 | -- lspconfig {{{ |
978 | -- ensure_installed = { | 980 | -- Use :help lspconfig-all to check servers |
979 | -- "vim-language-server", | 981 | { |
980 | -- "lua-language-server", | 982 | "neovim/nvim-lspconfig", |
981 | -- "css-lsp", | 983 | lazy = false, |
982 | -- "html-lsp", | 984 | config = function() |
983 | -- "prettier", | 985 | local lspconfig = require "lspconfig" |
984 | -- "stylua", | 986 | -- |
985 | -- }, | 987 | -- typescript |
986 | -- } | 988 | lspconfig.lua_ls.setup {} |
987 | -- end | 989 | lspconfig.tsserver.setup {} |
988 | -- }, | 990 | lspconfig.vimls.setup {} |
989 | -- -- }}} | 991 | lspconfig.html.setup {} |
990 | -- -- treesitter {{{ | 992 | -- |
991 | -- { | 993 | vim.keymap.set("n", "<leader>F", function() |
992 | -- "nvim-treesitter/nvim-treesitter", | 994 | vim.lsp.buf.format() |
993 | -- event = { "BufReadPost", "BufNewFile" }, | 995 | end, { desc = "format files" }) |
994 | -- cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, | 996 | end, |
995 | -- build = ":TSUpdate", | 997 | }, |
996 | -- config = function() | 998 | -- }}} |
997 | -- require("nvim-treesitter.configs").setup({ | 999 | -- Mason {{{ |
998 | -- ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" }, | 1000 | { |
999 | -- -- | 1001 | "williamboman/mason.nvim", |
1000 | -- highlight = { | 1002 | dependencies = { |
1001 | -- enable = true, | 1003 | "williamboman/mason-lspconfig.nvim", |
1002 | -- use_languagetree = true, | 1004 | }, |
1003 | -- }, | 1005 | config = function() |
1004 | -- -- | 1006 | require('mason').setup { |
1005 | -- indent = { enable = true }, | 1007 | automatically_installation = true, |
1006 | -- }) | 1008 | ensure_installed = { |
1007 | -- end, | 1009 | "vim-language-server", |
1008 | -- }, | 1010 | "lua-language-server", |
1009 | -- -- }}} | 1011 | "css-lsp", |
1012 | "html-lsp", | ||
1013 | "prettier", | ||
1014 | "stylua", | ||
1015 | }, | ||
1016 | } | ||
1017 | end | ||
1018 | }, | ||
1019 | -- }}} | ||
1020 | -- treesitter {{{ | ||
1021 | { | ||
1022 | "nvim-treesitter/nvim-treesitter", | ||
1023 | event = { "BufReadPost", "BufNewFile" }, | ||
1024 | cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, | ||
1025 | build = ":TSUpdate", | ||
1026 | config = function() | ||
1027 | require("nvim-treesitter.configs").setup({ | ||
1028 | ensure_installed = { "markdown", "markdown_inline", "lua", "luadoc", "printf", "vim", "vimdoc" }, | ||
1029 | |||
1030 | highlight = { | ||
1031 | enable = true, | ||
1032 | use_languagetree = true, | ||
1033 | additional_vim_regex_highlighting = true, | ||
1034 | }, | ||
1035 | |||
1036 | indent = { enable = true }, | ||
1037 | }) | ||
1038 | vim.cmd([[ | ||
1039 | syn match MarkdownHtmlDetails '^<details>' conceal cchar=▶ | ||
1040 | syn match MarkdownHtmlSummary '<summary>' conceal cchar= | ||
1041 | syn match MarkdownHtmlSummaryEnd '</summary>' conceal | ||
1042 | syn match MarkdownHtmlDetailsEnd '^</details>' conceal cchar=E | ||
1043 | ]]) | ||
1044 | end, | ||
1045 | }, | ||
1046 | -- }}} | ||
1010 | -- nvim-cmp {{{ | 1047 | -- nvim-cmp {{{ |
1011 | { | 1048 | { |
1012 | "hrsh7th/nvim-cmp", | 1049 | "hrsh7th/nvim-cmp", |
@@ -1133,18 +1170,35 @@ require("lazy").setup({ | |||
1133 | }, | 1170 | }, |
1134 | 1171 | ||
1135 | -- }}} | 1172 | -- }}} |
1136 | -- -- lspsaga {{{ | 1173 | -- lspsaga {{{ |
1137 | -- { | 1174 | { |
1138 | -- 'nvimdev/lspsaga.nvim', | 1175 | 'nvimdev/lspsaga.nvim', |
1139 | -- dependencies = { | 1176 | dependencies = { |
1140 | -- 'nvim-treesitter/nvim-treesitter', -- optional | 1177 | 'nvim-treesitter/nvim-treesitter', -- optional |
1141 | -- 'nvim-tree/nvim-web-devicons', -- optional | 1178 | 'nvim-tree/nvim-web-devicons', -- optional |
1142 | -- }, | 1179 | }, |
1143 | -- config = function() | 1180 | config = function() |
1144 | -- require('lspsaga').setup({}) | 1181 | require('lspsaga').setup({ |
1145 | -- end, | 1182 | autochdir = true, |
1146 | -- }, | 1183 | }) |
1147 | -- -- }}} | 1184 | vim.api.nvim_create_autocmd("LspAttach", { |
1185 | group = custom_autocommands, | ||
1186 | pattern = "*", | ||
1187 | callback = function(args) | ||
1188 | local map = vim.api.nvim_buf_set_keymap | ||
1189 | map(0, "n", "gd", "<cmd>Lspsaga goto_definition<cr>", {silent = true, noremap = true}) | ||
1190 | map(0, "n", "gr", "<cmd>Lspsaga rename<cr>", {silent = true, noremap = true}) | ||
1191 | map(0, "n", "gx", "<cmd>Lspsaga code_action<cr>", {silent = true, noremap = true}) | ||
1192 | map(0, "x", "gx", ":<c-u>Lspsaga range_code_action<cr>", {silent = true, noremap = true}) | ||
1193 | map(0, "n", "K", "<cmd>Lspsaga hover_doc<cr>", {silent = true, noremap = true}) | ||
1194 | map(0, "n", "go", "<cmd>Lspsaga show_line_diagnostics<cr>", {silent = true, noremap = true}) | ||
1195 | map(0, "n", "gj", "<cmd>Lspsaga diagnostic_jump_next<cr>", {silent = true, noremap = true}) | ||
1196 | map(0, "n", "gk", "<cmd>Lspsaga diagnostic_jump_prev<cr>", {silent = true, noremap = true}) | ||
1197 | end, | ||
1198 | }) | ||
1199 | end | ||
1200 | }, | ||
1201 | -- }}} | ||
1148 | -- -- conform {{{ | 1202 | -- -- conform {{{ |
1149 | -- { | 1203 | -- { |
1150 | -- "stevearc/conform.nvim", | 1204 | -- "stevearc/conform.nvim", |