nvim: run a formatted and update autocmds to new 0.7 api

This commit is contained in:
2023-07-08 15:20:41 +03:00
parent 86bf045a70
commit d41dfc6efe
21 changed files with 402 additions and 333 deletions

View File

@ -1,32 +1,30 @@
local cmd = vim.cmd
local opt = vim.opt
local g = vim.g
-- sensible settings
opt.autoread = true
opt.clipboard = 'unnamedplus'
opt.conceallevel = 0
opt.hlsearch = false
opt.lazyredraw = true
opt.mouse = 'a'
opt.nu = true
opt.rnu = true
opt.scrolloff = 10
opt.shortmess = 'c'
opt.showcmd = true
opt.showmode = false
opt.sw = 4
opt.swapfile = false
opt.timeoutlen = 500
opt.ts = 4
opt.laststatus = 3
-- opt.wrap = false
vim.opt.autoread = true
vim.opt.clipboard = "unnamedplus"
vim.opt.conceallevel = 0
vim.opt.hlsearch = false
vim.opt.lazyredraw = true
vim.opt.mouse = "a"
vim.opt.nu = true
vim.opt.rnu = true
vim.opt.scrolloff = 10
vim.opt.shortmess = "c"
vim.opt.showcmd = true
vim.opt.showmode = false
vim.opt.sw = 4
vim.opt.swapfile = false
vim.opt.timeoutlen = 500
vim.opt.ts = 4
vim.opt.laststatus = 3
-- :JsonFormat command using jq
cmd 'autocmd FileType json :command! JsonFormat %!jq .'
-- :jq command using jq
vim.api.nvim_create_autocmd("FileType", {
pattern = "json",
command = ":command! JsonFormat %!jq",
})
-- trigger autoread on file change
cmd "autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif"
-- neovim-qt font
opt.guifont = 'DejaVu\\ Sans\\ Mono:h14'
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
pattern = "*",
command = "if mode() != 'c' | checktime | endif",
})