From e58f70b411ae935fcd32f00d9e3983381fdc0294 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 26 Jun 2024 21:29:34 +0800 Subject: Update --- vim/init/config.vim | 23 +++++++++++++++++++++++ vim/init/keymaps.vim | 3 ++- vim/lazy.lua | 2 +- vim/lua/mappings.lua | 7 ++++++- vim/lua/plugins/init.lua | 5 +++++ 5 files changed, 37 insertions(+), 3 deletions(-) (limited to 'vim') diff --git a/vim/init/config.vim b/vim/init/config.vim index 07bed12..489521f 100644 --- a/vim/init/config.vim +++ b/vim/init/config.vim @@ -10,6 +10,29 @@ " Open help page in a new tab autocmd BufEnter *.txt if &filetype == 'help' | wincmd T | endif +" Quickly edit html tag class +function! s:ChangeAttr(pattern) + + let l:attr = matchstr(getline('.'), a:pattern.'="') + if l:attr == '' + let l:all_attrs = matchstr(getline('.'), '<[[:alnum:]]\+\zs\s\?[^>]*>\ze') + execute 's/'.l:all_attrs.'/ '.a:pattern.'=""'.l:all_attrs.'/' + noh + normal! 0f"l + startinsert + else + normal! 0 + call search(l:attr) + normal! f"l + noh + startinsert + endif +endfunction + +autocmd FileType html nnoremap cl :call ChangeAttr("class") +autocmd BufLeave nunmap cl +autocmd FileType html nnoremap id :call ChangeAttr("id") +autocmd BufLeave nunmap id "---------------------------------------------------------------------- " 有 tmux 何没有的功能键超时(毫秒) diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index 245905a..ff4821e 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim @@ -246,6 +246,7 @@ endfunc " Open a new buffer nmap b :enew +nmap B :enew nmap O :e /tmp/buffer " Next buffer @@ -254,7 +255,7 @@ noremap l :exe "buffer ".g:lastbuffer " set filetype noremap ft :set filetype= -noremap f :set foldmetho = +noremap fm :set foldmethod= " Let l toggle between this and the last accessed buffer let g:lastbuffer = 1 diff --git a/vim/lazy.lua b/vim/lazy.lua index 6cfadf0..ebe7766 100644 --- a/vim/lazy.lua +++ b/vim/lazy.lua @@ -1,5 +1,5 @@ -vim.g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" vim.g.mapleader = "," +vim.g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" -- bootstrap lazy and all plugins local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" diff --git a/vim/lua/mappings.lua b/vim/lua/mappings.lua index 9151f17..eaa6e68 100644 --- a/vim/lua/mappings.lua +++ b/vim/lua/mappings.lua @@ -110,7 +110,6 @@ end, { desc = "Create a new snippet" }) -- map("n", "ma", "Telescope marks", { desc = "telescope find marks" }) -- map("n", "cm", "Telescope git_commits", { desc = "telescope git commits" }) -- map("n", "gt", "Telescope git_status", { desc = "telescope git status" }) --- map("n", "th", "Telescope themes", { desc = "telescope nvchad themes" }) -- terminal -- map("t", "", "", { desc = "terminal escape terminal mode" }) @@ -120,8 +119,11 @@ vim.keymap.set("n", "h", function() require("nvchad.term").new { vim.keymap.set("n", "v", function() require("nvchad.term").new { pos = "vsp" } end, { desc = "terminal new vertical window" }) -- toggleable vim.keymap.set({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm" } end, { desc = "terminal toggleable vertical term" }) +vim.keymap.set("t", "", "", { desc = "terminal escape terminal mode" }) +vim.keymap.set({ "t" }, "", "|_i", { desc = "terminal toggleable vertical term" }) vim.keymap.set({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" } end, { desc = "terminal new horizontal term" }) vim.keymap.set({ "n", "t" }, "", function() require("nvchad.term").toggle { pos = "float", id = "floatTerm" } end, { desc = "terminal toggle floating term" }) +vim.keymap.set("n", "th", "Telescope themes", { desc = "telescope nvchad themes" }) -- whichkey vim.keymap.set("n", "wK", "WhichKey ", { desc = "whichkey all keymaps" }) @@ -169,6 +171,9 @@ vim.g.mkdp_preview_options = { vim.keymap.set('n', "", ':HopWord') vim.keymap.set('n', '', ':HopChar1') +-- [ Configure vim-surround ] +vim.cmd('vmap s S') + -- [ Aerial ] vim.keymap.set("n", "{", "AerialPrev", {}) vim.keymap.set("n", "}", "AerialNext", {}) diff --git a/vim/lua/plugins/init.lua b/vim/lua/plugins/init.lua index 8c49369..f54e21d 100644 --- a/vim/lua/plugins/init.lua +++ b/vim/lua/plugins/init.lua @@ -233,6 +233,11 @@ return { }, }, + { + 'tpope/vim-surround', + lazy = false, + } + -- { -- 'akinsho/bufferline.nvim', -- cgit v1.2.3-70-g09d2