From 104145392c4dc68d40274125f5ab3c2818a53656 Mon Sep 17 00:00:00 2001 From: veypi Date: Tue, 15 Oct 2024 19:26:24 +0800 Subject: [PATCH] autosave jsonlsp --- lazy-lock.json | 1 + lazyvim.json | 6 ++---- lua/plugins/autosave.lua | 27 +++++++++++++++++++++++++++ lua/plugins/lsp.lua | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 lua/plugins/autosave.lua diff --git a/lazy-lock.json b/lazy-lock.json index e5b874e..09429dd 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,6 @@ { "LazyVim": { "branch": "main", "commit": "13a4a84e3485a36e64055365665a45dc82b6bf71" }, + "auto-save.nvim": { "branch": "main", "commit": "5fbcaac0a2698c87a9a1bd2083cb6949505cca12" }, "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, "catppuccin": { "branch": "main", "commit": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, diff --git a/lazyvim.json b/lazyvim.json index 8e6b0ec..b8681df 100644 --- a/lazyvim.json +++ b/lazyvim.json @@ -1,9 +1,7 @@ { - "extras": [ - - ], + "extras": [], "news": { "NEWS.md": "6520" }, "version": 6 -} \ No newline at end of file +} diff --git a/lua/plugins/autosave.lua b/lua/plugins/autosave.lua new file mode 100644 index 0000000..f631651 --- /dev/null +++ b/lua/plugins/autosave.lua @@ -0,0 +1,27 @@ +return { + { + "okuuva/auto-save.nvim", + version = '^1.0.0', -- see https://devhints.io/semver, alternatively use '*' to use the latest tagged release + cmd = "ASToggle", -- optional for lazy loading on command + event = { "InsertLeave", "TextChanged" }, -- optional for lazy loading on trigger events + opts = { + enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it) + trigger_events = { -- See :h events + immediate_save = { "BufLeave", "FocusLost" }, -- vim events that trigger an immediate save + defer_save = { "InsertLeave", "TextChanged" }, -- vim events that trigger a deferred save (saves after `debounce_delay`) + cancel_deferred_save = { "InsertEnter" }, -- vim events that cancel a pending deferred save + }, + -- function that takes the buffer handle and 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 + -- if set to `nil` then no specific condition is applied + condition = nil, + write_all_buffers = false, -- write all buffers when the current one meets `condition` + noautocmd = false, -- do not execute autocmds when saving + lockmarks = false, -- lock marks when saving, see `:h lockmarks` for more details + debounce_delay = 1000, -- delay after which a pending save is executed + -- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable + debug = false, + } + } +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 5f4d04e..26a4b5e 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -2,7 +2,7 @@ return { { "nvim-treesitter/nvim-treesitter", - opts = { ensure_installed = { "vue", "css", "go", "gomod", "gowork", "gosum" } }, + opts = { ensure_installed = { "vue", "css", "go", "gomod", "gowork", "gosum", "json5" } }, }, { "williamboman/mason.nvim",