Added some minor keymapings; Added terminal support
This commit is contained in:
parent
93fde0556e
commit
0ca4139007
87
init.lua
87
init.lua
|
@ -167,6 +167,65 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagn
|
|||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
|
||||
-- flsu
|
||||
--
|
||||
-- general
|
||||
--
|
||||
vim.wo.relativenumber = true
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<leader>i', '<C-]>', { noremap = true, silent = true, desc = 'find tag under cursor' })
|
||||
-- vim.keymap.set('n', '<leader>t', function()
|
||||
--
|
||||
-- clipboard
|
||||
--
|
||||
vim.g.clipboard = {
|
||||
name = 'xclip',
|
||||
copy = {
|
||||
['+'] = 'xclip -selection clipboard',
|
||||
['*'] = 'xclip -selection clipboard',
|
||||
},
|
||||
paste = {
|
||||
['+'] = 'xclip -selection clipboard -o',
|
||||
['*'] = 'xclip -selection clipboard -o',
|
||||
},
|
||||
cache_enabled = 1,
|
||||
}
|
||||
--
|
||||
-- term
|
||||
--
|
||||
local termBfr = { bufnr = nil }
|
||||
|
||||
local function openOrToggleTerminal(new_term)
|
||||
new_term = new_term or false
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
|
||||
-- If the current buffer is a terminal, hide (minimize) it
|
||||
if vim.bo[bufnr].buftype == 'terminal' then
|
||||
vim.cmd 'hide'
|
||||
return
|
||||
end
|
||||
|
||||
if termBfr.bufnr and vim.api.nvim_buf_is_loaded(termBfr.bufnr) and not new_term then
|
||||
vim.cmd 'botright split'
|
||||
vim.cmd('buffer ' .. termBfr.bufnr)
|
||||
vim.cmd 'startinsert'
|
||||
return
|
||||
end
|
||||
|
||||
-- If no terminal is found, open a new one
|
||||
vim.cmd 'botright split | terminal'
|
||||
vim.cmd 'startinsert'
|
||||
termBfr.bufnr = vim.api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
-- Map <leader>t to toggle the terminal
|
||||
vim.keymap.set('n', '<leader>t', openOrToggleTerminal, { desc = 'Toggle Terminal' })
|
||||
|
||||
-- Map <leader>nt to open a new terminal or toggle the visibility of an existing one
|
||||
vim.keymap.set('n', '<leader>nt', function()
|
||||
vim.cmd 'cd %:p:h' -- Change to the directory of the current file
|
||||
openOrToggleTerminal(true) -- Open or toggle the terminal
|
||||
end, { desc = 'Open New Terminal' })
|
||||
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
|
||||
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
|
||||
-- is not what someone will guess without a bit more experience.
|
||||
|
@ -190,6 +249,10 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
|
|||
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
||||
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
||||
|
||||
-- my custom keys flsu
|
||||
|
||||
-- vim.keymap.set('n', '<leader>t', , { desc = 'sme' })
|
||||
|
||||
-- [[ Basic Autocommands ]]
|
||||
-- See `:help lua-guide-autocommands`
|
||||
|
||||
|
@ -708,7 +771,7 @@ require('lazy').setup({
|
|||
-- <c-h> is similar, except moving you backwards.
|
||||
['<C-l>'] = cmp.mapping(function()
|
||||
if luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
luasnip.expand_or_jump(1)
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['<C-h>'] = cmp.mapping(function()
|
||||
|
@ -837,6 +900,15 @@ require('lazy').setup({
|
|||
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
|
||||
-- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins`
|
||||
-- { import = 'custom.plugins' },
|
||||
--
|
||||
-- amongst your other plugins
|
||||
{
|
||||
'akinsho/toggleterm.nvim',
|
||||
version = '*',
|
||||
config = true,
|
||||
},
|
||||
-- or
|
||||
-- 'akinsho/toggleterm.nvim', version = "*", opts = {--[[ things you want to change go here]]}}
|
||||
}, {
|
||||
ui = {
|
||||
-- If you are using a Nerd Font: set icons to an empty table which will use the
|
||||
|
@ -859,5 +931,18 @@ require('lazy').setup({
|
|||
},
|
||||
})
|
||||
|
||||
function _G.set_terminal_keymaps()
|
||||
local opts = { buffer = 0 }
|
||||
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
|
||||
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
|
||||
vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]], opts)
|
||||
end
|
||||
|
||||
vim.cmd 'autocmd! TermOpen term://* lua set_terminal_keymaps()'
|
||||
|
||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||
-- vim: ts=2 sts=2 sw=2 et
|
||||
|
|
Loading…
Reference in New Issue