update
This commit is contained in:
parent
d3aaadc9bd
commit
3fb9c805e2
27
init.lua
27
init.lua
@ -10,5 +10,32 @@ vim.api.nvim_create_autocmd('User', {
|
|||||||
require 'feline'
|
require 'feline'
|
||||||
-- require 'dressing'
|
-- require 'dressing'
|
||||||
require 'NeoSwap'
|
require 'NeoSwap'
|
||||||
|
|
||||||
|
local Terminal = require('toggleterm.terminal').Terminal
|
||||||
|
local lazygit = Terminal:new({
|
||||||
|
cmd = "lazygit",
|
||||||
|
dir = "git_dir",
|
||||||
|
direction = "float",
|
||||||
|
float_opts = {
|
||||||
|
border = "none",
|
||||||
|
},
|
||||||
|
-- function to run on opening the terminal
|
||||||
|
on_open = function(term)
|
||||||
|
vim.cmd("startinsert!")
|
||||||
|
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>",
|
||||||
|
{ noremap = true, silent = true })
|
||||||
|
end,
|
||||||
|
-- function to run on closing the terminal
|
||||||
|
on_close = function(_)
|
||||||
|
vim.cmd("startinsert!")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
function _lazygit_toggle()
|
||||||
|
lazygit:toggle()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_set_keymap("n", "<leader>g", "<cmd>lua _lazygit_toggle()<CR>",
|
||||||
|
{ noremap = true, silent = true })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
local function augroup(name)
|
local function augroup(name)
|
||||||
return vim.api.nvim_create_augroup("my_" .. name, { clear = false })
|
return vim.api.nvim_create_augroup("my_" .. name, { clear = false })
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd(
|
vim.api.nvim_create_autocmd(
|
||||||
{ "BufEnter", "FocusGained", "InsertLeave", "WinEnter", "CmdlineLeave" },
|
{ "BufEnter", "FocusGained", "InsertLeave", "WinEnter", "CmdlineLeave" },
|
||||||
{
|
{
|
||||||
group = augroup("toggle_relative_number"),
|
group = augroup("toggle_relative_number"),
|
||||||
callback = function()
|
callback = function()
|
||||||
if not vim.opt.number:get() and not vim.opt.relativenumber:get() then
|
if not vim.opt.number:get() and not vim.opt.relativenumber:get() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
vim.opt.relativenumber = vim.api.nvim_get_mode().mode ~= "i"
|
vim.opt.relativenumber = vim.api.nvim_get_mode().mode ~= "i"
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd(
|
vim.api.nvim_create_autocmd(
|
||||||
{ "BufLeave", "FocusLost", "InsertEnter", "WinLeave", "CmdlineEnter" },
|
{ "BufLeave", "FocusLost", "InsertEnter", "WinLeave", "CmdlineEnter" },
|
||||||
{
|
{
|
||||||
group = augroup("toggle_relative_number"),
|
group = augroup("toggle_relative_number"),
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
vim.opt.relativenumber = false
|
vim.opt.relativenumber = false
|
||||||
if ev.event == "CmdlineEnter" then
|
if ev.event == "CmdlineEnter" then
|
||||||
vim.cmd("redraw")
|
vim.cmd("redraw")
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
-- close some filetypes with <q>
|
-- close some filetypes with <q>
|
||||||
@ -95,6 +95,10 @@ vim.cmd [[
|
|||||||
augroup END
|
augroup END
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
vim.cmd [[
|
||||||
|
autocmd VimLeave * call writefile([getcwd()], expand('~/.cache/nvim/cwd'))
|
||||||
|
]]
|
||||||
|
|
||||||
-- Fixes Autocomment
|
-- Fixes Autocomment
|
||||||
-- vim.api.nvim_create_autocmd({ 'BufWinEnter' }, {
|
-- vim.api.nvim_create_autocmd({ 'BufWinEnter' }, {
|
||||||
-- callback = function()
|
-- callback = function()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
local opt = { noremap = true, silent = true }
|
local opt = { noremap = true, silent = true }
|
||||||
local keymap = vim.api.nvim_set_keymap
|
local keymap = vim.api.nvim_set_keymap
|
||||||
|
|
||||||
|
keymap('n', 'gx', '<cmd>!xdg-open <c-r><c-a><cr>', opt)
|
||||||
|
|
||||||
keymap('n', '<c-,>', '<cmd>silent! NeoSwapPrev<cr>', opt)
|
keymap('n', '<c-,>', '<cmd>silent! NeoSwapPrev<cr>', opt)
|
||||||
keymap('n', '<c-.>', '<cmd>silent! NeoSwapNext<cr>', opt)
|
keymap('n', '<c-.>', '<cmd>silent! NeoSwapNext<cr>', opt)
|
||||||
keymap('n', '<insert>', '<cmd>Lazy profile<cr>', opt)
|
keymap('n', '<insert>', '<cmd>Lazy profile<cr>', opt)
|
||||||
|
@ -79,7 +79,7 @@ return {
|
|||||||
{ '<leader>fb', telescope 'buffers', desc = 'buffers' },
|
{ '<leader>fb', telescope 'buffers', desc = 'buffers' },
|
||||||
{ '<leader>fc', telescope 'colorscheme', desc = 'colorscheme' },
|
{ '<leader>fc', telescope 'colorscheme', desc = 'colorscheme' },
|
||||||
{ '<leader>fh', telescope 'oldfiles', desc = 'history' },
|
{ '<leader>fh', telescope 'oldfiles', desc = 'history' },
|
||||||
{ '<leader>fj', telescope 'jumplist', desc = 'history' },
|
{ '<leader>fj', telescope 'jumplist', desc = 'jumplist' },
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
config = function()
|
config = function()
|
||||||
|
@ -29,25 +29,25 @@ end
|
|||||||
|
|
||||||
function M.on_attach(client, bufnr)
|
function M.on_attach(client, bufnr)
|
||||||
-- Highlight references
|
-- Highlight references
|
||||||
-- if client.server_capabilities.documentHighlightProvider then
|
if client.server_capabilities.documentHighlightProvider then
|
||||||
-- vim.api.nvim_create_augroup("lsp_document_highlight", {
|
vim.api.nvim_create_augroup("lsp_document_highlight", {
|
||||||
-- clear = false,
|
clear = false,
|
||||||
-- })
|
})
|
||||||
-- vim.api.nvim_clear_autocmds({
|
vim.api.nvim_clear_autocmds({
|
||||||
-- group = "lsp_document_highlight",
|
group = "lsp_document_highlight",
|
||||||
-- buffer = bufnr,
|
buffer = bufnr,
|
||||||
-- })
|
})
|
||||||
-- -- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||||
-- -- group = "lsp_document_highlight",
|
group = "lsp_document_highlight",
|
||||||
-- -- buffer = bufnr,
|
buffer = bufnr,
|
||||||
-- -- callback = vim.lsp.buf.document_highlight,
|
callback = vim.lsp.buf.document_highlight,
|
||||||
-- -- })
|
})
|
||||||
-- -- vim.api.nvim_create_autocmd("CursorMoved", {
|
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||||
-- -- group = "lsp_document_highlight",
|
group = "lsp_document_highlight",
|
||||||
-- -- buffer = bufnr,
|
buffer = bufnr,
|
||||||
-- -- callback = vim.lsp.buf.clear_references,
|
callback = vim.lsp.buf.clear_references,
|
||||||
-- -- })
|
})
|
||||||
-- end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -61,5 +61,80 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"willothy/flatten.nvim",
|
||||||
|
opts = function()
|
||||||
|
---@type Terminal?
|
||||||
|
local saved_terminal
|
||||||
|
|
||||||
|
return {
|
||||||
|
window = {
|
||||||
|
open = "alternate",
|
||||||
|
},
|
||||||
|
callbacks = {
|
||||||
|
should_block = function(argv)
|
||||||
|
-- Note that argv contains all the parts of the CLI command, including
|
||||||
|
-- Neovim's path, commands, options and files.
|
||||||
|
-- See: :help v:argv
|
||||||
|
|
||||||
|
-- In this case, we would block if we find the `-b` flag
|
||||||
|
-- This allows you to use `nvim -b file1` instead of
|
||||||
|
-- `nvim --cmd 'let g:flatten_wait=1' file1`
|
||||||
|
return vim.tbl_contains(argv, "-b")
|
||||||
|
|
||||||
|
-- Alternatively, we can block if we find the diff-mode option
|
||||||
|
-- return vim.tbl_contains(argv, "-d")
|
||||||
|
end,
|
||||||
|
pre_open = function()
|
||||||
|
local term = require("toggleterm.terminal")
|
||||||
|
local termid = term.get_focused_id()
|
||||||
|
saved_terminal = term.get(termid)
|
||||||
|
end,
|
||||||
|
post_open = function(bufnr, winnr, ft, is_blocking)
|
||||||
|
if is_blocking and saved_terminal then
|
||||||
|
-- Hide the terminal while it's blocking
|
||||||
|
saved_terminal:close()
|
||||||
|
else
|
||||||
|
-- If it's a normal file, just switch to its window
|
||||||
|
vim.api.nvim_set_current_win(winnr)
|
||||||
|
-- vim.api.nvim_set_current_bufnr(bufnr)
|
||||||
|
|
||||||
|
-- If we're in a different wezterm pane/tab, switch to the current one
|
||||||
|
-- Requires willothy/wezterm.nvim
|
||||||
|
-- require("wezterm").switch_pane.id(
|
||||||
|
-- tonumber(os.getenv("WEZTERM_PANE"))
|
||||||
|
-- )
|
||||||
|
end
|
||||||
|
|
||||||
|
-- If the file is a git commit, create one-shot autocmd to delete its buffer on write
|
||||||
|
-- If you just want the toggleable terminal integration, ignore this bit
|
||||||
|
if ft == "gitcommit" or ft == "gitrebase" then
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
|
buffer = bufnr,
|
||||||
|
once = true,
|
||||||
|
callback = vim.schedule_wrap(function()
|
||||||
|
vim.api.nvim_buf_delete(bufnr, {})
|
||||||
|
end),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
block_end = function()
|
||||||
|
-- After blocking ends (for a git commit, etc), reopen the terminal
|
||||||
|
vim.schedule(function()
|
||||||
|
if saved_terminal then
|
||||||
|
saved_terminal:open()
|
||||||
|
saved_terminal = nil
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
-- or pass configuration with
|
||||||
|
-- opts = { }
|
||||||
|
-- Ensure that it runs first to minimize delay when opening file from terminal
|
||||||
|
lazy = false,
|
||||||
|
priority = 1001,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ return {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
vim.g.rainbow_delimiters = { highlight = highlight }
|
vim.g.rainbow_delimiters = { highlight = highlight }
|
||||||
require("ibl").setup { scope = { highlight = highlight, show_start = false } }
|
require("ibl").setup { scope = { highlight = highlight, show_start = false, show_end = false } }
|
||||||
|
|
||||||
hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
|
hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user