mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-07-11 18:04:25 +02:00
enc: update key mapping for comment
This commit is contained in:
parent
1167f053e4
commit
fa09a7248e
6 changed files with 109 additions and 74 deletions
|
@ -1,5 +1,6 @@
|
|||
-- definiskanfunction name
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
-- local keymap = vim.api.nvim_set_keymap
|
||||
local keymap = vim.keymap.set
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- Remap space leader keys
|
||||
|
@ -35,15 +36,43 @@ keymap("i", "<M-Down>", "<cmd>m+<cr>", opts)
|
|||
keymap("n", "<M-Up>", "<cmd>m-2<cr>", opts)
|
||||
keymap("i", "<M-Up>", "<cmd>m-2<cr>", opts)
|
||||
|
||||
-- create comment CTRL + / all mode
|
||||
keymap("v", "<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)
|
||||
keymap("i", "<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.current()<cr>", opts)
|
||||
keymap("i", "<C-/>", "<esc><cmd>lua require('Comment.api').toggle.linewise.current()<cr>", opts)
|
||||
keymap("n", "<C-_>", "<esc><cmd>lua require('Comment.api').toggle.linewise.current()<cr>", opts)
|
||||
keymap("n", "<C-/>", "<esc><cmd>lua require('Comment.api').toggle.linewise.current()<cr>", opts)
|
||||
-- create comment CTRL + / visual block mode
|
||||
keymap("x", "<C-_>", function()
|
||||
vim.api.nvim_feedkeys("gb", "v", true)
|
||||
end, opts)
|
||||
-- create comment CTRL + / normal mode
|
||||
keymap("i", "<C-_>", function()
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, false, true), "n", true)
|
||||
-- Toggle comment baris
|
||||
vim.api.nvim_feedkeys("gcc", "v", true)
|
||||
|
||||
-- Tunggu sejenak agar komentar terbentuk
|
||||
vim.schedule(function()
|
||||
local row = vim.fn.line(".") - 1 -- index dimulai dari 0
|
||||
local col = #vim.fn.getline(".") -- panjang baris = akhir kalimat
|
||||
|
||||
-- Geser 2 spasi dari akhir dan masuk insert mode
|
||||
vim.api.nvim_win_set_cursor(0, { row + 1, col })
|
||||
vim.api.nvim_feedkeys("i", "v", true)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Right><leader>", true, false, true), "n", true)
|
||||
end)
|
||||
end, opts)
|
||||
-- create comment CTRL + / normal mode
|
||||
keymap("n", "<C-_>", function()
|
||||
-- Toggle comment baris
|
||||
vim.api.nvim_feedkeys("gcc", "v", true)
|
||||
|
||||
-- Tunggu sejenak agar komentar terbentuk
|
||||
vim.schedule(function()
|
||||
local row = vim.fn.line(".") - 1 -- index dimulai dari 0
|
||||
local col = #vim.fn.getline(".") -- panjang baris = akhir kalimat
|
||||
|
||||
-- Geser 2 spasi dari akhir dan masuk insert mode
|
||||
vim.api.nvim_win_set_cursor(0, { row + 1, col })
|
||||
vim.api.nvim_feedkeys("i", "v", true)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Right><leader>", true, false, true), "n", true)
|
||||
end)
|
||||
end, opts)
|
||||
|
||||
-- close windows
|
||||
keymap("n", "q", "<cmd>q<cr>", opts)
|
||||
|
@ -92,59 +121,6 @@ keymap("n", "<A-l>", "<cmd>terminal live-server<cr>", opts)
|
|||
-- close current buffer
|
||||
keymap("n", "<S-t>", "<cmd>lua require('auto-bufferline.configs.utils').bufremove()<cr>", opts)
|
||||
|
||||
-- vim.keymap.set("n", "<leader>ti", function()
|
||||
-- local api = vim.api
|
||||
-- local parser_configs = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
-- local parsers = vim.tbl_keys(parser_configs)
|
||||
-- table.sort(parsers)
|
||||
--
|
||||
-- local choices = {}
|
||||
-- local lookup = {}
|
||||
--
|
||||
-- for _, parser in ipairs(parsers) do
|
||||
-- local is_installed = #api.nvim_get_runtime_file("parser/" .. parser .. ".so", false) > 0
|
||||
--
|
||||
-- local label = (is_installed and "[✓] " or "[✗] ") .. parser
|
||||
-- table.insert(choices, label)
|
||||
-- lookup[label] = parser
|
||||
-- end
|
||||
--
|
||||
-- vim.ui.select(choices, {
|
||||
-- prompt = "Treesitter ([✓]= installed, [✗] = not installed)",
|
||||
-- }, function(choice)
|
||||
-- if choice then
|
||||
-- local parser_name = lookup[choice]
|
||||
-- if parser_name then
|
||||
-- vim.cmd("TSInstall " .. parser_name)
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
-- end, { desc = "Install Treesitter" })
|
||||
--
|
||||
-- vim.keymap.set("n", "<leader>tu", function()
|
||||
-- local parsers = require("nvim-treesitter.info").installed_parsers()
|
||||
-- table.sort(parsers)
|
||||
-- local choices = {}
|
||||
-- local lookup = {}
|
||||
--
|
||||
-- for _, parser in ipairs(parsers) do
|
||||
-- local label = "[✓] " .. parser
|
||||
-- table.insert(choices, label)
|
||||
-- lookup[label] = parser
|
||||
-- end
|
||||
--
|
||||
-- vim.ui.select(choices, {
|
||||
-- prompt = "Uninstall Treesitter",
|
||||
-- }, function(choice)
|
||||
-- if choice then
|
||||
-- local parser_name = lookup[choice]
|
||||
-- if parser_name then
|
||||
-- vim.cmd("TSUninstall " .. parser_name)
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
-- end, { desc = "Uninstall Treesitter" })
|
||||
|
||||
vim.api.nvim_create_user_command("TSIsInstalled", function()
|
||||
local parsers = require("nvim-treesitter.info").installed_parsers()
|
||||
table.sort(parsers)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue