neovim part 6
This commit is contained in:
parent
d8c82c966b
commit
97482df1a5
14 changed files with 258 additions and 194 deletions
|
@ -3,7 +3,10 @@
|
|||
"auto-session": { "branch": "main", "commit": "00334ee24b9a05001ad50221c8daffbeedaa0842" },
|
||||
"autoclose.nvim": { "branch": "main", "commit": "b2077aa2c83df7ebc19b2a20a3a0654b24ae9c8f" },
|
||||
"blink.cmp": { "branch": "main", "commit": "cb5e346d9e0efa7a3eee7fd4da0b690c48d2a98e" },
|
||||
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
|
||||
"fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" },
|
||||
"flutter-tools.nvim": { "branch": "main", "commit": "8fa438f36fa6cb747a93557d67ec30ef63715c20" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "ee7e50dfbdf49e3acfa416fd3ad3abbdb658582c" },
|
||||
"harpoon": { "branch": "harpoon2", "commit": "ed1f853847ffd04b2b61c314865665e1dadf22c7" },
|
||||
"image.nvim": { "branch": "master", "commit": "c40215d7d7d1d8c823ee9a77be1a894d5c8df41b" },
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
local util = require('config.util')
|
||||
|
||||
-- NOTE: General --
|
||||
|
||||
-- hjkl to ijkl remap
|
||||
|
@ -26,32 +24,27 @@ vim.keymap.set({ 'n', 'v', 'o' }, '#', '_', { desc = '# start of line' })
|
|||
vim.keymap.set('n', '<C-s>', ':w<CR>', { desc = 'ctrl-s save' })
|
||||
vim.keymap.set('n', '<C-w>', ':bd<CR>', { desc = 'save and close', nowait = true })
|
||||
|
||||
-- tabs
|
||||
-- TODO: redo with telescope and ctrl tab
|
||||
|
||||
-- vim.keymap.set('n', '<leader><Tab>', ':bnext<CR>', { desc = 'next buffer' })
|
||||
-- vim.keymap.set('n', '<leader><S-Tab>', ':bprev<CR>', { desc = 'previous buffer', noremap = true })
|
||||
|
||||
-- delete word in insert mode
|
||||
vim.keymap.set('i', '<C-BS>', '<C-w>', { desc = 'delete word in insert mode' })
|
||||
|
||||
|
||||
|
||||
-- NOTE: Right Dock: Terminal & Oil
|
||||
|
||||
-- NOTE: ctrl m
|
||||
vim.keymap.set('n', '<F27>', '<cmd>Floaterminal<CR>', { desc = 'open terminal', nowait = true })
|
||||
vim.keymap.set('t', '<F27>', '<cmd>q<CR>', { desc = 'close terminal window' })
|
||||
|
||||
vim.keymap.set('n', '<C-l>', function()
|
||||
util.open_in_right_dock('term://')
|
||||
end, { desc = 'open terminal' })
|
||||
vim.keymap.set('t', '<C-l>', '<cmd>Floaterminal 1<CR>', { desc = 'terminal 1' })
|
||||
vim.keymap.set('t', '<C-j>', '<cmd>Floaterminal 2<CR>', { desc = 'terminal 2' })
|
||||
vim.keymap.set('t', '<C-f>', '<cmd>Floaterminal 3<CR>', { desc = 'terminal 3' })
|
||||
vim.keymap.set('t', '<C-g>', '<cmd>Floaterminal 4<CR>', { desc = 'terminal 4' })
|
||||
|
||||
vim.keymap.set('t', '<C-j>', '<cmd>wincmd h<CR>', { desc = 'focus editor', silent = true })
|
||||
vim.keymap.set('t', '<C-w>', '<C-d>', { desc = 'kill terminal' })
|
||||
vim.keymap.set('t', '<F28>', '<cmd>q<CR>', { desc = 'close terminal window' })
|
||||
|
||||
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { desc = 'normal mode in terminal' })
|
||||
|
||||
|
||||
vim.keymap.set('n', '<C-e>', function()
|
||||
util.open_in_right_dock('oil://')
|
||||
end, { desc = 'open oil' })
|
||||
vim.keymap.set('n', '<C-e>', '<cmd>Floateroil<CR>', { desc = 'open oil' })
|
||||
|
||||
|
||||
-- NOTE: Windows
|
||||
|
@ -164,7 +157,7 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|||
--
|
||||
-- This may be unwanted, since they displace some of your code
|
||||
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
|
||||
map('<leader>th', function()
|
||||
map('<leader>ih', function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
|
||||
end, '[T]oggle Inlay [H]ints')
|
||||
end
|
||||
|
@ -180,5 +173,9 @@ vim.keymap.set("n", "<leader>ml", ":MoltenEvaluateLine<CR>",
|
|||
{ silent = true, desc = "evaluate line" })
|
||||
vim.keymap.set("v", "<leader>mv", ":<C-u>MoltenEvaluateVisual<CR>gv",
|
||||
{ silent = false, desc = "evaluate visual selection" })
|
||||
vim.keymap.set("n", "<leader>mc", ":MoltenReevaluateCell<CR>",
|
||||
{ silent = false, desc = "reevaluate cell" })
|
||||
vim.keymap.set("n", "<leader>me", ":noautocmd MoltenEnterOutput<CR>",
|
||||
{ silent = true, desc = "show/enter output" })
|
||||
vim.keymap.set("n", "<leader>mh", ":MoltenHideOutput<CR>",
|
||||
{ silent = true, desc = "hide output" })
|
||||
|
|
|
@ -44,7 +44,8 @@ vim.opt.tabstop = 4
|
|||
vim.opt.shiftwidth = 4
|
||||
|
||||
vim.opt.hlsearch = false
|
||||
vim.opt.wrap = false
|
||||
|
||||
-- Example for configuring Neovim to load user-installed installed Lua rocks:
|
||||
-- Example for configring Neovim to load user-installed installed Lua rocks:
|
||||
package.path = package.path .. ';' .. vim.fn.expand('$HOME') .. '/.luarocks/share/lua/5.1/?/init.lua;'
|
||||
package.path = package.path .. ';' .. vim.fn.expand('$HOME') .. '/.luarocks/share/lua/5.1/?.lua;'
|
||||
|
|
|
@ -7,6 +7,16 @@ return {
|
|||
---@type AutoSession.Config
|
||||
opts = {
|
||||
suppressed_dirs = { '~/', '~/Downloads', '/' },
|
||||
pre_save_cmds = {
|
||||
function()
|
||||
local bufs = vim.api.nvim_list_bufs()
|
||||
for _, buf in ipairs(bufs) do
|
||||
if vim.bo[buf].buftype == 'terminal' then
|
||||
vim.api.nvim_buf_delete(buf, { force = true, unload = false })
|
||||
end
|
||||
end
|
||||
end
|
||||
},
|
||||
pre_restore_cmds = {
|
||||
-- might not be necessary, but save current harpoon data when we're about to restore a session
|
||||
function() require('harpoon'):sync() end,
|
||||
|
|
|
@ -39,69 +39,116 @@ return {
|
|||
},
|
||||
{
|
||||
"sindrets/diffview.nvim",
|
||||
},
|
||||
{
|
||||
"NeogitOrg/neogit",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-telescope/telescope.nvim",
|
||||
},
|
||||
config = function()
|
||||
require('neogit').setup({
|
||||
|
||||
kind = 'floating',
|
||||
graph_style = 'kitty',
|
||||
disable_line_numbers = false,
|
||||
disable_relative_line_numbers = false,
|
||||
commit_editor = {
|
||||
kind = 'floating',
|
||||
},
|
||||
commit_select_view = {
|
||||
kind = "floating",
|
||||
},
|
||||
commit_view = {
|
||||
kind = "floating",
|
||||
verify_commit = vim.fn.executable("gpg") == 1, -- Can be set to true or false, otherwise we try to find the binary
|
||||
},
|
||||
log_view = {
|
||||
kind = "floating",
|
||||
},
|
||||
rebase_editor = {
|
||||
kind = "floating",
|
||||
},
|
||||
reflog_view = {
|
||||
kind = "floating",
|
||||
},
|
||||
merge_editor = {
|
||||
kind = "floating",
|
||||
},
|
||||
description_editor = {
|
||||
kind = "floating",
|
||||
},
|
||||
tag_editor = {
|
||||
kind = "floating",
|
||||
},
|
||||
preview_buffer = {
|
||||
kind = "floating",
|
||||
},
|
||||
popup = {
|
||||
kind = "floating",
|
||||
},
|
||||
stash = {
|
||||
kind = "floating",
|
||||
},
|
||||
refs_view = {
|
||||
kind = "floating",
|
||||
},
|
||||
mappings = {
|
||||
status = {
|
||||
['i'] = 'MoveUp',
|
||||
['k'] = 'MoveDown',
|
||||
config = function ()
|
||||
local actions = require('diffview.config').actions
|
||||
require('diffview').setup({
|
||||
keymaps = {
|
||||
disable_defaults = true,
|
||||
file_panel = {
|
||||
['i'] = '<Up>',
|
||||
['k'] = '<Down>',
|
||||
['j'] = false,
|
||||
},
|
||||
|
||||
['<Space>'] = function () actions.toggle_stage_entry() end
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
vim.keymap.set('n', '<leader>gg', '<cmd>Neogit<CR>', { desc = 'open neogit '})
|
||||
end
|
||||
}
|
||||
},
|
||||
-- {
|
||||
-- "NeogitOrg/neogit",
|
||||
-- dependencies = {
|
||||
-- "nvim-lua/plenary.nvim",
|
||||
-- "nvim-telescope/telescope.nvim",
|
||||
-- },
|
||||
-- config = function()
|
||||
-- require('neogit').setup({
|
||||
--
|
||||
-- kind = 'floating',
|
||||
-- graph_style = 'kitty',
|
||||
-- disable_line_numbers = false,
|
||||
-- disable_relative_line_numbers = false,
|
||||
-- commit_editor = {
|
||||
-- kind = 'floating',
|
||||
-- },
|
||||
-- commit_select_view = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- commit_view = {
|
||||
-- kind = "floating",
|
||||
-- verify_commit = vim.fn.executable("gpg") == 1, -- Can be set to true or false, otherwise we try to find the binary
|
||||
-- },
|
||||
-- log_view = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- rebase_editor = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- reflog_view = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- merge_editor = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- description_editor = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- tag_editor = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- preview_buffer = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- popup = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- stash = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- refs_view = {
|
||||
-- kind = "floating",
|
||||
-- },
|
||||
-- mappings = {
|
||||
-- status = {
|
||||
-- ['i'] = 'MoveUp',
|
||||
-- ['k'] = 'MoveDown',
|
||||
-- ['j'] = false,
|
||||
-- },
|
||||
-- }
|
||||
-- })
|
||||
-- vim.keymap.set('n', '<leader>gg', '<cmd>Neogit<CR>', { desc = 'open neogit '})
|
||||
-- end
|
||||
-- }
|
||||
-- {
|
||||
-- 'tpope/vim-fugitive',
|
||||
-- }
|
||||
-- {
|
||||
-- 'sindrets/diffview.nvim',
|
||||
-- dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
-- -- lazy, only load diffview by these commands
|
||||
-- cmd = {
|
||||
-- 'DiffviewFileHistory', 'DiffviewOpen', 'DiffviewToggleFiles', 'DiffviewFocusFiles', 'DiffviewRefresh'
|
||||
-- }
|
||||
-- },
|
||||
-- {
|
||||
-- 'SuperBo/fugit2.nvim',
|
||||
-- build = false,
|
||||
-- opts = {
|
||||
-- width = 100,
|
||||
-- },
|
||||
-- dependencies = {
|
||||
-- 'MunifTanjim/nui.nvim',
|
||||
-- 'nvim-tree/nvim-web-devicons',
|
||||
-- 'nvim-lua/plenary.nvim',
|
||||
-- -- {
|
||||
-- -- 'chrisgrieser/nvim-tinygit', -- optional: for Github PR view
|
||||
-- -- dependencies = { 'stevearc/dressing.nvim' }
|
||||
-- -- },
|
||||
-- },
|
||||
-- cmd = { 'Fugit2', 'Fugit2Diff', 'Fugit2Graph' },
|
||||
-- keys = {
|
||||
-- { '<leader>F', mode = 'n', '<cmd>Fugit2<cr>' }
|
||||
-- }
|
||||
-- },
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ return {
|
|||
vim.keymap.set('n', '<leader>a', function() harpoon:list():add() end)
|
||||
vim.keymap.set('n', '<C-h>', function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
|
||||
|
||||
vim.keymap.set('n', '<A-1>', function() harpoon:list():select(1) end)
|
||||
vim.keymap.set('n', '<A-2>', function() harpoon:list():select(2) end)
|
||||
vim.keymap.set('n', '<A-3>', function() harpoon:list():select(3) end)
|
||||
vim.keymap.set('n', '<A-q>', function() harpoon:list():select(4) end)
|
||||
vim.keymap.set('n', '<C-l>', function() harpoon:list():select(1) end)
|
||||
vim.keymap.set('n', '<C-j>', function() harpoon:list():select(2) end)
|
||||
vim.keymap.set('n', '<C-f>', function() harpoon:list():select(3) end)
|
||||
vim.keymap.set('n', '<C-g>', function() harpoon:list():select(4) end)
|
||||
|
||||
-- -- Toggle previous & next buffers stored within Harpoon list
|
||||
-- vim.keymap.set('n', '<C-S-P>', function() harpoon:list():prev() end)
|
||||
|
|
|
@ -41,12 +41,13 @@ require('lazy').setup({
|
|||
require('config.plugins.ui'),
|
||||
require('config.plugins.telescope'),
|
||||
require('config.plugins.blinkcmp'),
|
||||
require('config.plugins.lsp'),
|
||||
require('config.plugins.treesitter'),
|
||||
require('config.plugins.languages.lsp'),
|
||||
require('config.plugins.languages.treesitter'),
|
||||
require('config.plugins.harpoon'),
|
||||
require('config.plugins.autosession'),
|
||||
|
||||
require('config.plugins.molten'),
|
||||
require('config.plugins.languages.molten'),
|
||||
require('config.plugins.languages.flutter'),
|
||||
|
||||
|
||||
-- NOTE: maybe revisit this later
|
||||
|
|
11
.config/nvim/lua/config/plugins/languages/flutter.lua
Normal file
11
.config/nvim/lua/config/plugins/languages/flutter.lua
Normal file
|
@ -0,0 +1,11 @@
|
|||
return {
|
||||
'nvim-flutter/flutter-tools.nvim',
|
||||
lazy = false,
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'stevearc/dressing.nvim', -- optional for vim.ui.select
|
||||
},
|
||||
config = function()
|
||||
require('flutter-tools').setup({})
|
||||
end,
|
||||
}
|
|
@ -6,7 +6,7 @@ return {
|
|||
opts = {
|
||||
backend = 'kitty', -- whatever backend you would like to use
|
||||
max_width = 100,
|
||||
max_height = 12,
|
||||
max_height = 20,
|
||||
max_height_window_percentage = math.huge,
|
||||
max_width_window_percentage = math.huge,
|
||||
window_overlap_clear_enabled = true, -- toggles images when windows are overlapped
|
||||
|
@ -22,7 +22,6 @@ return {
|
|||
init = function()
|
||||
-- these are examples, not defaults. Please see the readme
|
||||
vim.g.molten_image_provider = 'image.nvim'
|
||||
vim.g.molten_output_win_max_height = 20
|
||||
end,
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ return {
|
|||
build = ':TSUpdate',
|
||||
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
||||
opts = {
|
||||
ensure_installed = { 'bash', 'c', 'diff', 'html', 'css', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'rust', 'python', 'htmldjango', 'r' },
|
||||
ensure_installed = { 'bash', 'c', 'diff', 'html', 'css', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'rust', 'python', 'htmldjango', 'r', 'dart' },
|
||||
auto_install = false,
|
||||
highlight = {
|
||||
enable = true,
|
|
@ -41,8 +41,15 @@ return {
|
|||
vim.keymap.set('n', '<leader>ss', builtin.lsp_document_symbols, { desc = 'document symbols' })
|
||||
vim.keymap.set('n', '<leader>sS', builtin.lsp_workspace_symbols, { desc = 'workspace symbols' })
|
||||
|
||||
vim.keymap.set('n', '<leader>st', '<cmd>TodoTelescope<CR>', { desc = 'search todos' })
|
||||
vim.keymap.set('n', '<leader>sp', '<cmd>SessionSearch<CR>', { desc = 'search sessions' })
|
||||
|
||||
vim.keymap.set('n', '<leader>sh', function ()
|
||||
builtin.help_tags({
|
||||
previewer = false
|
||||
})
|
||||
end, { desc = 'help' })
|
||||
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
local function starts_with(str, prefix)
|
||||
return string.find(str, '^' .. prefix) ~= nil
|
||||
end
|
||||
|
||||
---get the window for the right dock
|
||||
---@return integer | nil window window id if exists, nil otherwise
|
||||
local function get_dock_win()
|
||||
local windows = vim.api.nvim_list_wins()
|
||||
for _, win in ipairs(windows) do
|
||||
local width = vim.api.nvim_win_get_width(win)
|
||||
if width == 60 or width == 40 then
|
||||
return win
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
---get the buffer which starts with prefix
|
||||
---@param prefix string prefix of the name of buffer
|
||||
---@return integer | nil buf buffer id if exists, nil otherwise
|
||||
local function get_dock_buf(prefix)
|
||||
local buffers = vim.api.nvim_list_bufs()
|
||||
for _, buf in ipairs(buffers) do
|
||||
if vim.api.nvim_buf_is_loaded(buf) then
|
||||
local buf_name = vim.api.nvim_buf_get_name(buf)
|
||||
if starts_with(buf_name, prefix) then
|
||||
return buf
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
---get number of windows that are not docks i.e. right dock
|
||||
---@param tabpage integer tabpage id of the tab to look in, 0 for current
|
||||
---@return integer count count of non-dock windows
|
||||
local function get_no_of_nondock_wins(tabpage)
|
||||
local wins = vim.api.nvim_tabpage_list_wins(tabpage)
|
||||
local count = 0
|
||||
for _, win in ipairs(wins) do
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
local buf_name = vim.api.nvim_buf_get_name(buf)
|
||||
if not(starts_with(buf_name, 'term://') or starts_with(buf_name, 'oil://')) then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
return count
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
open_in_right_dock = function (prefix)
|
||||
|
||||
-- set width accroding to terminal/oil
|
||||
local width = prefix == 'term://' and 60 or 40
|
||||
|
||||
-- get dock window if exists
|
||||
local dock_win = get_dock_win()
|
||||
if dock_win ~= nil then
|
||||
|
||||
local buf = vim.api.nvim_win_get_buf(dock_win)
|
||||
local buf_name = vim.api.nvim_buf_get_name(buf)
|
||||
vim.api.nvim_set_current_win(dock_win)
|
||||
vim.api.nvim_win_set_width(dock_win, width)
|
||||
|
||||
if starts_with(buf_name, prefix) then
|
||||
if prefix == 'term://' then
|
||||
vim.api.nvim_feedkeys('a', 'n', true)
|
||||
end
|
||||
else
|
||||
if prefix == 'term://' then
|
||||
vim.cmd.term()
|
||||
vim.api.nvim_feedkeys('a', 'n', true)
|
||||
else
|
||||
vim.cmd('Oil')
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- no dock window at this point so create new
|
||||
vim.cmd.vsplit()
|
||||
vim.api.nvim_win_set_width(0, width)
|
||||
|
||||
-- get existing buf if exists
|
||||
local dock_buf = get_dock_buf(prefix)
|
||||
|
||||
if dock_buf ~= nil then
|
||||
vim.api.nvim_set_current_buf(dock_buf)
|
||||
if prefix == 'term://' then
|
||||
vim.api.nvim_feedkeys('a', 'n', true)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if prefix == 'term://' then
|
||||
vim.cmd.term()
|
||||
vim.api.nvim_feedkeys('a', 'n', true)
|
||||
else
|
||||
vim.cmd('Oil')
|
||||
end
|
||||
end,
|
||||
|
||||
}
|
92
.config/nvim/plugin/floater.lua
Normal file
92
.config/nvim/plugin/floater.lua
Normal file
|
@ -0,0 +1,92 @@
|
|||
---Opens a floating windo
|
||||
---@param buf? integer buffer-ID of buffer to put in thw window
|
||||
---@param w_percent? decimal width of floating window will be this * full width
|
||||
---@param h_percent? decimal height of floating window will be this * full height
|
||||
---@param opts any options to pass to nvim_open_win
|
||||
local function open_floating_win(buf, w_percent, h_percent, opts)
|
||||
buf = buf or vim.api.nvim_create_buf(true, false)
|
||||
w_percent = w_percent or 0.8
|
||||
h_percent = h_percent or 0.8
|
||||
local default_opts = {
|
||||
relative = 'editor',
|
||||
row = (vim.o.lines - vim.o.lines * h_percent)/2,
|
||||
col = (vim.o.columns - vim.o.columns * w_percent)/2,
|
||||
width = math.floor(vim.o.columns * w_percent),
|
||||
height = math.floor(vim.o.lines * h_percent),
|
||||
style = 'minimal',
|
||||
border = 'rounded'
|
||||
}
|
||||
opts = vim.tbl_deep_extend('force', default_opts, opts or {})
|
||||
vim.api.nvim_open_win(buf, true, opts)
|
||||
end
|
||||
|
||||
local term_state = {
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
last_used = 1,
|
||||
win = -1,
|
||||
}
|
||||
|
||||
vim.api.nvim_create_user_command('Floaterminal', function(table)
|
||||
-- TODO: update last_used buffer if it gets deleted
|
||||
|
||||
local is_new = false
|
||||
if table.args ~= '' then
|
||||
|
||||
local num = tonumber(table.args)
|
||||
if num < 1 or num > 4 then
|
||||
error('numbers from 1 to 4 allowed only')
|
||||
end
|
||||
if not vim.api.nvim_win_is_valid(term_state.win) then
|
||||
error('only specify arguments after opening the floaterminal')
|
||||
end
|
||||
|
||||
if not vim.api.nvim_buf_is_valid(term_state[num]) then
|
||||
term_state[num] = vim.api.nvim_create_buf(true, false)
|
||||
is_new = true
|
||||
end
|
||||
|
||||
term_state.last_used = num
|
||||
vim.api.nvim_set_current_buf(term_state[num])
|
||||
|
||||
else
|
||||
|
||||
if not vim.api.nvim_buf_is_valid(term_state[term_state.last_used]) then
|
||||
term_state[term_state.last_used] = vim.api.nvim_create_buf(true, false)
|
||||
is_new = true
|
||||
end
|
||||
|
||||
open_floating_win(term_state[term_state.last_used])
|
||||
|
||||
term_state.win = vim.api.nvim_get_current_win()
|
||||
|
||||
end
|
||||
|
||||
if is_new then
|
||||
vim.cmd.term()
|
||||
end
|
||||
if vim.api.nvim_get_mode().mode == 'nt' then
|
||||
vim.api.nvim_feedkeys('a', 'n', true)
|
||||
end
|
||||
|
||||
end, { nargs = '?', desc = 'open the floaterminaaal' })
|
||||
|
||||
|
||||
local oil_buf = -1
|
||||
|
||||
vim.api.nvim_create_user_command('Floateroil', function()
|
||||
local is_new = false
|
||||
if not vim.api.nvim_buf_is_valid(oil_buf) then
|
||||
oil_buf = vim.api.nvim_create_buf(true, false)
|
||||
is_new = true
|
||||
end
|
||||
|
||||
open_floating_win(oil_buf)
|
||||
if is_new then
|
||||
vim.cmd('Oil')
|
||||
end
|
||||
|
||||
end, { desc = 'open the floateroil' })
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue