mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
[Refactor] Allow editing default keymaps (#1213)
This commit is contained in:
parent
e0f0c81ea6
commit
77e283bd9c
11 changed files with 246 additions and 171 deletions
31
README.md
31
README.md
|
@ -78,8 +78,26 @@ lvim.colorscheme = "spacegray"
|
||||||
|
|
||||||
lvim.builtin.compe.autocomplete = true
|
lvim.builtin.compe.autocomplete = true
|
||||||
|
|
||||||
-- keymappings
|
-- keymappings [view all the defaults by pressing <leader>Lk]
|
||||||
lvim.leader = "space"
|
lvim.leader = "space"
|
||||||
|
-- add your own keymapping
|
||||||
|
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
|
||||||
|
-- unmap a default keymapping
|
||||||
|
-- lvim.keys.normal_mode["<C-Up>"] = ""
|
||||||
|
-- edit a default keymapping
|
||||||
|
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>"
|
||||||
|
|
||||||
|
-- Use which-key to add extra bindings with the leader-key prefix
|
||||||
|
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>lua require'telescope'.extensions.project.project{}<CR>", "Projects" }
|
||||||
|
-- lvim.builtin.which_key.mappings["t"] = {
|
||||||
|
-- name = "+Trouble",
|
||||||
|
-- r = { "<cmd>Trouble lsp_references<cr>", "References" },
|
||||||
|
-- f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
|
||||||
|
-- d = { "<cmd>Trouble lsp_document_diagnostics<cr>", "Diagnosticss" },
|
||||||
|
-- q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
|
||||||
|
-- l = { "<cmd>Trouble loclist<cr>", "LocationList" },
|
||||||
|
-- w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Diagnosticss" },
|
||||||
|
-- }
|
||||||
|
|
||||||
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
|
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
|
||||||
lvim.builtin.dashboard.active = true
|
lvim.builtin.dashboard.active = true
|
||||||
|
@ -123,17 +141,6 @@ lvim.plugins = {
|
||||||
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" },
|
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" },
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
-- Additional Leader bindings for WhichKey
|
|
||||||
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>lua require'telescope'.extensions.project.project{}<CR>", "Projects" }
|
|
||||||
-- lvim.builtin.which_key.mappings["t"] = {
|
|
||||||
-- name = "+Trouble",
|
|
||||||
-- r = { "<cmd>Trouble lsp_references<cr>", "References" },
|
|
||||||
-- f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
|
|
||||||
-- d = { "<cmd>Trouble lsp_document_diagnostics<cr>", "Diagnosticss" },
|
|
||||||
-- q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
|
|
||||||
-- l = { "<cmd>Trouble loclist<cr>", "LocationList" },
|
|
||||||
-- w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Diagnosticss" },
|
|
||||||
-- }
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
7
init.lua
7
init.lua
|
@ -42,11 +42,6 @@ end
|
||||||
require("settings").load_commands()
|
require("settings").load_commands()
|
||||||
autocmds.define_augroups(lvim.autocommands)
|
autocmds.define_augroups(lvim.autocommands)
|
||||||
|
|
||||||
local keymap = require "utils.keymap"
|
|
||||||
local default_keymaps = require "keymappings"
|
|
||||||
keymap.load(default_keymaps.keymaps, default_keymaps.opts)
|
|
||||||
keymap.load(lvim.keys, default_keymaps.opts)
|
|
||||||
|
|
||||||
local plugins = require "plugins"
|
local plugins = require "plugins"
|
||||||
local plugin_loader = require("plugin-loader").init()
|
local plugin_loader = require("plugin-loader").init()
|
||||||
plugin_loader:load { plugins, lvim.plugins }
|
plugin_loader:load { plugins, lvim.plugins }
|
||||||
|
@ -73,6 +68,8 @@ if lsp_settings_status_ok then
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require("keymappings").setup()
|
||||||
|
|
||||||
-- TODO: these guys need to be in language files
|
-- TODO: these guys need to be in language files
|
||||||
-- if lvim.lang.emmet.active then
|
-- if lvim.lang.emmet.active then
|
||||||
-- require "lsp.emmet-ls"
|
-- require "lsp.emmet-ls"
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
lvim.builtin.bufferline = {
|
lvim.builtin.bufferline = {
|
||||||
keymap = {
|
keymap = {
|
||||||
values = {
|
|
||||||
normal_mode = {
|
normal_mode = {
|
||||||
["<S-l>"] = { ":BufferNext<CR>" },
|
["<S-l>"] = ":BufferNext<CR>",
|
||||||
["<S-h>"] = { ":BufferPrevious<CR>" },
|
["<S-h>"] = ":BufferPrevious<CR>",
|
||||||
},
|
|
||||||
},
|
|
||||||
opts = {
|
|
||||||
normal_mode = { noremap = true, silent = true },
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local keymap = require "utils.keymap"
|
local keymap = require "keymappings"
|
||||||
keymap.load(lvim.builtin.bufferline.keymap.values, lvim.builtin.bufferline.keymap.opts)
|
keymap.append_to_defaults(lvim.builtin.bufferline.keymap)
|
||||||
|
|
|
@ -42,12 +42,12 @@ M.config = function()
|
||||||
keymap = {
|
keymap = {
|
||||||
values = {
|
values = {
|
||||||
insert_mode = {
|
insert_mode = {
|
||||||
["<Tab>"] = { 'pumvisible() ? "<C-n>" : "<Tab>"' },
|
["<Tab>"] = 'pumvisible() ? "<C-n>" : "<Tab>"',
|
||||||
["<S-Tab>"] = { 'pumvisible() ? "<C-p>" : "<S-Tab>"' },
|
["<S-Tab>"] = 'pumvisible() ? "<C-p>" : "<S-Tab>"',
|
||||||
["<C-Space>"] = { "compe#complete()" },
|
["<C-Space>"] = "compe#complete()",
|
||||||
["<C-e>"] = { "compe#close('<C-e>')" },
|
["<C-e>"] = "compe#close('<C-e>')",
|
||||||
["<C-f>"] = { "compe#scroll({ 'delta': +4 })" },
|
["<C-f>"] = "compe#scroll({ 'delta': +4 })",
|
||||||
["<C-d>"] = { "compe#scroll({ 'delta': -4 })" },
|
["<C-d>"] = "compe#scroll({ 'delta': -4 })",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
|
@ -105,7 +105,7 @@ M.setup = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local keymap = require "utils.keymap"
|
local keymap = require "keymappings"
|
||||||
keymap.load(lvim.builtin.compe.keymap.values, lvim.builtin.compe.keymap.opts)
|
keymap.load(lvim.builtin.compe.keymap.values, lvim.builtin.compe.keymap.opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,10 @@ M.config = function()
|
||||||
"Workspace Symbols",
|
"Workspace Symbols",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
L = {
|
||||||
|
name = "+LunarVim",
|
||||||
|
k = { "<cmd>lua require('keymappings').print()<cr>", "View LunarVim's default keymappings" },
|
||||||
|
},
|
||||||
|
|
||||||
s = {
|
s = {
|
||||||
name = "Search",
|
name = "Search",
|
||||||
|
|
|
@ -1237,6 +1237,7 @@ lvim.lang = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require("keymappings").config()
|
||||||
require("core.which-key").config()
|
require("core.which-key").config()
|
||||||
require "core.status_colors"
|
require "core.status_colors"
|
||||||
require("core.gitsigns").config()
|
require("core.gitsigns").config()
|
||||||
|
|
|
@ -1,109 +1,157 @@
|
||||||
local opts = {
|
local M = {}
|
||||||
insert_mode = { noremap = true, silent = true },
|
|
||||||
normal_mode = { noremap = true, silent = true },
|
local generic_opts_any = { noremap = true, silent = true }
|
||||||
visual_mode = { noremap = true, silent = true },
|
|
||||||
visual_block_mode = { noremap = true, silent = true },
|
local mode_adapters = {
|
||||||
term_mode = { silent = true },
|
insert_mode = "i",
|
||||||
|
normal_mode = "n",
|
||||||
|
term_mode = "t",
|
||||||
|
visual_mode = "v",
|
||||||
|
visual_block_mode = "x",
|
||||||
}
|
}
|
||||||
|
|
||||||
local keymaps = {
|
-- Append key mappings to lunarvim's defaults for a given mode
|
||||||
|
-- @param keymaps The table of key mappings containing a list per mode (normal_mode, insert_mode, ..)
|
||||||
|
function M.append_to_defaults(keymaps)
|
||||||
|
for mode, mappings in pairs(keymaps) do
|
||||||
|
for k, v in ipairs(mappings) do
|
||||||
|
lvim.keys[mode][k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Load key mappings for a given mode
|
||||||
|
-- @param mode The keymap mode, can be one of the keys of mode_adapters
|
||||||
|
-- @param keymaps The list of key mappings
|
||||||
|
-- @param opts The mapping options
|
||||||
|
function M.load_mode(mode, keymaps, opts)
|
||||||
|
mode = mode_adapters[mode] and mode_adapters[mode] or mode
|
||||||
|
for k, v in pairs(keymaps) do
|
||||||
|
vim.api.nvim_set_keymap(mode, k, v, opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Load key mappings for all provided modes
|
||||||
|
-- @param keymaps A list of key mappings for each mode
|
||||||
|
-- @param opts The mapping options for each mode
|
||||||
|
function M.load(keymaps, opts)
|
||||||
|
for mode, mapping in pairs(keymaps) do
|
||||||
|
M.load_mode(mode, mapping, opts[mode])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.config()
|
||||||
|
lvim.keys = {
|
||||||
|
---@usage change or add keymappings for insert mode
|
||||||
insert_mode = {
|
insert_mode = {
|
||||||
-- I hate escape
|
-- 'jk' for quitting insert mode
|
||||||
["jk"] = { "<ESC>" },
|
["jk"] = "<ESC>",
|
||||||
["kj"] = { "<ESC>" },
|
-- 'kj' for quitting insert mode
|
||||||
["jj"] = { "<ESC>" },
|
["kj"] = "<ESC>",
|
||||||
|
-- 'jj' for quitting insert mode
|
||||||
|
["jj"] = "<ESC>",
|
||||||
-- Move current line / block with Alt-j/k ala vscode.
|
-- Move current line / block with Alt-j/k ala vscode.
|
||||||
["<A-j>"] = { "<Esc>:m .+1<CR>==gi" },
|
["<A-j>"] = "<Esc>:m .+1<CR>==gi",
|
||||||
["<A-k>"] = { "<Esc>:m .-2<CR>==gi" },
|
-- Move current line / block with Alt-j/k ala vscode.
|
||||||
|
["<A-k>"] = "<Esc>:m .-2<CR>==gi",
|
||||||
-- navigation
|
-- navigation
|
||||||
["<A-Up>"] = { "<C-\\><C-N><C-w>k" },
|
["<A-Up>"] = "<C-\\><C-N><C-w>k",
|
||||||
["<A-Down>"] = { "<C-\\><C-N><C-w>j" },
|
["<A-Down>"] = "<C-\\><C-N><C-w>j",
|
||||||
["<A-Left>"] = { "<C-\\><C-N><C-w>h" },
|
["<A-Left>"] = "<C-\\><C-N><C-w>h",
|
||||||
["<A-Right>"] = { "<C-\\><C-N><C-w>l" },
|
["<A-Right>"] = "<C-\\><C-N><C-w>l",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
---@usage change or add keymappings for normal mode
|
||||||
normal_mode = {
|
normal_mode = {
|
||||||
-- Better window movement
|
-- Better window movement
|
||||||
["<C-h>"] = { "<C-w>h" },
|
["<C-h>"] = "<C-w>h",
|
||||||
["<C-j>"] = { "<C-w>j" },
|
["<C-j>"] = "<C-w>j",
|
||||||
["<C-k>"] = { "<C-w>k" },
|
["<C-k>"] = "<C-w>k",
|
||||||
["<C-l>"] = { "<C-w>l" },
|
["<C-l>"] = "<C-w>l",
|
||||||
|
|
||||||
-- Resize with arrows
|
-- Resize with arrows
|
||||||
["<C-Up>"] = { ":resize -2<CR>" },
|
["<C-Up>"] = ":resize -2<CR>",
|
||||||
["<C-Down>"] = { ":resize +2<CR>" },
|
["<C-Down>"] = ":resize +2<CR>",
|
||||||
["<C-Left>"] = { ":vertical resize -2<CR>" },
|
["<C-Left>"] = ":vertical resize -2<CR>",
|
||||||
["<C-Right>"] = { ":vertical resize +2<CR>" },
|
["<C-Right>"] = ":vertical resize +2<CR>",
|
||||||
|
|
||||||
-- Tab switch buffer
|
-- Tab switch buffer
|
||||||
-- { "<TAB>", ":bnext<CR>" },
|
["<S-l>"] = ":BufferNext<CR>",
|
||||||
-- { "<S-TAB>", ":bprevious<CR>" },
|
["<S-h>"] = ":BufferPrevious<CR>",
|
||||||
|
|
||||||
-- Move current line / block with Alt-j/k a la vscode.
|
-- Move current line / block with Alt-j/k a la vscode.
|
||||||
["<A-j>"] = { ":m .+1<CR>==" },
|
["<A-j>"] = ":m .+1<CR>==",
|
||||||
["<A-k>"] = { ":m .-2<CR>==" },
|
["<A-k>"] = ":m .-2<CR>==",
|
||||||
|
|
||||||
-- QuickFix
|
-- QuickFix
|
||||||
["]q"] = { ":cnext<CR>" },
|
["]q"] = ":cnext<CR>",
|
||||||
["[q"] = { ":cprev<CR>" },
|
["[q"] = ":cprev<CR>",
|
||||||
["<C-q>"] = { ":call QuickFixToggle()<CR>" },
|
["<C-q>"] = ":call QuickFixToggle()<CR>",
|
||||||
|
|
||||||
-- {'<C-TAB>', 'compe#complete()', {noremap = true, silent = true, expr = true}},
|
|
||||||
|
|
||||||
-- LSP
|
|
||||||
["gd"] = { "<cmd>lua vim.lsp.buf.definition()<CR>" },
|
|
||||||
["gD"] = { "<cmd>lua vim.lsp.buf.declaration()<CR>" },
|
|
||||||
["gr"] = { "<cmd>lua vim.lsp.buf.references()<CR>" },
|
|
||||||
["gi"] = { "<cmd>lua vim.lsp.buf.implementation()<CR>" },
|
|
||||||
["gl"] = { "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })<CR>" },
|
|
||||||
["gs"] = { "<cmd>lua vim.lsp.buf.signature_help()<CR>" },
|
|
||||||
["gp"] = { "<cmd>lua require'lsp.peek'.Peek('definition')<CR>" },
|
|
||||||
["K"] = { "<cmd>lua vim.lsp.buf.hover()<CR>" },
|
|
||||||
["<C-p>"] = { "<cmd>lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})<CR>" },
|
|
||||||
["<C-n>"] = { "<cmd>lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})<CR>" },
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
---@usage change or add keymappings for terminal mode
|
||||||
term_mode = {
|
term_mode = {
|
||||||
-- Terminal window navigation
|
-- Terminal window navigation
|
||||||
["<C-h>"] = { "<C-\\><C-N><C-w>h" },
|
["<C-h>"] = "<C-\\><C-N><C-w>h",
|
||||||
["<C-j>"] = { "<C-\\><C-N><C-w>j" },
|
["<C-j>"] = "<C-\\><C-N><C-w>j",
|
||||||
["<C-k>"] = { "<C-\\><C-N><C-w>k" },
|
["<C-k>"] = "<C-\\><C-N><C-w>k",
|
||||||
["<C-l>"] = { "<C-\\><C-N><C-w>l" },
|
["<C-l>"] = "<C-\\><C-N><C-w>l",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
---@usage change or add keymappings for visual mode
|
||||||
visual_mode = {
|
visual_mode = {
|
||||||
-- Better indenting
|
-- Better indenting
|
||||||
["<"] = { "<gv" },
|
["<"] = "<gv",
|
||||||
[">"] = { ">gv" },
|
[">"] = ">gv",
|
||||||
|
|
||||||
-- { "p", '"0p', { silent = true } },
|
-- ["p"] = '"0p',
|
||||||
-- { "P", '"0P', { silent = true } },
|
-- ["P"] = '"0P',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
---@usage change or add keymappings for visual block mode
|
||||||
visual_block_mode = {
|
visual_block_mode = {
|
||||||
-- Move selected line / block of text in visual mode
|
-- Move selected line / block of text in visual mode
|
||||||
["K"] = { ":move '<-2<CR>gv-gv" },
|
["K"] = ":move '<-2<CR>gv-gv",
|
||||||
["J"] = { ":move '>+1<CR>gv-gv" },
|
["J"] = ":move '>+1<CR>gv-gv",
|
||||||
|
|
||||||
-- Move current line / block with Alt-j/k ala vscode.
|
-- Move current line / block with Alt-j/k ala vscode.
|
||||||
["<A-j>"] = { ":m '>+1<CR>gv-gv" },
|
["<A-j>"] = ":m '>+1<CR>gv-gv",
|
||||||
["<A-k>"] = { ":m '<-2<CR>gv-gv" },
|
["<A-k>"] = ":m '<-2<CR>gv-gv",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if vim.fn.has "mac" == 1 then
|
if vim.fn.has "mac" == 1 then
|
||||||
-- TODO: fix this
|
lvim.keys.normal_mode["<A-Up>"] = lvim.keys.normal_mode["<C-Up>"]
|
||||||
keymaps.normal_mode["<A-Up>"] = keymaps.normal_mode["<C-Up>"]
|
lvim.keys.normal_mode["<A-Down>"] = lvim.keys.normal_mode["<C-Down>"]
|
||||||
keymaps.normal_mode["<A-Down>"] = keymaps.normal_mode["<C-Down>"]
|
lvim.keys.normal_mode["<A-Left>"] = lvim.keys.normal_mode["<C-Left>"]
|
||||||
keymaps.normal_mode["<A-Left>"] = keymaps.normal_mode["<C-Left>"]
|
lvim.keys.normal_mode["<A-Right>"] = lvim.keys.normal_mode["<C-Right>"]
|
||||||
keymaps.normal_mode["<A-Right>"] = keymaps.normal_mode["<C-Right>"]
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader
|
function M.print(mode)
|
||||||
|
print "List of LunarVim's default keymappings (not including which-key)"
|
||||||
|
if mode then
|
||||||
|
print(vim.inspect(lvim.keys[mode]))
|
||||||
|
else
|
||||||
|
print(vim.inspect(lvim.keys))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
-- navigate tab completion with <c-j> and <c-k>
|
-- navigate tab completion with <c-j> and <c-k>
|
||||||
-- runs conditionally
|
-- runs conditionally
|
||||||
vim.cmd 'inoremap <expr> <C-j> pumvisible() ? "\\<C-n>" : "\\<C-j>"'
|
vim.cmd 'inoremap <expr> <C-j> pumvisible() ? "\\<C-n>" : "\\<C-j>"'
|
||||||
vim.cmd 'inoremap <expr> <C-k> pumvisible() ? "\\<C-p>" : "\\<C-k>"'
|
vim.cmd 'inoremap <expr> <C-k> pumvisible() ? "\\<C-p>" : "\\<C-k>"'
|
||||||
|
local generic_opts = {
|
||||||
|
insert_mode = generic_opts_any,
|
||||||
|
normal_mode = generic_opts_any,
|
||||||
|
visual_mode = generic_opts_any,
|
||||||
|
visual_block_mode = generic_opts_any,
|
||||||
|
term_mode = { silent = true },
|
||||||
|
}
|
||||||
|
|
||||||
return { keymaps = keymaps, opts = opts }
|
vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader
|
||||||
|
M.load(lvim.keys, generic_opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
|
|
|
@ -33,6 +33,24 @@ local function lsp_highlight_document(client)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function add_lsp_buffer_keybindings(bufnr)
|
||||||
|
local wk = require "which-key"
|
||||||
|
local keys = {
|
||||||
|
["K"] = { "<cmd>lua vim.lsp.buf.hover()<CR>", "Show hover" },
|
||||||
|
["gd"] = { "<cmd>lua vim.lsp.buf.definition()<CR>", "Goto Definition" },
|
||||||
|
["gD"] = { "<cmd>lua vim.lsp.buf.declaration()<CR>", "Goto declaration" },
|
||||||
|
["gr"] = { "<cmd>lua vim.lsp.buf.references()<CR>", "Goto references" },
|
||||||
|
["gi"] = { "<cmd>lua vim.lsp.buf.implementation()<CR>", "Goto implementation" },
|
||||||
|
["gs"] = { "<cmd>lua vim.lsp.buf.signature_help()<CR>", "show signature help" },
|
||||||
|
["gp"] = { "<cmd>lua require'lsp.peek'.Peek('definition')<CR>", "Peek definition" },
|
||||||
|
["gl"] = {
|
||||||
|
"<cmd>lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })<CR>",
|
||||||
|
"Show line diagnostics",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
wk.register(keys, { mode = "n", buffer = bufnr })
|
||||||
|
end
|
||||||
|
|
||||||
function M.common_capabilities()
|
function M.common_capabilities()
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
@ -64,6 +82,7 @@ function M.common_on_attach(client, bufnr)
|
||||||
lvim.lsp.on_attach_callback(client, bufnr)
|
lvim.lsp.on_attach_callback(client, bufnr)
|
||||||
end
|
end
|
||||||
lsp_highlight_document(client)
|
lsp_highlight_document(client)
|
||||||
|
add_lsp_buffer_keybindings(bufnr)
|
||||||
require("lsp.null-ls").setup(vim.bo.filetype)
|
require("lsp.null-ls").setup(vim.bo.filetype)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ function utils.reload_lv_config()
|
||||||
plugin_loader:load { plugins, lvim.plugins }
|
plugin_loader:load { plugins, lvim.plugins }
|
||||||
vim.cmd ":PackerCompile"
|
vim.cmd ":PackerCompile"
|
||||||
vim.cmd ":PackerInstall"
|
vim.cmd ":PackerInstall"
|
||||||
|
require("keymappings").setup()
|
||||||
-- vim.cmd ":PackerClean"
|
-- vim.cmd ":PackerClean"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,17 +5,25 @@ lvim.format_on_save = true
|
||||||
lvim.lint_on_save = true
|
lvim.lint_on_save = true
|
||||||
lvim.colorscheme = "spacegray"
|
lvim.colorscheme = "spacegray"
|
||||||
|
|
||||||
-- keymappings
|
-- keymappings [view all the defaults by pressing <leader>Lk]
|
||||||
lvim.leader = "space"
|
lvim.leader = "space"
|
||||||
-- overwrite/augment the key-mappings provided by LunarVim for any mode, or leave empty to keep the defaults.
|
-- add your own keymapping
|
||||||
-- lvim.keys.normal_mode = {
|
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
|
||||||
-- -- Page down/up
|
-- unmap a default keymapping
|
||||||
-- ["[d"] = { "<PageUp>" },
|
-- lvim.keys.normal_mode["<C-Up>"] = ""
|
||||||
-- ["]d"] = { "<PageDown>" },
|
-- edit a default keymapping
|
||||||
--
|
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>"
|
||||||
-- -- Navigate buffers
|
|
||||||
-- ["<Tab>"] = { ":bnext<CR>" },
|
-- Use which-key to add extra bindings with the leader-key prefix
|
||||||
-- ["<S-Tab>"] = { ":bprevious<CR>" },
|
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>lua require'telescope'.extensions.project.project{}<CR>", "Projects" }
|
||||||
|
-- lvim.builtin.which_key.mappings["t"] = {
|
||||||
|
-- name = "+Trouble",
|
||||||
|
-- r = { "<cmd>Trouble lsp_references<cr>", "References" },
|
||||||
|
-- f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
|
||||||
|
-- d = { "<cmd>Trouble lsp_document_diagnostics<cr>", "Diagnosticss" },
|
||||||
|
-- q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
|
||||||
|
-- l = { "<cmd>Trouble loclist<cr>", "LocationList" },
|
||||||
|
-- w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Diagnosticss" },
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
-- TODO: User Config for predefined plugins
|
-- TODO: User Config for predefined plugins
|
||||||
|
@ -69,5 +77,3 @@ lvim.builtin.treesitter.highlight.enabled = true
|
||||||
-- lvim.autocommands.custom_groups = {
|
-- lvim.autocommands.custom_groups = {
|
||||||
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" },
|
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" },
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
-- Additional Leader bindings for WhichKey
|
|
||||||
|
|
|
@ -13,17 +13,26 @@ an executable
|
||||||
lvim.format_on_save = true
|
lvim.format_on_save = true
|
||||||
lvim.lint_on_save = true
|
lvim.lint_on_save = true
|
||||||
lvim.colorscheme = "spacegray"
|
lvim.colorscheme = "spacegray"
|
||||||
-- keymappings
|
|
||||||
|
-- keymappings [view all the defaults by pressing <leader>Lk]
|
||||||
lvim.leader = "space"
|
lvim.leader = "space"
|
||||||
-- overwrite/augment the key-mappings provided by LunarVim for any mode, or leave empty to keep the defaults.
|
-- add your own keymapping
|
||||||
-- lvim.keys.normal_mode = {
|
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
|
||||||
-- -- Page down/up
|
-- unmap a default keymapping
|
||||||
-- ["[d"] = { "<PageUp>" },
|
-- lvim.keys.normal_mode["<C-Up>"] = ""
|
||||||
-- ["]d"] = { "<PageDown>" },
|
-- edit a default keymapping
|
||||||
--
|
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>"
|
||||||
-- -- Navigate buffers
|
|
||||||
-- ["<Tab>"] = { ":bnext<CR>" },
|
-- Use which-key to add extra bindings with the leader-key prefix
|
||||||
-- ["<S-Tab>"] = { ":bprevious<CR>" },
|
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>lua require'telescope'.extensions.project.project{}<CR>", "Projects" }
|
||||||
|
-- lvim.builtin.which_key.mappings["t"] = {
|
||||||
|
-- name = "+Trouble",
|
||||||
|
-- r = { "<cmd>Trouble lsp_references<cr>", "References" },
|
||||||
|
-- f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
|
||||||
|
-- d = { "<cmd>Trouble lsp_document_diagnostics<cr>", "Diagnosticss" },
|
||||||
|
-- q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
|
||||||
|
-- l = { "<cmd>Trouble loclist<cr>", "LocationList" },
|
||||||
|
-- w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Diagnosticss" },
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
-- TODO: User Config for predefined plugins
|
-- TODO: User Config for predefined plugins
|
||||||
|
@ -77,15 +86,3 @@ lvim.builtin.treesitter.highlight.enabled = true
|
||||||
-- lvim.autocommands.custom_groups = {
|
-- lvim.autocommands.custom_groups = {
|
||||||
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" },
|
-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" },
|
||||||
-- }
|
-- }
|
||||||
|
|
||||||
-- Additional Leader bindings for WhichKey
|
|
||||||
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>lua require'telescope'.extensions.project.project{}<CR>", "Projects" }
|
|
||||||
-- lvim.builtin.which_key.mappings["t"] = {
|
|
||||||
-- name = "+Trouble",
|
|
||||||
-- r = { "<cmd>Trouble lsp_references<cr>", "References" },
|
|
||||||
-- f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
|
|
||||||
-- d = { "<cmd>Trouble lsp_document_diagnostics<cr>", "Diagnosticss" },
|
|
||||||
-- q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
|
|
||||||
-- l = { "<cmd>Trouble loclist<cr>", "LocationList" },
|
|
||||||
-- w = { "<cmd>Trouble lsp_workspace_diagnostics<cr>", "Diagnosticss" },
|
|
||||||
-- }
|
|
||||||
|
|
Loading…
Reference in a new issue