From 846f37457c9c8519e69228f354a695c1e789e352 Mon Sep 17 00:00:00 2001 From: neoteny Date: Fri, 8 Oct 2021 09:42:28 +0300 Subject: [PATCH] update lvim --- config/lvim/config.lua | 22 ++++++-------------- config/lvim/ftplugin/go.lua | 6 +++--- config/lvim/ftplugin/javascript.lua | 32 ++++++++++++++--------------- config/lvim/ftplugin/lua.lua | 6 +++--- config/lvim/ftplugin/python.lua | 6 +++--- config/lvim/ftplugin/typescript.lua | 6 +++--- config/lvim/lua/plug/tabnine.lua | 4 ++-- config/lvim/lua/plug/ultest.lua | 8 ++++++++ config/lvim/lua/user/keymaps.lua | 4 +++- config/lvim/lua/user/plugins.lua | 17 +++++++-------- 10 files changed, 54 insertions(+), 57 deletions(-) create mode 100644 config/lvim/lua/plug/ultest.lua diff --git a/config/lvim/config.lua b/config/lvim/config.lua index 1bf4a53..3046fe4 100644 --- a/config/lvim/config.lua +++ b/config/lvim/config.lua @@ -1,4 +1,4 @@ -lvim.format_on_save = false +lvim.format_on_save = true lvim.lint_on_save = true lvim.colorscheme = "onedarker" @@ -12,29 +12,19 @@ lvim.builtin.gitsigns.opts.current_line_blame = true lvim.builtin.gitsigns.opts.current_line_blame_opts = { delay = 200 } -- TreeSitter -lvim.builtin.treesitter.ensure_installed = { - "javascript", - "typescript", - "jsdoc", - "yaml", - "toml", - "lua", - "go", -} +lvim.builtin.treesitter.ensure_installed = { "javascript", "typescript", "jsdoc", "yaml", "toml", "lua", "go", "gomod" } lvim.builtin.treesitter.indent.disable = { "python" } -- Telescope lvim.builtin.telescope.defaults.layout_config.prompt_position = "top" -lvim.builtin.telescope.defaults.file_ignore_patterns = { - ".git", - "node_modules", - "env", - ".bin", -} +lvim.builtin.telescope.defaults.file_ignore_patterns = { ".git", "node_modules", "target", "env", ".bin" } -- NvimTree lvim.builtin.nvimtree.ignore = { ".git", "node_modules", ".bin", "env" } +-- LSP +-- lvim.lsp.override = {"gopls"} + -- Others require "user.plugins" require "user.keymaps" diff --git a/config/lvim/ftplugin/go.lua b/config/lvim/ftplugin/go.lua index 6c74444..07c8083 100644 --- a/config/lvim/ftplugin/go.lua +++ b/config/lvim/ftplugin/go.lua @@ -1,7 +1,7 @@ lvim.lang.go.formatters = { - { exe = "gofumpt" }, - -- { exe = "gofmt" }, - -- { exe = "goimports" }, + { exe = "gofumpt" }, + -- { exe = "gofmt" }, + { exe = "goimports" }, } -- Debugger diff --git a/config/lvim/ftplugin/javascript.lua b/config/lvim/ftplugin/javascript.lua index c6b3012..e383080 100644 --- a/config/lvim/ftplugin/javascript.lua +++ b/config/lvim/ftplugin/javascript.lua @@ -1,10 +1,10 @@ lvim.lang.javascript.formatters = { - -- { exe = "eslint_d" }, - { exe = "prettierd" }, + -- { exe = "eslint_d" }, + { exe = "prettierd" }, } lvim.lang.javascript.linters = { - { exe = "eslint_d" }, + { exe = "eslint_d" }, } -- Debugger @@ -12,17 +12,17 @@ require("dap-install").config("jsnode", {}) -- Lsp lvim.lang.javascript.lsp.setup.handlers = { - ["textDocument/publishDiagnostics"] = function(_, _, p, id, _, cfg) - if p.diagnostics ~= nil then - local i = 1 - while i <= #p.diagnostics do - if p.diagnostics[i].code == 80001 then - table.remove(p.diagnostics, i) - else - i = i + 1 - end - end - end - vim.lsp.diagnostic.on_publish_diagnostics(_, _, p, id, _, cfg) - end, + ["textDocument/publishDiagnostics"] = function(_, _, p, id, _, cfg) + if p.diagnostics ~= nil then + local i = 1 + while i <= #p.diagnostics do + if p.diagnostics[i].code == 80001 then + table.remove(p.diagnostics, i) + else + i = i + 1 + end + end + end + vim.lsp.diagnostic.on_publish_diagnostics(_, _, p, id, _, cfg) + end, } diff --git a/config/lvim/ftplugin/lua.lua b/config/lvim/ftplugin/lua.lua index a980ca4..62436a2 100644 --- a/config/lvim/ftplugin/lua.lua +++ b/config/lvim/ftplugin/lua.lua @@ -1,8 +1,8 @@ lvim.lang.lua.formatters = { - { exe = "stylua" }, + { exe = "stylua" }, } lvim.lang.lua.linters = { - -- { exe = "luacheck" }, - -- { exe = "selene" }, + -- { exe = "luacheck" }, + { exe = "selene" }, } diff --git a/config/lvim/ftplugin/python.lua b/config/lvim/ftplugin/python.lua index f799f56..e79b5dc 100644 --- a/config/lvim/ftplugin/python.lua +++ b/config/lvim/ftplugin/python.lua @@ -1,8 +1,8 @@ lvim.lang.python.formatters = { - { exe = "black" }, - { exe = "isort" }, + { exe = "black" }, + { exe = "isort" }, } lvim.lang.python.linters = { - { exe = "flake8" }, + { exe = "flake8" }, } diff --git a/config/lvim/ftplugin/typescript.lua b/config/lvim/ftplugin/typescript.lua index e1def86..e8c5377 100644 --- a/config/lvim/ftplugin/typescript.lua +++ b/config/lvim/ftplugin/typescript.lua @@ -1,8 +1,8 @@ lvim.lang.typescript.formatters = { - -- { exe = "eslint_d" }, - { exe = "prettierd" }, + -- { exe = "eslint_d" }, + { exe = "prettierd" }, } lvim.lang.typescript.linters = { - { exe = "eslint_d" }, + { exe = "eslint_d" }, } diff --git a/config/lvim/lua/plug/tabnine.lua b/config/lvim/lua/plug/tabnine.lua index fda0bd1..6c198cf 100644 --- a/config/lvim/lua/plug/tabnine.lua +++ b/config/lvim/lua/plug/tabnine.lua @@ -1,12 +1,12 @@ local M = {} function M.setup() - local ok, tabnine = pcall(require, "cmp_tabnine.config") + local ok, tabnine_cfg = pcall(require, "cmp_tabnine.config") if not ok then return end - tabnine:setup { + tabnine_cfg:setup { max_lines = 1000, max_num_results = 10, sort = true, diff --git a/config/lvim/lua/plug/ultest.lua b/config/lvim/lua/plug/ultest.lua new file mode 100644 index 0000000..adfd03a --- /dev/null +++ b/config/lvim/lua/plug/ultest.lua @@ -0,0 +1,8 @@ +local M = {} + +function M.setup() + -- GOlang + vim.g["test#go#gotest#optiongs"] = "-v --short" +end + +return M diff --git a/config/lvim/lua/user/keymaps.lua b/config/lvim/lua/user/keymaps.lua index 64d09e1..fc0be55 100644 --- a/config/lvim/lua/user/keymaps.lua +++ b/config/lvim/lua/user/keymaps.lua @@ -1,9 +1,10 @@ lvim.keys.normal_mode[""] = "BufferClose" lvim.keys.normal_mode[""] = "w" +lvim.keys.term_mode["jk"] = "" lvim.keys.visual_mode["jk"] = "" -- Which key -lvim.builtin.which_key.mappings.l.a = { "Telescope lsp_code_actions", "Code Actions" } +-- lvim.builtin.which_key.mappings.l.a = { "Telescope lsp_code_actions", "Code Actions" } lvim.builtin.which_key.mappings.l.d = { "TroubleToggle", "Diagnostics" } lvim.builtin.which_key.mappings.l.R = { "TroubleToggle lsp_references", "References" } lvim.builtin.which_key.mappings.s.P = { "Telescope projects", "Projects" } @@ -19,6 +20,7 @@ lvim.builtin.which_key.mappings["t"] = { } -- Beffers +lvim.keys.normal_mode[""] = "BufferLast" local fmt = string.format for i = 1, 9 do lvim.keys.normal_mode[fmt("", i)] = fmt("BufferGoto %d", i) diff --git a/config/lvim/lua/user/plugins.lua b/config/lvim/lua/user/plugins.lua index 1fd7d45..9687f9c 100644 --- a/config/lvim/lua/user/plugins.lua +++ b/config/lvim/lua/user/plugins.lua @@ -11,7 +11,7 @@ lvim.plugins = { "folke/todo-comments.nvim", event = "BufRead", config = function() - require "plug.todo-comment" + require("plug.todo-comment").setup() end, }, { @@ -19,7 +19,7 @@ lvim.plugins = { run = "./install.sh", event = "InsertEnter", config = function() - require "plug.tabnine" + require("plug.tabnine").setup() end, }, { @@ -33,7 +33,7 @@ lvim.plugins = { "Smirnov-O/ts-unit.nvim", keys = { "vip", "cip", "yip", "dip" }, config = function() - require "plug.ts-unit" + require("plug.ts-unit").setup() end, }, { @@ -41,13 +41,10 @@ lvim.plugins = { requires = { { "vim-test/vim-test", after = "vim-ultest" }, }, + cmd = { "Ultest", "UltestStop", "UltestClear", "UltestNearest", "UltestOutput" }, run = ":UpdateRemotePlugins", - cmd = { - "Ultest", - "UltestStop", - "UltestClear", - "UltestNearest", - "UltestOutput", - }, + config = function() + require("plug.ultest").setup() + end, }, }