add: add key map live server, close buffer

This commit is contained in:
asep komarudin 2024-02-14 22:40:05 +07:00
parent 02ec73abf4
commit 17c1335cd6
2 changed files with 29 additions and 1 deletions

View file

@ -10,6 +10,12 @@ function _LIVE_SERVER()
live_server:toggle()
end
function _close_buffer()
local buf = vim.api.nvim_get_current_buf()
-- delete current buffer
require("bufdelete").bufdelete(buf, true)
end
local term_opts = { silent = true }
-- Shorten function name
@ -46,6 +52,7 @@ keymap("n", "<C-Z>", "<cmd>undo<CR>", opts)
keymap("x", "<C-Z>", "<esc><cmd>undo<CR>", opts)
keymap("v", "<C-Z>", "<esc><cmd>undo<CR>", opts)
keymap("i", "<C-Z>", "<esc><cmd>undo<CR>", opts)
-- create comment CTRL + / all mode
keymap("n", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", opts)
keymap("v", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", opts)
keymap("i", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", opts)
@ -54,6 +61,9 @@ keymap("n", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise.curre
-- keymap("n", "<C-l>", "<esc><cmd>lua _LIVE_SERVER()<cr>", opts)
-- keymap("i", "<C-l>", "<esc><cmd>lua _LIVE_SERVER()<cr>", opts)
-- ALT + l to open terminal and run live-server
keymap("n", "<A-l>", "<cmd>terminal<cr>$i<Right>live-server<cr>", opts)
-- Resize with arrows
-- cona
-- keymap("n", "<C-Down>", ":resize +2<CR>", opts)
@ -114,6 +124,9 @@ keymap("x", "<S-Down>", ":'<,'>t'><cr>", opts)
-- keymap("i", "<C-r>", "<cmd>RunFile<CR>", opts)
-- keymap("n", "<C-r>", "<cmd>RunFile<CR>", opts)
-- close current buffer
keymap("n", "<S-t>", "<cmd>lua _close_buffer()<cr>", opts)
-- Visual Block --
-- Move text up and down
keymap("x", "J", ":move '>+1<CR>gv-gv", opts)