added keybindings
This commit is contained in:
parent
0f401d28e1
commit
b1a7860fdd
|
@ -3,7 +3,7 @@ local nnoremap = Remap.nnoremap
|
||||||
local inoremap = Remap.inoremap
|
local inoremap = Remap.inoremap
|
||||||
|
|
||||||
local sumneko_root_path = "/usr/lib/lua-language-server"
|
local sumneko_root_path = "/usr/lib/lua-language-server"
|
||||||
local sumneko_binary = "/usr/bin/lua-language-server"
|
local sumneko_binary = "/usr/local/bin/lua-language-server"
|
||||||
|
|
||||||
-- Setup nvim-cmp.
|
-- Setup nvim-cmp.
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
@ -34,19 +34,19 @@ cmp.setup({
|
||||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
formatting = {
|
formatting = {
|
||||||
format = function(entry, vim_item)
|
format = function(entry, vim_item)
|
||||||
vim_item.kind = lspkind.presets.default[vim_item.kind]
|
vim_item.kind = lspkind.presets.default[vim_item.kind]
|
||||||
local menu = source_mapping[entry.source.name]
|
local menu = source_mapping[entry.source.name]
|
||||||
-- if entry.source.name == "cmp_tabnine" then
|
-- if entry.source.name == "cmp_tabnine" then
|
||||||
-- if entry.completion_item.data ~= nil and entry.completion_item.data.detail ~= nil then
|
-- if entry.completion_item.data ~= nil and entry.completion_item.data.detail ~= nil then
|
||||||
-- menu = entry.completion_item.data.detail .. " " .. menu
|
-- menu = entry.completion_item.data.detail .. " " .. menu
|
||||||
-- end
|
-- end
|
||||||
-- vim_item.kind = ""
|
-- vim_item.kind = ""
|
||||||
-- end
|
-- end
|
||||||
vim_item.menu = menu
|
vim_item.menu = menu
|
||||||
return vim_item
|
return vim_item
|
||||||
end,
|
end,
|
||||||
|
@ -82,24 +82,50 @@ tabnine:setup({
|
||||||
run_on_every_keystroke = true,
|
run_on_every_keystroke = true,
|
||||||
snippet_placeholder = "..",
|
snippet_placeholder = "..",
|
||||||
})
|
})
|
||||||
]]--
|
]]
|
||||||
|
--
|
||||||
|
|
||||||
local function config(_config)
|
local function config(_config)
|
||||||
return vim.tbl_deep_extend("force", {
|
return vim.tbl_deep_extend("force", {
|
||||||
on_attach = function()
|
on_attach = function()
|
||||||
nnoremap("gD", function() vim.lsp.buf.definition() end)
|
nnoremap("gD", function()
|
||||||
nnoremap("gd", function() vim.lsp.buf.definition() end)
|
vim.lsp.buf.definition()
|
||||||
nnoremap("K", function() vim.lsp.buf.hover() end)
|
end)
|
||||||
nnoremap("gi", function() vim.lsp.buf.implementation() end)
|
nnoremap("gd", function()
|
||||||
nnoremap("<leader>wa", function() vim.lsp.buf.add_workspace_folder() end)
|
vim.lsp.buf.definition()
|
||||||
nnoremap("<leader>wr", function() vim.lsp.buf.remove_workspace_folder() end)
|
end)
|
||||||
nnoremap("<leader>wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end)
|
nnoremap("K", function()
|
||||||
nnoremap("<leader>vws", function() vim.lsp.buf.workspace_symbol() end)
|
vim.lsp.buf.hover()
|
||||||
nnoremap("<leader>vd", function() vim.diagnostic.open_float() end)
|
end)
|
||||||
nnoremap("[d", function() vim.diagnostic.goto_next() end)
|
nnoremap("gi", function()
|
||||||
nnoremap("]d", function() vim.diagnostic.goto_prev() end)
|
vim.lsp.buf.implementation()
|
||||||
nnoremap("<leader>ca", function() vim.lsp.buf.code_action() end)
|
end)
|
||||||
nnoremap("<leader>vco", function() vim.lsp.buf.code_action({
|
nnoremap("<leader>wa", function()
|
||||||
|
vim.lsp.buf.add_workspace_folder()
|
||||||
|
end)
|
||||||
|
nnoremap("<leader>wr", function()
|
||||||
|
vim.lsp.buf.remove_workspace_folder()
|
||||||
|
end)
|
||||||
|
nnoremap("<leader>wl", function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end)
|
||||||
|
nnoremap("<leader>vws", function()
|
||||||
|
vim.lsp.buf.workspace_symbol()
|
||||||
|
end)
|
||||||
|
nnoremap("<leader>vd", function()
|
||||||
|
vim.diagnostic.open_float()
|
||||||
|
end)
|
||||||
|
nnoremap("[d", function()
|
||||||
|
vim.diagnostic.goto_next()
|
||||||
|
end)
|
||||||
|
nnoremap("]d", function()
|
||||||
|
vim.diagnostic.goto_prev()
|
||||||
|
end)
|
||||||
|
nnoremap("<leader>ca", function()
|
||||||
|
vim.lsp.buf.code_action()
|
||||||
|
end)
|
||||||
|
nnoremap("<leader>vco", function()
|
||||||
|
vim.lsp.buf.code_action({
|
||||||
filter = function(code_action)
|
filter = function(code_action)
|
||||||
if not code_action or not code_action.data then
|
if not code_action or not code_action.data then
|
||||||
return false
|
return false
|
||||||
|
@ -108,16 +134,26 @@ local function config(_config)
|
||||||
local data = code_action.data.id
|
local data = code_action.data.id
|
||||||
return string.sub(data, #data - 1, #data) == ":0"
|
return string.sub(data, #data - 1, #data) == ":0"
|
||||||
end,
|
end,
|
||||||
apply = true
|
apply = true,
|
||||||
}) end)
|
})
|
||||||
nnoremap("<leader>gr", function() vim.lsp.buf.references() end)
|
end)
|
||||||
nnoremap("<leader>rn", function() vim.lsp.buf.rename() end)
|
nnoremap("<leader>gr", function()
|
||||||
inoremap("<C-h>", function() vim.lsp.buf.signature_help() end)
|
vim.lsp.buf.references()
|
||||||
nnoremap("<leader>f", function() vim.lsp.buf.format({ async = true }) end)
|
end)
|
||||||
|
nnoremap("<leader>rn", function()
|
||||||
|
vim.lsp.buf.rename()
|
||||||
|
end)
|
||||||
|
inoremap("<C-h>", function()
|
||||||
|
vim.lsp.buf.signature_help()
|
||||||
|
end)
|
||||||
|
nnoremap("<leader>f", function()
|
||||||
|
vim.lsp.buf.format({ async = true })
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
}, _config or {})
|
}, _config or {})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require("lspconfig").solargraph.setup(config())
|
||||||
require("lspconfig").zls.setup(config())
|
require("lspconfig").zls.setup(config())
|
||||||
|
|
||||||
require("lspconfig").tsserver.setup(config())
|
require("lspconfig").tsserver.setup(config())
|
||||||
|
@ -147,15 +183,6 @@ require("lspconfig").gopls.setup(config({
|
||||||
-- who even uses this?
|
-- who even uses this?
|
||||||
require("lspconfig").rust_analyzer.setup(config({
|
require("lspconfig").rust_analyzer.setup(config({
|
||||||
cmd = { "rustup", "run", "nightly", "rust-analyzer" },
|
cmd = { "rustup", "run", "nightly", "rust-analyzer" },
|
||||||
--[[
|
|
||||||
settings = {
|
|
||||||
rust = {
|
|
||||||
unstable_features = true,
|
|
||||||
build_on_save = false,
|
|
||||||
all_features = true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
--]]
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
require("lspconfig").sumneko_lua.setup(config({
|
require("lspconfig").sumneko_lua.setup(config({
|
||||||
|
@ -216,4 +243,3 @@ require("luasnip.loaders.from_vscode").lazy_load({
|
||||||
include = nil, -- Load all languages
|
include = nil, -- Load all languages
|
||||||
exclude = {},
|
exclude = {},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ mason_lspconfig.setup({
|
||||||
"html",
|
"html",
|
||||||
"cssls",
|
"cssls",
|
||||||
"sumneko_lua",
|
"sumneko_lua",
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
mason_null_ls.setup({
|
mason_null_ls.setup({
|
||||||
|
@ -29,5 +29,5 @@ mason_null_ls.setup({
|
||||||
"prettier",
|
"prettier",
|
||||||
"stylua",
|
"stylua",
|
||||||
"eslint_d",
|
"eslint_d",
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,8 @@ null_ls.setup({
|
||||||
sources = {
|
sources = {
|
||||||
formatting.prettier,
|
formatting.prettier,
|
||||||
formatting.stylua,
|
formatting.stylua,
|
||||||
diagnostics.eslint_d
|
diagnostics.eslint_d,
|
||||||
|
diagnostics.rubocop,
|
||||||
},
|
},
|
||||||
-- format on save
|
-- format on save
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
|
@ -28,4 +29,3 @@ null_ls.setup({
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ return require("packer").startup(function(use)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
use("tpope/vim-fugitive")
|
||||||
|
|
||||||
use({
|
use({
|
||||||
"folke/trouble.nvim",
|
"folke/trouble.nvim",
|
||||||
requires = "kyazdani42/nvim-web-devicons",
|
requires = "kyazdani42/nvim-web-devicons",
|
||||||
|
@ -72,6 +74,16 @@ return require("packer").startup(function(use)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
use({
|
||||||
|
"kylechui/nvim-surround",
|
||||||
|
tag = "*", -- Use for stability; omit to use `main` branch for the latest features
|
||||||
|
config = function()
|
||||||
|
require("nvim-surround").setup({
|
||||||
|
-- Configuration here, or leave empty to use defaults
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Automatically set up your configuration after cloning packer.nvim
|
-- Automatically set up your configuration after cloning packer.nvim
|
||||||
-- Put this at the end after all plugins
|
-- Put this at the end after all plugins
|
||||||
if packer_bootstrap then
|
if packer_bootstrap then
|
||||||
|
|
|
@ -1,14 +1,70 @@
|
||||||
local nnoremap = require("rahcodes.keymap").nnoremap
|
local Remap = require("rahcodes.keymap")
|
||||||
|
local nnoremap = Remap.nnoremap
|
||||||
|
local vnoremap = Remap.vnoremap
|
||||||
|
local inoremap = Remap.inoremap
|
||||||
|
local nmap = Remap.nmap
|
||||||
|
|
||||||
nnoremap("<leader>pv", "<cmd>Ex<CR>")
|
nnoremap("<leader>pv", "<cmd>Ex<CR>")
|
||||||
|
|
||||||
local builtin = require('telescope.builtin')
|
local builtin = require("telescope.builtin")
|
||||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
|
vim.keymap.set("n", "<leader>ff", builtin.find_files, {})
|
||||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
|
||||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
vim.keymap.set("n", "<leader>fb", builtin.buffers, {})
|
||||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
|
vim.keymap.set("n", "<leader>fh", builtin.help_tags, {})
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>m', builtin.oldfiles, {})
|
vim.keymap.set("n", "<leader>m", builtin.oldfiles, {})
|
||||||
vim.keymap.set('n', '<leader>gb', builtin.git_branches, {})
|
vim.keymap.set("n", "<leader>gb", builtin.git_branches, {})
|
||||||
vim.keymap.set('n', '<leader>gs', builtin.git_status, {})
|
-- vim.keymap.set('n', '<leader>gs', builtin.git_status, {})
|
||||||
vim.keymap.set('n', '<leader><leader>', builtin.git_files, {})
|
vim.keymap.set("n", "<leader><leader>", builtin.git_files, {})
|
||||||
|
|
||||||
|
-- Git Fugitive
|
||||||
|
nnoremap("<leader>gs", ":G<CR>")
|
||||||
|
nnoremap("<leader>gh", ":diffget //3<CR>")
|
||||||
|
nnoremap("<leader>gu", ":diffget //2<CR>")
|
||||||
|
nnoremap("<leader>gc", ":GCheckout<CR>")
|
||||||
|
nnoremap("<leader>ga", ":G add %:p<CR><CR>")
|
||||||
|
nnoremap("<leader>gc", ":G commit -v -q<CR>")
|
||||||
|
nnoremap("<leader>gt", ":G commit -v -q %:p<CR>")
|
||||||
|
nnoremap("<leader>gca", ":G commit --amend --no-edit<CR>")
|
||||||
|
nnoremap("<leader>gd", ":Gdiff<CR>")
|
||||||
|
nnoremap("<leader>ge", ":Gedit<CR>")
|
||||||
|
nnoremap("<leader>gr", ":Gread<CR>")
|
||||||
|
nnoremap("<leader>gw", ":Gwrite<CR><CR>")
|
||||||
|
nnoremap("<leader>gl", ":silent! Glog<CR>:bot copen<CR>")
|
||||||
|
nnoremap("<leader>gp", ":Ggrep<Space>")
|
||||||
|
nnoremap("<leader>gm", ":Gmove<Space>")
|
||||||
|
nnoremap("<leader>gb", ":G branch<Space>")
|
||||||
|
nnoremap("<leader>go", ":G checkout<Space>")
|
||||||
|
nnoremap("<leader>gps", ":Dispatch! git push<CR>")
|
||||||
|
nnoremap("<leader>gpl", ":Dispatch! git pull<CR>")
|
||||||
|
|
||||||
|
vnoremap("J", ":m '>+1<CR>gv=gv")
|
||||||
|
vnoremap("K", ":m '<-2<CR>gv=gv")
|
||||||
|
|
||||||
|
nnoremap("/", "/\v")
|
||||||
|
vnoremap("/", "/\v")
|
||||||
|
nnoremap("<leader>/", ":Rg<space>")
|
||||||
|
vnoremap("<leader>/", ":Rg<space>")
|
||||||
|
nnoremap("<leader>`", ":noh<cr>")
|
||||||
|
|
||||||
|
-- No Cheating
|
||||||
|
nnoremap("<up>", "<nop>")
|
||||||
|
nnoremap("<down>", "<nop>")
|
||||||
|
nnoremap("<left>", "<nop>")
|
||||||
|
nnoremap("<right>", "<nop>")
|
||||||
|
inoremap("<up>", "<nop>")
|
||||||
|
inoremap("<down>", "<nop>")
|
||||||
|
inoremap("<left>", "<nop>")
|
||||||
|
inoremap("<right>", "<nop>")
|
||||||
|
|
||||||
|
-- No weird line jumps
|
||||||
|
nnoremap("j", "gj")
|
||||||
|
nnoremap("k", "gk")
|
||||||
|
|
||||||
|
-- Copy to system clipboard
|
||||||
|
vnoremap("<leader>y", '"*y')
|
||||||
|
vnoremap("<leader>yy", '"+y')
|
||||||
|
|
||||||
|
-- Move buffers
|
||||||
|
nmap("sp", ":bprev<Return>")
|
||||||
|
nmap("sn", ":bnext<Return>")
|
||||||
|
|
Loading…
Reference in New Issue