From c680ac2a4b06ebdc2da9a05311f01495c73f9c01 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 30 Jul 2024 17:56:29 +0800 Subject: Update --- vim/init/basic.vim | 59 +++-------- vim/init/config.vim | 63 +++++++----- vim/init/keymaps.vim | 174 +++++++++++++++++--------------- vim/mini.lua | 276 ++++++++++++++++++++++++++++++++++----------------- 4 files changed, 331 insertions(+), 241 deletions(-) (limited to 'vim') diff --git a/vim/init/basic.vim b/vim/init/basic.vim index e18d51f..751b3ac 100644 --- a/vim/init/basic.vim +++ b/vim/init/basic.vim @@ -17,57 +17,28 @@ augroup END " For Buffer and Tab {{{ augroup tabinfo au! - let g:tab_group = {} - " BufEnter {{{ - function! AddBufToTabGroup(tab_group) - let l:tabId = tabpagenr() - let l:bufnr = bufnr() - - if has_key(a:tab_group, l:tabId) - for v in a:tab_group[l:tabId] - if v == l:bufnr - return - endif - endfor - call add(a:tab_group[l:tabId], l:bufnr) - else - let a:tab_group[l:tabId] = [l:bufnr] - endif - endfunc - autocmd BufWinEnter * if &buflisted | call AddBufToTabGroup(g:tab_group) | endif - " }}} - " BufDelete {{{ - function! RemoveBufFromTabGroup(tab_group) - let l:tabId = tabpagenr() - - if has_key(a:tab_group, l:tabId) - let l:new_tab_group = {} - - for [k, tab_list] in items(a:tab_group) - let l:list = [] - for buf in tab_list - if buflisted(buf) > 0 && buf != expand('') - call add(l:list, buf) - end - endfor - if !empty(l:list) - let l:new_tab_group[k] = l:list - endif - endfor - let g:tab_group = l:new_tab_group - - endif + " t:bufs holds buffer numbers + autocmd BufWinEnter * if &buflisted | call AddBufToTab() | endif + autocmd BufDelete * call RemoveBufFromTabs() + function! AddBufToTab() + if !has_key(t:, 'bufs') | let t:['bufs'] = [] | endif + call add(t:bufs, bufnr()) | call sort(t:bufs) | call uniq(t:bufs) + endfunc + function! RemoveBufFromTabs() + for tab in gettabinfo() + call filter(tab.variables.bufs, "v:val != "..expand('')) + endfor endfunc - autocmd BufDelete * call RemoveBufFromTabGroup(g:tab_group) - "}}} + + nnoremap T :echo t:bufs augroup END "}}} " GERERNAL {{{ let mapleader = "," " Always use comma as leader key -set nocompatible " Disable vi compatible, today is 20XX +set nocompatible " Disable vi compatible, today is 2RemoveBufFromTabXX set path=.,** " Allow :find with completion set mouse= " Disable mouse selection set winaltkeys=no " Allow alt key for mapping @@ -194,7 +165,7 @@ augroup END set foldenable " Allow fold set foldmethod=indent " Fold contents by indent set foldlevel=2 -set fillchars+=foldopen:▽,foldsep:│,foldclose:▶ +set fillchars=fold:\ ,foldopen:▽,foldsep:│,foldclose:▶ let g:defaut_foldcolumn = "" if has('nvim') let g:defaut_foldcolumn = "auto:3" diff --git a/vim/init/config.vim b/vim/init/config.vim index 4181ad3..9700c61 100644 --- a/vim/init/config.vim +++ b/vim/init/config.vim @@ -16,14 +16,15 @@ augroup END augroup TerminalSize au! - function! LayoutForSmallTerminal() - if &lines < 19 + function! LayoutForSmallTerminal(bound) + let l:bound = a:bound ? a:bound : 19 + if &lines < l:bound || g:alacritty_extra_padding silent! set cmdheight=0 laststatus=0 showtabline=0 signcolumn=no nowrap scrolloff=1 else silent! set cmdheight& laststatus& showtabline=2 signcolumn=yes scrolloff=3 endif - endfunction - autocmd VimEnter,VimResized * call LayoutForSmallTerminal() + endfunc + autocmd VimEnter,VimResized * silent call LayoutForSmallTerminal(0) augroup END " }}} @@ -140,30 +141,45 @@ augroup InitFileTypes echo "filetype from shebang: ".l:filetype execute "set filetype=".l:filetype endif - endfunction + endfunc autocmd BufReadPost * call ApplyShebang() " }}} " Markdown {{{ augroup Config_Markdown au! - au FileType markdown setlocal wrap sw=2 ts=2 - au FileType markdown setlocal foldexpr=MarkdownLevel() foldmethod=expr + au FileType markdown call InitMarkdown() + + function! InitMarkdown() + setlocal wrap sw=2 ts=2 + setlocal foldexpr=MarkdownLevel() foldmethod=expr + setlocal foldtext=MarkdownFoldTextHeading() + syn match Details '^
' conceal cchar=▶ + syn match Summary '' conceal cchar= + syn match SummaryEnd '' conceal + syn match DetailsEnd '^
' conceal cchar=E + endfunc " Fold by heading level function! MarkdownLevel() let hash_num = matchstr(getline(v:lnum), '^#\+') - let hash_num_at_top = matchstr(getline(v:lnum-1), '^#\+') - if empty(hash_num) - if empty(hash_num_at_top) - return "=" - else - return ">"..(len(hash_num_at_top)) - endif + if !empty(hash_num) + " HEADING + " return ">"..(len(hash_num) - 1) + return len(hash_num) == 1 ? 0 : '>1' else - return len(hash_num) - 1 + " Contents + return "=" endif - endfunction + endfunc + + function! MarkdownFoldTextHeading() + let origin = split(MarkdownFoldText()[2:], ' ') + let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g') + let lines = join(origin[-2:], ' ')[1:-2] + let spaces = repeat('.', 50 - len(heading) - len(lines)) + return heading..spaces.." "..lines + endfunc augroup END @@ -186,7 +202,7 @@ augroup InitFileTypes noh startinsert endif - endfunction + endfunc autocmd FileType html,markdown nnoremap cl :call ChangeAttr("class") autocmd FileType html,markdown nnoremap id :call ChangeAttr("id") @@ -194,12 +210,12 @@ augroup InitFileTypes autocmd BufWrite *.html,*.js,*.css call ReloadServer() function! ReloadServer() silent !browser-sync reload &>/dev/null - endfunction + endfunc " }}} " Mail {{{ - autocmd BufRead /tmp/mutt-* set tw=72 + autocmd BufRead /tmp/mutt-* setlocal tw=72 " }}} " Password {{{ @@ -211,12 +227,9 @@ augroup InitFileTypes function SetPasswordFile() setlocal foldminlines=0 setlocal foldmethod=manual - function s:custom() - return "Password" - endfunction - setlocal foldtext=s:custom() + setlocal foldtext="Password" norm! ggzfl - endfunction + endfunc " }}} " Beancount {{{ @@ -225,7 +238,7 @@ augroup InitFileTypes set filetype=beancount silent !setsid fava ~/bean/main.bean &>/dev/null autocmd VimLeave * silent !killall fava - endfunction + endfunc " }}} diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index 1eb2b20..ce5d315 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim @@ -3,7 +3,7 @@ "====================================================================== " vim: sw=2 ts=2 foldmethod=marker foldmarker={{{,}}} -" COMMON_MAPPING ----------------{{{ +" COMMON_MAPPING {{{ " Space for searching map / @@ -11,9 +11,6 @@ map / " Escape normal mode by inoremap l -" Search for selected test -vnoremap * y/\V=escape(@",'/\') - " Set wrap nnoremap W :set wrap! @@ -39,23 +36,6 @@ augroup vimrc_CRfix autocmd CmdwinEnter * nnoremap augroup END -" In case ALT key is not working -" execute "set =\e2" -" execute "set =\e1" -" execute "set =\e3" -" execute "set =\e4" -" execute "set =\e5" -" execute "set =\e6" -" execute "set =\e7" -" execute "set =\e8" -" execute "set =\e9" -" execute "set =\e0" -" execute "set =\ef" -" execute "set =\eb" -" execute "set =\ed" -" execute "set =\el" -" execute "set =\eh" - " Spell nnoremap \s :set spell!:set spell? nnoremap ss ]s @@ -68,9 +48,22 @@ nnoremap 1 vnoremap Tz :!trans -t zh-TW -b vnoremap Te :!trans -t en-US -b +let g:alacritty_extra_padding = 0 +function! ToggleWinPadding() + if g:alacritty_extra_padding + !alacritty msg config --window-id $WINDOWID --reset + else + redir => output | hi Normal | redir END + let bg_color = matchstr(output, 'guibg=\zs[^\s]\+\ze') + exe "!alacritty msg config --window-id $WINDOWID window.padding.x=300 'colors.primary.background=\"\\"..bg_color.."\"'" + endif + + let g:alacritty_extra_padding = !g:alacritty_extra_padding +endfunc +nnoremap Z silent call ToggleWinPadding() " }}} -" WORKING_DIR ----------------{{{ +" WORKING_DIR {{{ let g:last_path = execute("pwd") augroup SaveLatestDir @@ -103,7 +96,7 @@ function! InCaseCdToLatestDir() endfunction " }}} -" MOTION ----------------{{{ +" MOTION {{{ " j/k will move virtual lines (lines that wrap) nnoremap j (v:count == 0 ? 'gj' : 'j') @@ -121,7 +114,7 @@ xnoremap iq i" xnoremap aq a" -" READLINE_FEATURES ----------------{{{ +" READLINE_FEATURES {{{ inoremap inoremap @@ -155,7 +148,7 @@ nnoremap gk inoremap gj inoremap gk " }}} -" JUMP_TO_TABS_WITH_ALT ----------------{{{ +" JUMP_TO_TABS_WITH_ALT {{{ nnoremap :tabn 1 nnoremap :tabn 2 @@ -200,11 +193,29 @@ nnoremap ddkP nnoremap S S " }}} -" MANAGE_VIMRC ----------------{{{ +" TERMINAL {{{ +" In case ALT key is not working +" execute "set =\e2" +" execute "set =\e1" +" execute "set =\e3" +" execute "set =\e4" +" execute "set =\e5" +" execute "set =\e6" +" execute "set =\e7" +" execute "set =\e8" +" execute "set =\e9" +" execute "set =\e0" +" execute "set =\ef" +" execute "set =\eb" +" execute "set =\ed" +" execute "set =\el" +" execute "set =\eh" +"}}} +" MANAGE_VIMRC {{{ " source .vimrc nnoremap so V:so -nnoremap so :source ~/.vimrc +nnoremap so :source % vnoremap so :source autocmd! BUFWRITEPOST $MYVIMRC source $MYVIMRC @@ -213,7 +224,7 @@ nnoremap e :scriptnames nnoremap ee :edit $MYVIMRC " }}} -" MANAGE_BUFFERS ----------------{{{ +" MANAGE_BUFFERS {{{ " Set options nnoremap so :set @@ -236,19 +247,25 @@ augroup SaveLastBuffer augroup END nnoremap l :exe "buffer ".g:lastbuffer -" Use Ctrl-C for buffer delete or quit vim ----------------{{{ +" Use Ctrl-C for buffer delete or quit vim {{{ " Toggle behavior for the last buffer in the last window let g:quitVimWhenPressingCtrlC = 1 function! ToggleQuit() - let g:quitVimWhenPressingCtrlC = g:quitVimWhenPressingCtrlC ? 0 : 1 + let g:quitVimWhenPressingCtrlC = !g:quitVimWhenPressingCtrlC let message = g:quitVimWhenPressingCtrlC ? "Unlock" : "Lock" echo message endfunction nnoremap \q :call ToggleQuit() +func! QuitWithCheck() + if g:quitVimWhenPressingCtrlC + silent! quit + else + echo "Press \\q to allow quit with " + endif +endfunc function! CloseBufferSafely() - let l:bufnr = bufnr() " Ask Saving if &modified let answer = confirm("Save changes?", "&Yes\n&No\n&Cancel") @@ -257,31 +274,37 @@ function! CloseBufferSafely() if answer == "" | return | endif endif - if g:tab_group[tabpagenr()] == [l:bufnr] - bdelete + let l:bufnr = bufnr() + + if len(t:bufs) == 1 + " Close tab for last buffer + tabclose else - bprevious | bd # + " Switch to proper buffer + let l:next_buf = get(t:bufs, bufnr('#')) ? bufnr('#') : filter(t:bufs, 'v:val != '..l:bufnr)[0] + exe "b "..l:next_buf + call filter(t:bufs, 'v:val != '..l:bufnr) endif + + " Delete buffer if every t:buf doesn't have it + for tab in gettabinfo() + if get(tab.variables.bufs, l:bufnr) | return | endif + endfor + exe "bd! "..l:bufnr + endfunction -func! QuitWithCheck() - if g:quitVimWhenPressingCtrlC - silent! quit - else - echo "Press \\q to allow quit with " - endif -endfunc function! Bye() let windows = gettabinfo(tabpagenr())[0]['windows'] - let bufs = getbufinfo({'buflisted': 1}) - if len(windows) == 1 && len(bufs) == 1 + if len(t:bufs) <= 1 && len(windows) == 1 call QuitWithCheck() elseif &diff silent call CloseBuffersForDiff() elseif len(windows) >1 quit else - silent! call CloseBufferSafely() + call CloseBufferSafely() + " silent! call CloseBufferSafely() endif endfunction nnoremap :call Bye() @@ -325,7 +348,7 @@ nnoremap D silent! SwitchDiffForGitHEAD " }}} " }}} -" MANAGE_WINDOWS ----------------{{{ +" MANAGE_WINDOWS {{{ nnoremap sb :windo set scrollbind! @@ -361,7 +384,7 @@ elseif has('nvim') tnoremap endif " }}} -" MANAGE_TABS ----------------{{{ +" MANAGE_TABS {{{ " Useful mappings for managing tabs map tn :tabnew @@ -395,13 +418,13 @@ function! Tab_MoveRight() endif endfunc " }}} -" FOLD ----------------{{{ +" FOLD {{{ " Set fold options nnoremap fm :e'set foldmethod='..&foldmethod nnoremap fc :e'set foldcolumn='..&foldcolumn -nnoremap zi zizz +nnoremap zi zizz:silent exe &foldenable ? "set foldcolumn=auto:3" : "set foldcolumn=0" " Show fold level when it changes nnoremap zm zm:set foldlevel @@ -415,7 +438,9 @@ nnoremap zF :call ToggleUnfoldSelection()zv nnoremap \z :call GrayOutOtherFolds() " Select current fold +onoremap az :silent! keepjumps normal![zV]z xnoremap az :silent! keepjumps normal![zV]z +onoremap iz :silent! keepjumps normal![zjV]zk xnoremap iz :silent! keepjumps normal![zjV]zk " Use l to open fold @@ -464,7 +489,7 @@ function! GrayOutOtherFolds() endfunction " }}} -" HIGHLIGHT ----------------{{{ +" HIGHLIGHT {{{ " Disable highlight when is pressed nnoremap :noh @@ -497,7 +522,7 @@ nnoremap gh :call matchadd('MultiLineHighlight', '\%'.line('.') nnoremap gH :call clearmatches() " }}} -" SURROUND ----------------{{{ +" SURROUND {{{ inoremap ' '' inoremap " "" @@ -530,14 +555,14 @@ endfunction vnoremap :call AddSpaceForSelection() " }}} -" QUICKFIX ----------------{{{ +" QUICKFIX {{{ nnoremap cn :cn nnoremap cp :cp nnoremap cw :cw 10 " }}} -" REDIRECTION_WITH_BUFFER ----------------{{{ +" REDIRECTION_WITH_BUFFER {{{ " Usage: " :Redir hi ............. show the full output of command ':hi' in a scratch window @@ -561,38 +586,23 @@ command! -nargs=1 -complete=command Redir silent call Redir() command! -nargs=1 -complete=command R silent call Redir() nnoremap rr :Redir " }}} -" QUICK_SUBSTITUTE ----------------{{{ +" SEARCH/SUBSTITUTE {{{ -" Usage: Press n times for area, and for substitute +" Search for selected test +vnoremap * y/\V=escape(@",'/\') -" substitute across file vnoremap s y:%s//0/g -let g:search_not_in_register = 1 -" When leaving visual mode, resume search_not_in_register -autocmd Modechanged [vV\x16]*:* let g:search_not_in_register = 1 - -function! ExpandSelectionBySearch(sep) - if g:search_not_in_register - " Save current selection to register, and keep selection - norm! ygv - let g:search_not_in_register = 0 - endif - " Use register s to go to next search, counts/total is displayed in - " statusline - call feedkeys(a:sep.."\0"..a:sep.."e\") -endfunction -function! SubstituteBySearch() - " Apply current search for default substitute text - call feedkeys(":s//\0/g\\") -endfunction - -vnoremap call ExpandSelectionBySearch('/') -vnoremap call ExpandSelectionBySearch('?') -vnoremap call SubstituteBySearch() +" Usage: Press n times for area, and for substitute +let g:search_selection = 0 +" When leaving visual mode, resume search_selection +autocmd Modechanged [vV\x16]*:* let g:search_selection = 0 +xmap g:search_selection ? "//e" : "*:let g:search_selection = 1gv//e" +xmap g:search_selection ? "??" : "*:let g:search_selection = 1gv??" +vnoremap :s//0/g " }}} -" SIGN ----------------{{{ +" SIGN {{{ nnoremap sc :e'set signcolumn='..&signcolumn @@ -600,7 +610,7 @@ nnoremap si :exe ":sign place " .. line('.') .. " line=" .. line('.') .. nnoremap sI :exe ":sign unplace * file=" .. expand("%:p") " }}} -" GIT_TIG ----------------{{{ +" GIT_TIG {{{ let g:tig_explorer_keymap_commit_split = '' let g:tig_explorer_keymap_commit_vsplit = '' @@ -609,7 +619,7 @@ nnoremap s TigStatus nnoremap b TigBlame " }}} -" Tmp: Markdown items (temproray solution) ----------------{{{ +" Tmp: Markdown items (temproray solution) {{{ " Toggle list item in markdown: "- [ ] XXX" -> "XXX" -> "- XXX" -> "- [ ] XXX" " autocmd FileType markdown nnoremap i V:!sed -E '/^ *- \[.\]/ { s/^( *)- \[.\] */\1/; q; }; /^ *[^[:space:]-]/ { s/^( *)/\1- /; q; }; /^ *- / { s/^( *)- /\1- [ ] /; q; }' @@ -618,14 +628,14 @@ nnoremap b TigBlame " Toggle task status: "- [ ] " -> "- [x]" -> "- [.] " -> "- [ ] " " nnoremap x V:!sed -E '/^ *- \[ \]/ { s/^( *)- \[ \]/\1- [x]/; q; }; /^ *- \[\x\]/ { s/^( *)- \[\x\]/\1- [.]/; q; }; /^ *- \[\.\]/ { s/^( *)- \[\.\]/\1- [ ]/; q; }' " }}} -" Tmp: Common system command ----------------{{{ +" Tmp: Common system command {{{ " Show date selector nnoremap dd :r !sh -c 'LANG=en zenity --calendar --date-format="\%Y.\%m.\%d" 2>/dev/null' nnoremap dD :r !sh -c 'LANG=en zenity --calendar --date-format="\%a \%b \%d" 2>/dev/null' nnoremap dt :r !date +\%H:\%mA " }}} -" Tmp: Compile ----------------{{{ +" Tmp: Compile {{{ " 编译运行 C/C++ 项目 " 详细见:http://www.skywind.me/blog/archives/2084 diff --git a/vim/mini.lua b/vim/mini.lua index 15f4c42..6c31590 100644 --- a/vim/mini.lua +++ b/vim/mini.lua @@ -327,12 +327,121 @@ require("lazy").setup({ vim.keymap.set({ "n", "t" }, "", function() vim.cmd("ToggleTerm direction=float") end, { desc = "terminal toggle floating term" }) + vim.keymap.set({ "n", "t" }, "", function() + zoom() + end, { desc = "terminal toggle floating term" }) vim.keymap.set({ "n", "t" }, "", function() vim.cmd("ToggleTerm direction=horizontal") end, { desc = "terminal toggle floating term" }) end, }, --}}} +-- Markdown: obsidian {{{ + { + "epwalsh/obsidian.nvim", + version = "*", -- recommended, use latest release instead of latest commit + lazy = false, + ft = "markdown", + -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: + -- event = { + -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. + -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" + -- "BufReadPre path/to/my-vault/**.md", + -- "BufNewFile path/to/my-vault/**.md", + -- }, + dependencies = { + -- Required. + "nvim-lua/plenary.nvim", + }, + config = function() + vim.keymap.set("n", "oo", ":Obsidian", { }) + vim.keymap.set("n", "ot", ":ObsidianTags", { }) + vim.keymap.set("n", "os", ":ObsidianSearch", { }) + vim.keymap.set("n", "oq", ":ObsidianQuickSwitch", { }) + vim.keymap.set("v", "on", ":ObsidianLinkNew", { }) + vim.keymap.set("n", "ol", ":ObsidianLinks", { }) + require("obsidian").setup({ + workspaces = { + { + name = "log", + path = "~/log", + }, + }, + completion = { + -- Set to false to disable completion. + nvim_cmp = true, + -- Trigger completion at 2 chars. + min_chars = 2, + }, + mapping = { + -- Toggle check-boxes. + ["oc"] = { + action = function() + return require("obsidian").util.toggle_checkbox() + end, + opts = { buffer = true }, + }, + -- Smart action depending on context, either follow link or toggle checkbox. + [""] = { + action = function() + return require("obsidian").util.smart_action() + end, + opts = { buffer = true, expr = true }, + }, + }, + -- see below for full list of options 👇 + note_id_func = function(title) + return title + -- Create note IDs in a Zettelkasten format with a timestamp and a suffix. + -- In this case a note with the title 'My new note' will be given an ID that looks + -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md' + -- local suffix = "" + -- title = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() + -- if title ~= nil and title ~= "" then + -- -- If title is given, transform it into valid file name. + -- suffix = "-" .. title + -- else + -- -- If title is nil, just add 4 random uppercase letters to the suffix. + -- for _ = 1, 4 do + -- suffix = suffix .. string.char(math.random(65, 90)) + -- end + -- suffix = "-" .. title + -- end + -- return tostring(os.time()) .. suffix + end, + -- Optional, for templates (see below). + templates = { + folder = "templates", + date_format = "%Y-%m-%d", + time_format = "%H:%M", + -- A map for custom variables, the key should be the variable and the value a function + substitutions = {}, + }, + }) + end, + }, +-- }}} +-- Markdown: preview {{{ + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = function() + vim.fn["mkdp#util#install"]() + end, + keys = { + { + "cp", + ft = "markdown", + "MarkdownPreviewToggle", + desc = "Markdown Preview", + }, + }, + config = function() + vim.cmd([[do FileType]]) + vim.g.mkdp_browser = 'firefox' + end, + }, +-- }}} -- lualine {{{ { "nvim-lualine/lualine.nvim", @@ -417,67 +526,67 @@ require("lazy").setup({ }, -- }}} - -- lspconfig {{{ - -- Use :help lspconfig-all to check servers - { - "neovim/nvim-lspconfig", - lazy = false, - config = function() - local lspconfig = require "lspconfig" - -- - -- typescript - lspconfig.lua_ls.setup {} - lspconfig.tsserver.setup {} - lspconfig.vimls.setup {} - lspconfig.html.setup {} - -- - vim.keymap.set("n", "F", function() - vim.lsp.buf.format() - end, { desc = "format files" }) - end, - }, - -- }}} - -- Mason {{{ - { - "williamboman/mason.nvim", - dependencies = { - "williamboman/mason-lspconfig.nvim", - }, - config = function() - require('mason').setup { - automatically_installation = true, - ensure_installed = { - "vim-language-server", - "lua-language-server", - "css-lsp", - "html-lsp", - "prettier", - "stylua", - }, - } - end - }, - -- }}} - -- treesitter {{{ - { - "nvim-treesitter/nvim-treesitter", - event = { "BufReadPost", "BufNewFile" }, - cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, - build = ":TSUpdate", - config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" }, - -- - highlight = { - enable = true, - use_languagetree = true, - }, - -- - indent = { enable = true }, - }) - end, - }, - -- }}} + -- -- lspconfig {{{ + -- -- Use :help lspconfig-all to check servers + -- { + -- "neovim/nvim-lspconfig", + -- lazy = false, + -- config = function() + -- local lspconfig = require "lspconfig" + -- -- + -- -- typescript + -- lspconfig.lua_ls.setup {} + -- lspconfig.tsserver.setup {} + -- lspconfig.vimls.setup {} + -- lspconfig.html.setup {} + -- -- + -- vim.keymap.set("n", "F", function() + -- vim.lsp.buf.format() + -- end, { desc = "format files" }) + -- end, + -- }, + -- -- }}} + -- -- Mason {{{ + -- { + -- "williamboman/mason.nvim", + -- dependencies = { + -- "williamboman/mason-lspconfig.nvim", + -- }, + -- config = function() + -- require('mason').setup { + -- automatically_installation = true, + -- ensure_installed = { + -- "vim-language-server", + -- "lua-language-server", + -- "css-lsp", + -- "html-lsp", + -- "prettier", + -- "stylua", + -- }, + -- } + -- end + -- }, + -- -- }}} + -- -- treesitter {{{ + -- { + -- "nvim-treesitter/nvim-treesitter", + -- event = { "BufReadPost", "BufNewFile" }, + -- cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, + -- build = ":TSUpdate", + -- config = function() + -- require("nvim-treesitter.configs").setup({ + -- ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" }, + -- -- + -- highlight = { + -- enable = true, + -- use_languagetree = true, + -- }, + -- -- + -- indent = { enable = true }, + -- }) + -- end, + -- }, + -- -- }}} -- nvim-cmp {{{ { "hrsh7th/nvim-cmp", @@ -537,7 +646,6 @@ require("lazy").setup({ [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), [''] = cmp.mapping.confirm(), [''] = cmp.mapping.abort(), } @@ -577,7 +685,7 @@ require("lazy").setup({ { name = "path" }, }, experimental = { - ghost_text = true, + -- ghost_text = true, } }) cmp.setup.cmdline(':', { @@ -675,6 +783,7 @@ require("mini.basics").setup() require("mini.misc").setup({ make_global = { "put", "put_text", "zoom" }, }) +vim.keymap.set( 'n', 'z', function() zoom() end, { buffer = bufnr, desc = 'zoom' }) --}}} -- mini.extra {{{ require("mini.extra").setup() @@ -800,10 +909,10 @@ require("mini.visits").setup() -- mini.surround {{{ require("mini.surround").setup { mappings = { - add = 'S' + add = 'sa' } } -vim.keymap.set('v', 's', 'S', { remap = true }) +vim.keymap.set('v', 's', 'sa', {}) -- }}} -- mini.indentscope {{{ require("mini.indentscope").setup() @@ -957,16 +1066,16 @@ require("mini.pairs").setup() -- add { source = "lambdalisue/suda.vim" } -- }}} -- -- true-zen {{{ --- add({ +-- Add({ -- source = "Pocco81/true-zen.nvim", -- }) -- vim.keymap.set("n", "z", ":TZAtaraxis") -- -- }}} --- -- bufferline {{{ +-- bufferline {{{ Add({ source = "akinsho/bufferline.nvim", depends = { - "nvim-tree/nvim-web-devicons", -- OPTIONAL: for file icons + "nvim-tree/nvim-web-devicons", "tiagovla/scope.nvim", }, }) @@ -1015,34 +1124,15 @@ require('bufferline').setup{ } }, custom_filter = function (buf_number) - local tabId = tostring(vim.fn.tabpagenr()) - if vim.g.tab_group[tabId] then - for _, p in ipairs(vim.g.tab_group[tabId]) do - if p == buf_number then - return true - end + for _, p in ipairs(vim.t.bufs) do + if p == buf_number then + return true end end return false end } }; - --- require("bufferline").setup({ --- options = { --- custom_filter = function(buf_number) --- local tabId = vim.fn.tabpagenr() --- if vim.g.tab_group[tabId] then --- for _, p in ipairs(vim.g.tab_group[tabId]) do --- if p == buf_number then --- return true --- end --- end --- end --- return false --- end --- }, --- }) -- keymaps {{{ for i = 1, 9, 1 do vim.keymap.set("n", string.format("", i), function() @@ -1058,6 +1148,12 @@ vim.keymap.set("n", "", "BufferLineTogglePin", opts) -- }}} -- -- TODO: tabpages -- -- }}} +Add { + source = "chentoast/marks.nvim" +} +require('marks').setup { +} +vim.cmd("hi MarkSignHL guifg=#f85e84 guibg=#37343a") -- KEYMAPS {{{ -- cgit v1.2.3-70-g09d2