-- definiskanfunction name local keymap = vim.api.nvim_set_keymap local opts = { noremap = true, silent = true } -- Remap space leader keys keymap("", "", "", opts) vim.g.mapleader = " " vim.g.maplocalleader = " " -- MODES -- mormal mode = "n" -- insert mode = "i" -- visual mode = "v" -- visual block mode = "x" -- term mode = "t" -- command mode = "c" for _, mode in ipairs({ "i", "v", "n", "x" }) do -- duplicate line keymap(mode, "", "t.", opts) keymap(mode, "", "t -1", opts) -- save file keymap(mode, "", "silent! w", opts) end -- duplicate line visual block keymap("x", "", ":'<,'>t'>", opts) keymap("x", "", ":'<,'>t-1", opts) -- move text up and down keymap("x", "", ":move '>+1gv-gv", opts) keymap("x", "", ":move '<-2gv-gv", opts) keymap("n", "", "m+", opts) keymap("i", "", "m+", opts) keymap("n", "", "m-2", opts) keymap("i", "", "m-2", opts) -- create comment CTRL + / all mode keymap("v", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) keymap("v", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) keymap("i", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) keymap("i", "", "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", opts) keymap("i", "", "lua require('Comment.api').toggle.linewise.current()", opts) keymap("i", "", "lua require('Comment.api').toggle.linewise.current()", opts) keymap("n", "", "lua require('Comment.api').toggle.linewise.current()", opts) keymap("n", "", "lua require('Comment.api').toggle.linewise.current()", opts) -- close windows keymap("n", "q", "q", opts) keymap("n", "f", "NvimTreeFindFileToggle", opts) -- window navigation keymap("n", "", "h", opts) keymap("n", "", "j", opts) keymap("n", "", "k", opts) keymap("n", "", "l", opts) keymap("n", "", "gg0v$G", opts) keymap("i", "", "gg0v$G", opts) keymap("n", "", '"+y', opts) keymap("v", "", '"+y', opts) keymap("x", "", '"+y', opts) keymap("n", "", '"+P', opts) keymap("v", "", '"+P', opts) keymap("i", "", "pa", opts) keymap("x", "", '"+P', opts) keymap("n", "", "undo", opts) keymap("x", "", "undo", opts) keymap("v", "", "undo", opts) keymap("i", "", "undo", opts) -- Navigate buffers keymap("n", "", ":bnext", opts) keymap("n", "", ":bnext", opts) keymap("n", "", ":bprevious", opts) keymap("n", "", ":bprevious", opts) -- Reordering Bufferline keymap("n", "", "BufferLineMovePrev", opts) keymap("n", "", "BufferLineMoveNext", opts) -- Press jk fast to exit insert mode keymap("i", "jk", "", opts) keymap("i", "kj", "", opts) -- Stay in indent mode keymap("v", "<", "", ">gv", opts) -- ALT + l to open terminal and run live-server keymap("n", "", "terminal live-server", opts) -- close current buffer keymap("n", "", "lua require('auto-bufferline.configs.utils').bufremove()", opts) -- vim.keymap.set("n", "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", "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) 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, {})