vim autocommands
This commit is contained in:
+10
-28
@@ -82,21 +82,13 @@ opt.foldmethod = "expr"
|
|||||||
-- highlight on yank
|
-- highlight on yank
|
||||||
local cmd = vim.cmd
|
local cmd = vim.cmd
|
||||||
|
|
||||||
local function create_augroup(autocmds, name)
|
vim.api.nvim_command [[augroup MYAU]]
|
||||||
cmd("augroup " .. name)
|
vim.api.nvim_command [[autocmd!]]
|
||||||
cmd("autocmd!")
|
vim.api.nvim_command [[autocmd BufWritePre * %s/\s\+$//e]]
|
||||||
for _, autocmd in ipairs(autocmds) do
|
vim.api.nvim_command [[autocmd BufWritePre *.py execute ":Black"]]
|
||||||
cmd("autocmd " .. table.concat(autocmd, " "))
|
vim.api.nvim_command [[autocmd BufReadPost quickfix nmap <buffer> <cr> <cr>]]
|
||||||
end
|
vim.api.nvim_command [[autocmd TextYankPost * "lua vim.highlight.on_yank {on_visual = false}"]]
|
||||||
cmd("augroup END")
|
vim.api.nvim_command [[augroup END]]
|
||||||
end
|
|
||||||
|
|
||||||
cmd "au TextYankPost * lua vim.highlight.on_yank {on_visual = false}"
|
|
||||||
create_augroup({
|
|
||||||
{ "BufWritePre", "*", [[%s/\s\+$//e]] }, -- Delete trailing whitespace
|
|
||||||
{ "BufReadPost", "quickfix", "nmap <buffer> <cr> <cr>" },
|
|
||||||
{ "TextYankPost", "*", "lua vim.highlight.on_yank {on_visual = false}" },
|
|
||||||
}, "myau")
|
|
||||||
|
|
||||||
-- ----------------------------------------
|
-- ----------------------------------------
|
||||||
-- MAPS
|
-- MAPS
|
||||||
@@ -418,12 +410,10 @@ require("packer").startup {function(use)
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
use {"psf/black",
|
use {"psf/black"}
|
||||||
vim.api.nvim_command [[autocmd BufWritePre *.py execute ':Black']]
|
|
||||||
}
|
|
||||||
|
|
||||||
-- treesitter
|
-- treesitter
|
||||||
use {"nvim-treesitter/nvim-treesitter",
|
use {"nvim-treesitter/nvim-treesitter",
|
||||||
run = ":TSUpdate",
|
run = ":TSUpdate",
|
||||||
config = function()
|
config = function()
|
||||||
require("nvim-treesitter.configs").setup {
|
require("nvim-treesitter.configs").setup {
|
||||||
@@ -658,14 +648,6 @@ require("packer").startup {function(use)
|
|||||||
if client.resolved_capabilities.rename then
|
if client.resolved_capabilities.rename then
|
||||||
bmap(bufnr, "n", "<M-r>", ":Lspsaga rename<cr>", opts)
|
bmap(bufnr, "n", "<M-r>", ":Lspsaga rename<cr>", opts)
|
||||||
end
|
end
|
||||||
if client.resolved_capabilities.document_formatting or client.resolved_capabilities.document_range_formatting then
|
|
||||||
vim.api.nvim_command [[augroup Format]]
|
|
||||||
vim.api.nvim_command [[autocmd! * <buffer>]]
|
|
||||||
vim.api.nvim_command [[autocmd BufWritePost *.py lua vim.lsp.buf.formatting_seq_sync()]]
|
|
||||||
vim.api.nvim_command [[autocmd BufWritePost *.md lua vim.lsp.buf.formatting_seq_sync()]]
|
|
||||||
vim.api.nvim_command [[autocmd BufWritePost *.yaml lua vim.lsp.buf.formatting_seq_sync()]]
|
|
||||||
vim.api.nvim_command [[augroup END]]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
use_saga_diagnostic_sign = true
|
use_saga_diagnostic_sign = true
|
||||||
require("lspsaga").init_lsp_saga {
|
require("lspsaga").init_lsp_saga {
|
||||||
|
|||||||
Reference in New Issue
Block a user