From 06d2d1ed020ac3b21f6405eec1103bc33eca43c9 Mon Sep 17 00:00:00 2001 From: Young Xu Date: Sat, 6 May 2023 00:17:07 +0800 Subject: [PATCH] chore: format lua --- lua/core/keymapping.lua | 6 +-- lua/core/theme.lua | 2 +- lua/lsp/frontend.lua | 6 +-- lua/lsp/go.lua | 5 +- lua/lsp/init.lua | 14 +++--- lua/lsp/volar.lua | 2 +- lua/plugins/java.lua | 2 +- lua/plugins/treesitter.lua | 96 +++++++++++++++++++------------------- lua/plugins/utils.lua | 0 lua/plugins/wilder.lua | 1 - 10 files changed, 66 insertions(+), 68 deletions(-) delete mode 100644 lua/plugins/utils.lua diff --git a/lua/core/keymapping.lua b/lua/core/keymapping.lua index 521228d..8ebbf71 100644 --- a/lua/core/keymapping.lua +++ b/lua/core/keymapping.lua @@ -30,9 +30,9 @@ map.set("n", "", "j", noreopt) map.set("n", "", "k", noreopt) map.set("n", "", "l", noreopt) -- 折叠配置 -map.set({"n", "v"}, "z+", "zM", noreopt) -map.set({"n", "v"}, "z-", "zR", noreopt) -map.set({"n", "v"}, "zz", "za", noreopt) +map.set({ "n", "v" }, "z+", "zM", noreopt) +map.set({ "n", "v" }, "z-", "zR", noreopt) +map.set({ "n", "v" }, "zz", "za", noreopt) -- 分屏 map.set("n", "sv", ":vsp", noreopt) map.set("n", "sh", ":sp", noreopt) diff --git a/lua/core/theme.lua b/lua/core/theme.lua index 6106172..9eaad96 100644 --- a/lua/core/theme.lua +++ b/lua/core/theme.lua @@ -1 +1 @@ -vim.cmd([[colorscheme tokyonight-storm]]) +-- vim.cmd([[colorscheme tokyonight-storm]]) diff --git a/lua/lsp/frontend.lua b/lua/lsp/frontend.lua index b07bd3e..692e1f6 100644 --- a/lua/lsp/frontend.lua +++ b/lua/lsp/frontend.lua @@ -4,15 +4,15 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true require("lspconfig").html.setup({ - capabilities = capabilities, + capabilities = capabilities, }) require("lspconfig").cssls.setup({ - capabilities = capabilities, + capabilities = capabilities, }) require("lspconfig").tsserver.setup({ - capabilities = capabilities, + capabilities = capabilities, }) -- require("lspconfig").eslint.setup({ diff --git a/lua/lsp/go.lua b/lua/lsp/go.lua index 8232503..f38faa2 100644 --- a/lua/lsp/go.lua +++ b/lua/lsp/go.lua @@ -46,13 +46,13 @@ cmp.setup({ local capabilities = require("cmp_nvim_lsp").default_capabilities() --nvim-cmp -require("lspconfig")["golangci_lint_ls"].setup({ +require("lspconfig").golangci_lint_ls.setup({ on_attach = common_lsp_on_attach, flags = common_lsp_flags, }) util = require("lspconfig/util") -require("lspconfig")["gopls"].setup({ +require("lspconfig").gopls.setup({ cmd = { "gopls" }, filetypes = { "go", "gomod" }, root_dir = util.root_pattern("go.work", "go.mod", ".git"), @@ -71,4 +71,3 @@ require("lspconfig")["gopls"].setup({ }, init_options = { usePlaceholders = true }, }) - diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 44d29c7..92504c3 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,14 +1,14 @@ -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer common_lsp_on_attach = function(client, bufnr) - local function buf_set_keymap(...) - vim.api.nvim_buf_set_keymap(bufnr, ...) - end - local function buf_set_option(...) - vim.api.nvim_buf_set_option(bufnr, ...) - end + local function buf_set_keymap(...) + vim.api.nvim_buf_set_keymap(bufnr, ...) + end + local function buf_set_option(...) + vim.api.nvim_buf_set_option(bufnr, ...) + end end common_lsp_flags = { - debounce_text_changes = 500, + debounce_text_changes = 500, } diff --git a/lua/lsp/volar.lua b/lua/lsp/volar.lua index efd2a8e..f5dce7d 100644 --- a/lua/lsp/volar.lua +++ b/lua/lsp/volar.lua @@ -1,3 +1,3 @@ require("lspconfig").volar.setup({ - filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "json" }, + filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "json" }, }) diff --git a/lua/plugins/java.lua b/lua/plugins/java.lua index 03e878c..2214c46 100644 --- a/lua/plugins/java.lua +++ b/lua/plugins/java.lua @@ -9,7 +9,7 @@ function IsFileExist(filename) end function IsWindows() - local delimeter = package.config.sub(1, 1) + local delimeter = package.config:sub(1, 1) if delimeter == "/" then return false end diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index c6011c9..4c79e1d 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,43 +1,43 @@ require("nvim-treesitter.configs").setup({ - -- A list of parser names, or "all" (the four listed parsers should always be installed) - ensure_installed = { - "bash", - "c", - "css", - "dart", - "diff", - "dockerfile", - "git_rebase", - "gitattributes", - "gitcommit", - "gitignore", - "go", - "gomod", - "gosum", - "gowork", - "html", - "java", - "javascript", - "json", - "lua", - "markdown", - "rust", - "toml", - "typescript", - "vim", - "vue", - "yaml", + -- A list of parser names, or "all" (the four listed parsers should always be installed) + ensure_installed = { + "bash", + "c", + "css", + "dart", + "diff", + "dockerfile", + "git_rebase", + "gitattributes", + "gitcommit", + "gitignore", + "go", + "gomod", + "gosum", + "gowork", + "html", + "java", + "javascript", + "json", + "lua", + "markdown", + "rust", + "toml", + "typescript", + "vim", + "vue", + "yaml", "proto", - }, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = true, - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, - -- List of parsers to ignore installing (for "all") - ignore_install = {}, - ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) - -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + }, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = true, + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + -- List of parsers to ignore installing (for "all") + ignore_install = {}, + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! incremental_selection = { enable = true, @@ -48,14 +48,14 @@ require("nvim-treesitter.configs").setup({ scope_incremental = "", }, }, - indent = { - enable = true, - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - autotag = { - enable = true, - }, + indent = { + enable = true, + }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + autotag = { + enable = true, + }, }) diff --git a/lua/plugins/utils.lua b/lua/plugins/utils.lua deleted file mode 100644 index e69de29..0000000 diff --git a/lua/plugins/wilder.lua b/lua/plugins/wilder.lua index da3b63c..deba85d 100644 --- a/lua/plugins/wilder.lua +++ b/lua/plugins/wilder.lua @@ -49,4 +49,3 @@ G.map({ { "c", "", [[wilder#in_context() ? wilder#previous() : '']], { noremap = true, expr = true } }, { "c", "0", "0", {} }, -- 不清楚原因导致0无法使用 强制覆盖 }) -