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 'dressing'
|
||||
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,
|
||||
})
|
||||
|
@ -95,6 +95,10 @@ vim.cmd [[
|
||||
augroup END
|
||||
]]
|
||||
|
||||
vim.cmd [[
|
||||
autocmd VimLeave * call writefile([getcwd()], expand('~/.cache/nvim/cwd'))
|
||||
]]
|
||||
|
||||
-- Fixes Autocomment
|
||||
-- vim.api.nvim_create_autocmd({ 'BufWinEnter' }, {
|
||||
-- callback = function()
|
||||
|
@ -1,6 +1,8 @@
|
||||
local opt = { noremap = true, silent = true }
|
||||
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! NeoSwapNext<cr>', opt)
|
||||
keymap('n', '<insert>', '<cmd>Lazy profile<cr>', opt)
|
||||
|
@ -79,7 +79,7 @@ return {
|
||||
{ '<leader>fb', telescope 'buffers', desc = 'buffers' },
|
||||
{ '<leader>fc', telescope 'colorscheme', desc = 'colorscheme' },
|
||||
{ '<leader>fh', telescope 'oldfiles', desc = 'history' },
|
||||
{ '<leader>fj', telescope 'jumplist', desc = 'history' },
|
||||
{ '<leader>fj', telescope 'jumplist', desc = 'jumplist' },
|
||||
}
|
||||
end,
|
||||
config = function()
|
||||
|
@ -29,25 +29,25 @@ end
|
||||
|
||||
function M.on_attach(client, bufnr)
|
||||
-- Highlight references
|
||||
-- if client.server_capabilities.documentHighlightProvider then
|
||||
-- vim.api.nvim_create_augroup("lsp_document_highlight", {
|
||||
-- clear = false,
|
||||
-- })
|
||||
-- vim.api.nvim_clear_autocmds({
|
||||
-- group = "lsp_document_highlight",
|
||||
-- buffer = bufnr,
|
||||
-- })
|
||||
-- -- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
-- -- group = "lsp_document_highlight",
|
||||
-- -- buffer = bufnr,
|
||||
-- -- callback = vim.lsp.buf.document_highlight,
|
||||
-- -- })
|
||||
-- -- vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
-- -- group = "lsp_document_highlight",
|
||||
-- -- buffer = bufnr,
|
||||
-- -- callback = vim.lsp.buf.clear_references,
|
||||
-- -- })
|
||||
-- end
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
vim.api.nvim_create_augroup("lsp_document_highlight", {
|
||||
clear = false,
|
||||
})
|
||||
vim.api.nvim_clear_autocmds({
|
||||
group = "lsp_document_highlight",
|
||||
buffer = bufnr,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
group = "lsp_document_highlight",
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
group = "lsp_document_highlight",
|
||||
buffer = bufnr,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -61,5 +61,80 @@ return {
|
||||
},
|
||||
})
|
||||
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)
|
||||
|
||||
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)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user