[neovim] Give key bindings a little love; add GUI bindings for neovide
- Clean up the init interface. Move all the init methods into a single init_all() call. - Add two keybindings for <M-j> and <M-k> to move by soft-wrapped lines in Normal mode - Add a few key bindings for the usual shortcuts for cut/copy/paste when in GUI mode. In vim, D is the character that represents the Super/Apple key. So, <D-x>, <D-c>, and <D-v> now do what you'd expect.
This commit is contained in:
parent
31215aadbf
commit
534d9a102b
3 changed files with 38 additions and 9 deletions
|
@ -56,10 +56,7 @@ require 'treesitter'
|
||||||
require 'lsp'
|
require 'lsp'
|
||||||
|
|
||||||
local keys = require 'keys'
|
local keys = require 'keys'
|
||||||
keys.init_key_opts()
|
keys.init()
|
||||||
keys.init_window_key_mappings()
|
|
||||||
keys.init_diagnostic_key_mappings()
|
|
||||||
keys.init_telescope_mappings()
|
|
||||||
|
|
||||||
local gui = require 'gui'
|
local gui = require 'gui'
|
||||||
gui.init()
|
gui.init()
|
||||||
|
|
|
@ -5,10 +5,13 @@ local function _init_neovide()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- No use for these animations.
|
||||||
vim.g.neovide_cursor_animation_length = 0
|
vim.g.neovide_cursor_animation_length = 0
|
||||||
vim.g.neovide_position_animation_length = 0
|
vim.g.neovide_position_animation_length = 0
|
||||||
vim.g.neovide_scroll_animation_length = 0
|
vim.g.neovide_scroll_animation_length = 0
|
||||||
|
|
||||||
|
vim.g.neovide_input_macos_option_key_is_meta = "both"
|
||||||
|
|
||||||
vim.cmd [[ colorscheme lunaperche ]]
|
vim.cmd [[ colorscheme lunaperche ]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,33 @@
|
||||||
|
|
||||||
local map = vim.keymap.set
|
local map = vim.keymap.set
|
||||||
|
|
||||||
local function init_key_opts()
|
local function init_key_options()
|
||||||
vim.g.mapleader = ","
|
vim.g.mapleader = ","
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function navigation_mappings()
|
||||||
|
local options = { noremap = true }
|
||||||
|
|
||||||
|
-- Navigate by soft-wrapped lines using Alt/Option/Meta + jk
|
||||||
|
map({'n', 'v'}, '<M-k>', 'gk', options)
|
||||||
|
map({'n', 'v'}, '<M-j>', 'gj', options)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function clipboard_mappings()
|
||||||
|
if not vim.fn.has('gui_running') then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = { noremap = true }
|
||||||
|
|
||||||
|
-- Copy to the system clipboard
|
||||||
|
map('v', '<D-c>', '"+y', options)
|
||||||
|
-- Cut to the system clipboard
|
||||||
|
map('v', '<D-x>', '"+x', options)
|
||||||
|
-- Paste from the system clipboard
|
||||||
|
map({'i', 'v'}, '<D-v>', '"+p', options)
|
||||||
|
end
|
||||||
|
|
||||||
local function window_key_mappings()
|
local function window_key_mappings()
|
||||||
local options = { silent = true }
|
local options = { silent = true }
|
||||||
|
|
||||||
|
@ -70,10 +93,16 @@ local function telescope_mappings()
|
||||||
map('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
|
map('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function init_all_global_keybindings()
|
||||||
|
init_key_options()
|
||||||
|
clipboard_mappings()
|
||||||
|
window_key_mappings()
|
||||||
|
navigation_mappings()
|
||||||
|
diagnostic_mappings()
|
||||||
|
telescope_mappings()
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init_key_opts = init_key_opts,
|
init = init_all_global_keybindings,
|
||||||
init_window_key_mappings = window_key_mappings,
|
|
||||||
init_diagnostic_key_mappings = diagnostic_mappings,
|
|
||||||
init_lsp_key_mappings = local_lsp_mappings,
|
init_lsp_key_mappings = local_lsp_mappings,
|
||||||
init_telescope_mappings = telescope_mappings,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue