Add which-key safeguard
This commit is contained in:
parent
da04b67bd4
commit
4e68e46d31
73
init.lua
73
init.lua
|
@ -31,7 +31,6 @@ end
|
|||
opt.guicursor:append('a:blinkon1000') -- Blink cursor once a second for all modes
|
||||
o.mouse = 'a' -- Enable mouse input
|
||||
o.termguicolors = true -- Enable 24bit terminal colors
|
||||
g.neovide_confirm_quit = 1 -- Confirm closing neovide window when changes are unsaved
|
||||
|
||||
-- Other interface settings
|
||||
o.clipboard = 'unnamedplus' -- Use system clipboard by default
|
||||
|
@ -75,14 +74,20 @@ if fn.executable('rg') then
|
|||
end
|
||||
|
||||
-- Convenience keybindings
|
||||
require'which-key'.register{['<C-w>!'] = {'<Cmd>copen<CR>', 'Quickfix window'}}
|
||||
require'which-key'.register{['<F2>'] = {'<Cmd>set number! relativenumber!<CR>', 'Toggle relative numbers'}}
|
||||
require'which-key'.register{['<F3>'] = {'<Cmd>set number!<CR>', 'Toggle line numbers'}}
|
||||
do
|
||||
-- which-key might not be available yet
|
||||
local ok, which_key = pcall(require, 'which-key')
|
||||
if ok then
|
||||
which_key.register{['<C-w>!'] = {'<Cmd>copen<CR>', 'Quickfix window'}}
|
||||
which_key.register{['<F2>'] = {'<Cmd>set number! relativenumber!<CR>', 'Toggle relative numbers'}}
|
||||
which_key.register{['<F3>'] = {'<Cmd>set number!<CR>', 'Toggle line numbers'}}
|
||||
|
||||
require'which-key'.register{['<A-h>'] = {'<C-w>h', 'Go to the left window'}}
|
||||
require'which-key'.register{['<A-l>'] = {'<C-w>l', 'Go to the right window'}}
|
||||
require'which-key'.register{['<A-n>'] = {'<C-w>n', 'Go to the up window'}}
|
||||
require'which-key'.register{['<A-e>'] = {'<C-w>e', 'Go to the down window'}}
|
||||
which_key.register{['<A-h>'] = {'<C-w>h', 'Go to the left window'}}
|
||||
which_key.register{['<A-l>'] = {'<C-w>l', 'Go to the right window'}}
|
||||
which_key.register{['<A-n>'] = {'<C-w>n', 'Go to the up window'}}
|
||||
which_key.register{['<A-e>'] = {'<C-w>e', 'Go to the down window'}}
|
||||
end
|
||||
end
|
||||
|
||||
-- Do workman remappings
|
||||
noremap('', 'n', 'gj')
|
||||
|
@ -94,6 +99,9 @@ noremap('', 'k', 'e')
|
|||
vim.cmd [[
|
||||
command! Light colorscheme base16-atelier-sulphurpool-light
|
||||
command! Dark colorscheme nord
|
||||
|
||||
" Perform file as the root user
|
||||
"cmap w!! w !sudo tee > /dev/null %
|
||||
]]
|
||||
|
||||
-- Autocommands
|
||||
|
@ -110,32 +118,13 @@ au BufReadPost *
|
|||
" Highlight yanked text
|
||||
au TextYankPost * silent! lua vim.highlight.on_yank()
|
||||
|
||||
au User StartifyReady noremap <buffer> n gj| noremap <buffer> e gk
|
||||
au User Startified noremap <buffer> n j | noremap <buffer> e k
|
||||
|
||||
" Recompile plugin config cache when vimrc is updated
|
||||
au BufWritePost */.config/nvim/init.lua source <afile> | PackerCompile
|
||||
|
||||
augroup END
|
||||
]]
|
||||
--local au = vim.api.nvim_create_augroup
|
||||
--local augroup = vim.api.nvim_create_augroup('luarc', {clear = true})
|
||||
--au('User', { pattern = 'StartifyReady', group = augroup, callback = function(cmd)
|
||||
-- vim.keymap.set('', 'n', 'gj', {silent = true, buffer = true})
|
||||
-- vim.keymap.set('', 'e', 'gk', {silent = true, buffer = true})
|
||||
--end})
|
||||
--au('BufWritePost', {
|
||||
-- pattern = '*/.config/nvim/init.lua',
|
||||
-- group = augroup,
|
||||
-- command = 'source <afile> | PackerCompile'
|
||||
--})
|
||||
--au('TextYankPost', { pattern = '*', group = augroup, callback = vim.highlight.on_yank })
|
||||
--au('BufWritePost', { pattern = '*/.config/nvim/init.lua', command = 'source <afile> | PackerCompile' })
|
||||
--au('BufReadPost', { pattern = '*', group = augroup, command = function()
|
||||
-- local line = vim.fn.line
|
||||
-- if line[['\"]] > 1 && line[['\"]] <= line'$' && o.ft ~= 'commit' then
|
||||
-- vim.cmd'normal g`"'
|
||||
-- end
|
||||
--end })
|
||||
|
||||
-- Diagnostics
|
||||
vim.diagnostic.config {
|
||||
|
@ -237,21 +226,7 @@ require'packer'.startup(function(use)
|
|||
use 'vim-airline/vim-airline'
|
||||
use 'vim-airline/vim-airline-themes'
|
||||
use 'romgrk/barbar.nvim'
|
||||
use {'MattesGroeger/vim-bookmarks', config = function()
|
||||
vim.g.bookmark_save_per_working_dir = 1
|
||||
end}
|
||||
use {'stevearc/dressing.nvim', config = function()
|
||||
vim.cmd'highlight link FloatTitle TelescopeBorder'
|
||||
require'dressing'.setup {
|
||||
input = {
|
||||
winhighlight = 'NormalFloat:TelescopeNormal,FloatBorder:TelescopeBorder'
|
||||
},
|
||||
select = {
|
||||
enabled = false,
|
||||
telescope = require'telescope.themes'.get_cursor()
|
||||
},
|
||||
}
|
||||
end}
|
||||
use 'MattesGroeger/vim-bookmarks'
|
||||
use 'j-hui/fidget.nvim'
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'tpope/vim-rhubarb'
|
||||
|
@ -274,7 +249,7 @@ require'packer'.startup(function(use)
|
|||
require'stabilize'.setup()
|
||||
end}
|
||||
use 'mhinz/vim-startify'
|
||||
use {'nvim-telescope/telescope.nvim', after = 'which-key.nvim', config = function()
|
||||
use {'nvim-telescope/telescope.nvim', config = function()
|
||||
require'telescope'.setup {
|
||||
defaults = {
|
||||
sorting_strategy = 'ascending',
|
||||
|
@ -302,7 +277,7 @@ require'packer'.startup(function(use)
|
|||
full_path = true,
|
||||
},
|
||||
['ui-select'] = {
|
||||
require'telescope.themes'.get_cursor()
|
||||
require'telescope.themes'.get_dropdown({layout_strategy = 'cursor'})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -310,7 +285,7 @@ require'packer'.startup(function(use)
|
|||
["<Leader>f"] = {
|
||||
name = 'Telescope',
|
||||
["<Space>"] = {'<Cmd>Telescope<CR>', 'List pickers'},
|
||||
f = {'<Cmd>Telescope find_files<CR>', 'Files'},
|
||||
f = {'<Cmd>Telescope find_files hidden=true<CR>', 'Files'},
|
||||
d = {'<Cmd>Telescope find_files find_command=fd,--type,d,-I<CR>', 'Directories'},
|
||||
r = {'<Cmd>Telescope oldfiles<CR>', 'Recent files'},
|
||||
g = {'<Cmd>Telescope live_grep<CR>', 'Grep'},
|
||||
|
@ -350,7 +325,6 @@ require'packer'.startup(function(use)
|
|||
-- Finish bootstrap if we just cloned
|
||||
if packer_bootstrap then
|
||||
require('packer').sync()
|
||||
vim.notify('Bootstrapped plugin manager, you may need to restart neovim')
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -726,11 +700,6 @@ require('nvim-tree').setup {
|
|||
}
|
||||
}
|
||||
vim.cmd'highlight NvimTreeOpenedFile guifg=NONE gui=italic'
|
||||
vim.api.nvim_create_autocmd('ColorScheme', {
|
||||
group = 'vimrc',
|
||||
desc = 'Change NvimTreeOpenedFile highlight',
|
||||
command = 'highlight NvimTreeOpenedFile guifg=NONE gui=italic'
|
||||
})
|
||||
|
||||
require'which-key'.register{['<Leader>t'] = {'<Cmd>NvimTreeToggle<CR>', 'Nvim Tree'}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue