From b794a3a524567e0597c8565f043f3156720c318b Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 1 Feb 2023 23:53:42 +0200 Subject: Commented out 'last search pattern' --- lua/user/keys.lua | 81 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 60 insertions(+), 21 deletions(-) (limited to 'lua') diff --git a/lua/user/keys.lua b/lua/user/keys.lua index f01a0c5..46333e1 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -91,8 +91,8 @@ map("n", "[", ":tabprev") map("n", "]", ":tabnext") -- "Zoom" a split window into a tab and/or close it ---map("n", ",", ":tabnew %") ---map("n", ".", ":tabclose") +map("n", ",", ":tabnew %") +map("n", ".", ":tabclose") -- Vim TABs map("n", "1", "1gt") @@ -152,7 +152,7 @@ map("n", "cd", ":cd %:p:h:pwd") map('n', 'o', ':!xdg-open %') -- Unsets the 'last search pattern' register by hitting return -map("n", "", "!silent :noh") +--map("n", "", "!silent :noh") -- Toggle completion map("n", "tc", ":lua require('user.utils').toggle_completion()") @@ -263,6 +263,45 @@ vim.cmd([[ ]]) map("n", "", ":call OpenLastClosed() ") +-- Function to quickly open/hide terminal window inside vim +-- Terminal operation when +-- 1. terminal is open in split window, it closes the window (terminal still +-- running) +-- 2. terminal open in buffer, it moves window into split window +-- 3. no termial instance running then it opens new terminal instance in split +-- window +local function Term() + local terminal_buffer_number = vim.fn.bufnr("term://") + local terminal_window_number = vim.fn.bufwinnr("term://") + local window_count = vim.fn.winnr("$") + + if terminal_window_number > 0 and window_count > 1 then + vim.fn.execute(terminal_window_number .. "wincmd c") + elseif terminal_buffer_number > 0 and terminal_buffer_number ~= vim.fn.bufnr("%") then + vim.fn.execute("sb " .. terminal_buffer_number) + elseif terminal_buffer_number == vim.fn.bufnr("%") then + vim.fn.execute("bprevious | sb " .. terminal_buffer_number .. " | wincmd p") + else + vim.fn.execute("sp term://zsh") + end +end + +vim.api.nvim_create_user_command("Term", Term, { + desc = "Open terminal window", +}) + +map("n", "g", vim.cmd.Term) +map("t", "g", "") + +--map("n", "",function +----local window_id = +-- local Toggle_float = vim.api.nvim_win_get_config() +--if vim.api.nvim_win_get_config(window_id).relative ~= '' then +-- vim.api.nvim_command("nvim_win_close()") +-- -- window with this window_id is floating +--end +--end +--) ---------------- Plugin Operations ---------------- -- Packer @@ -358,23 +397,23 @@ end map("n", "ww", ":lua Toggle_autopairs()", term_opts) -- Tabularize -vim.cmd([[ - vnoremap mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "" - nnoremap mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "" - "nnoremap i mc40A 080lDgelD`cP - "vnoremap ii mc0f-20i`cdt=j -]]) +--vim.cmd([[ +-- vnoremap mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "" +-- nnoremap mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "" +-- "nnoremap i mc40A 080lDgelD`cP +-- "vnoremap ii mc0f-20i`cdt=j +--]]) -- EasyAlign -vim.cmd([[ - " Start interactive EasyAlign in visual mode (e.g. vipga) - xmap ga (EasyAlign) - " Start interactive EasyAlign for a motion/text object (e.g. gaip) - nmap ga (EasyAlign) - if !exists('g:easy_align_delimiters') - let g:easy_align_delimiters = {} - endif - let g:easy_align_delimiters['--'] = { 'pattern': '--', 'ignore_groups': ['String'] } - nnoremap 21A d21\| - imap a -]]) +--vim.cmd([[ +-- " Start interactive EasyAlign in visual mode (e.g. vipga) +-- xmap ga (EasyAlign) +-- " Start interactive EasyAlign for a motion/text object (e.g. gaip) +-- nmap ga (EasyAlign) +-- if !exists('g:easy_align_delimiters') +-- let g:easy_align_delimiters = {} +-- endif +-- let g:easy_align_delimiters['--'] = { 'pattern': '--', 'ignore_groups': ['String'] } +-- nnoremap 21A d21\| +-- imap a +--]]) -- cgit v1.2.3