From 59c5e8796d94e7c48b3188785d2117dcffee9900 Mon Sep 17 00:00:00 2001 From: TheK4n Date: Mon, 7 Nov 2022 18:14:21 +0300 Subject: [PATCH] nvim plugins --- sub/vim/init.lua | 60 ++++++++++++++++++++++++++++-------------------- sub/vim/vimrc | 4 +--- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/sub/vim/init.lua b/sub/vim/init.lua index 0883941..69e1749 100644 --- a/sub/vim/init.lua +++ b/sub/vim/init.lua @@ -1,22 +1,41 @@ -local autosave = require("autosave") +local autosave = require("auto-save") autosave.setup( - { - enabled = true, - execution_message = "AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S"), - events = {"TextChanged", "InsertLeave"}, - conditions = { - exists = true, - filename_is_not = {}, - filetype_is_not = {}, - modifiable = true - }, - write_all_buffers = false, - on_off_commands = true, - clean_command_line_interval = 0, - debounce_delay = 0 - } +{ + enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it) + execution_message = { + message = function() -- message to print on save + return ("AutoSave: saved at " .. vim.fn.strftime("%H:%M:%S")) + end, + dim = 0.18, -- dim the color of `message` + cleaning_interval = 1250, -- (milliseconds) automatically clean MsgArea after displaying `message`. See :h MsgArea + }, + trigger_events = {"InsertLeave", "TextChanged"}, -- vim events that trigger auto-save. See :h events + -- function that determines whether to save the current buffer or not + -- return true: if buffer is ok to be saved + -- return false: if it's not ok to be saved + condition = function(buf) + local fn = vim.fn + local utils = require("auto-save.utils.data") + + if + fn.getbufvar(buf, "&modifiable") == 1 and + utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then + return true -- met condition(s), can save + end + return false -- can't save + end, + write_all_buffers = false, -- write all buffers when the current one meets `condition` + debounce_delay = 135, -- saves the file at most every `debounce_delay` milliseconds + callbacks = { -- functions to be executed at different intervals + enabling = nil, -- ran when enabling auto-save + disabling = nil, -- ran when disabling auto-save + before_asserting_save = nil, -- ran before checking `condition` + before_saving = nil, -- ran before doing the actual save + after_saving = nil -- ran after doing the actual save + } +} ) @@ -132,12 +151,3 @@ require("nvim-autopairs").setup {} require('gitsigns').setup() -local null_ls = require("null-ls") - -null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua, - null_ls.builtins.diagnostics.eslint, - null_ls.builtins.completion.spell, - }, -}) diff --git a/sub/vim/vimrc b/sub/vim/vimrc index 9748c48..96caa3f 100644 --- a/sub/vim/vimrc +++ b/sub/vim/vimrc @@ -181,7 +181,7 @@ call vundle#begin() Plugin 'preservim/vimux' Plugin 'rbgrouleff/bclose.vim' Plugin 'frazrepo/vim-rainbow' - Plugin 'Pocco81/AutoSave.nvim' + Plugin 'Pocco81/auto-save.nvim' " requiered patch your font Plugin 'ryanoasis/vim-devicons' Plugin 'windwp/nvim-autopairs' @@ -205,7 +205,6 @@ call vundle#begin() Plugin 'preservim/nerdtree' Plugin 'lewis6991/gitsigns.nvim' - Plugin 'jose-elias-alvarez/null-ls.nvim' call vundle#end() @@ -310,4 +309,3 @@ nnoremap l :call TabDo('call ToggleRelativeAbsoluteNumber()') < " Quick exiting without save nnoremap qq :qa! -