From 866a0b32802980bb682b80f17f9e85a34183e34f Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 12 Feb 2023 15:03:08 +0800 Subject: [PATCH 001/708] java-deps --- lua/kide/plugins/lazy-nvim.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index b7b853da..544c4062 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -163,9 +163,10 @@ require("lazy").setup({ { "JavaHello/java-deps.nvim", lazy = true, - ft = { "java" }, + ft = "java", + dependencies = "mfussenegger/nvim-jdtls", config = function() - require("java-deps").setup() + require("java-deps").setup({}) end, }, From befb26f388430b5c2c779d4e7e64526f0d60b101 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 13 Feb 2023 09:13:01 +0800 Subject: [PATCH 002/708] lua_ls --- lua/kide/lsp/init.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index cb20b88e..2ddec97d 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -1,8 +1,7 @@ local mason_lspconfig = require("mason-lspconfig") mason_lspconfig.setup({ ensure_installed = { - -- "lua-language-server", - "sumneko_lua", + "lua_ls", }, }) @@ -38,10 +37,6 @@ require("mason-lspconfig").setup_handlers({ -- and will be called for each installed server that doesn't have -- a dedicated handler. function(server_name) -- default handler (optional) - -- sumneko_lua -> lua_ls - if server_name == "sumneko_lua" then - server_name = "lua_ls" - end local lspconfig = require("lspconfig") -- tools config local cfg = utils.or_default(server_configs[server_name], {}) From 2d4cd2482ce225fee75578af9a065f83d4547764 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 13 Feb 2023 09:47:05 +0800 Subject: [PATCH 003/708] =?UTF-8?q?semgrep=20=E6=9A=82=E6=97=B6=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/null-ls.lua | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lua/kide/plugins/config/null-ls.lua b/lua/kide/plugins/config/null-ls.lua index 1e57cd0b..6fbc0d79 100644 --- a/lua/kide/plugins/config/null-ls.lua +++ b/lua/kide/plugins/config/null-ls.lua @@ -111,17 +111,9 @@ local on_attach = function(client, bufnr) end end -if "1" == os.getenv("SEMGREP_ENABLE") then - table.insert( - sources, - null_ls.builtins.diagnostics.semgrep.with({ - filetypes = { "java" }, - extra_args = { "--config", os.getenv("SEMGREP_RULES_PATH") .. "/java" }, - method = null_ls.methods.DIAGNOSTICS_ON_SAVE, - }) - ) -end -if "1" == os.getenv("PMD_ENABLE") then +if "Y" == os.getenv("SEMGREP_ENABLE") then + table.insert(sources, null_ls.builtins.diagnostics.semgrep) +elseif "Y" == os.getenv("PMD_ENABLE") then table.insert( sources, null_ls.builtins.diagnostics.pmd.with({ From 89271c6d80095d129dd3cfb8e694cae60efb6b71 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 14 Feb 2023 09:24:30 +0800 Subject: [PATCH 004/708] trans --- lua/kide/plugins/lazy-nvim.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 544c4062..68a67ded 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -443,6 +443,7 @@ require("lazy").setup({ { "uga-rosa/translate.nvim", lazy = true, + cmd = "Translate", config = function() require("kide.plugins.config.translate") end, From 3a705be1db3c0540a1aa65ecc5e7c28cfb1fbf40 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 15 Feb 2023 09:59:04 +0800 Subject: [PATCH 005/708] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E2=9C=94=E5=AD=97?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/lazy-nvim.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 68a67ded..1d342e2b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -543,7 +543,11 @@ require("lazy").setup({ "j-hui/fidget.nvim", lazy = true, config = function() - require("fidget").setup({}) + require("fidget").setup({ + text = { + done = "", + }, + }) end, }, @@ -684,4 +688,10 @@ require("lazy").setup({ require("chatgpt").setup({}) end, }, +}, { + ui = { + icons = { + task = " ", + }, + }, }) From 8e5499fe27330da24166567a448b80644a1ca146 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 17 Feb 2023 15:30:09 +0800 Subject: [PATCH 006/708] make install_jsregexp --- lua/kide/plugins/lazy-nvim.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 1d342e2b..afdf24db 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -45,6 +45,7 @@ require("lazy").setup({ "L3MON4D3/LuaSnip", lazy = true, dependencies = { "rafamadriz/friendly-snippets" }, + build = "make install_jsregexp", config = function() require("kide.plugins.config.luasnip") end, From 1d64be621cb93308dbba21583d261ab4c5f9525a Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 17 Feb 2023 15:48:27 +0800 Subject: [PATCH 007/708] lazy_load --- lua/kide/plugins/config/luasnip.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/luasnip.lua b/lua/kide/plugins/config/luasnip.lua index 73574b89..818dfff1 100644 --- a/lua/kide/plugins/config/luasnip.lua +++ b/lua/kide/plugins/config/luasnip.lua @@ -503,4 +503,4 @@ ls.filetype_set("cpp", { "c" }) -- Mind that this will extend `ls.snippets` so you need to do it after your own snippets or you -- will need to extend the table yourself instead of setting a new one. -require("luasnip.loaders.from_vscode").load() -- Load only python snippets +require("luasnip.loaders.from_vscode").lazy_load() From 3821fef3c516c61b0168a04d7887d81e0b3d116d Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 18 Feb 2023 21:00:02 +0800 Subject: [PATCH 008/708] lua snippets --- lua/kide/core/keybindings.lua | 6 + lua/kide/plugins/config/luasnip.lua | 449 +--------------------------- lua/kide/snippets/java.lua | 80 +++++ 3 files changed, 88 insertions(+), 447 deletions(-) create mode 100644 lua/kide/snippets/java.lua diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index f8be0306..3cedeb71 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -147,6 +147,12 @@ nnoremap l -- nvimTree map("n", "e", ":NvimTreeToggle", opt) + + -- set keybinds for both INSERT and VISUAL. + vim.api.nvim_set_keymap("i", "", "luasnip-next-choice", {}) + vim.api.nvim_set_keymap("s", "", "luasnip-next-choice", {}) + vim.api.nvim_set_keymap("i", "", "luasnip-prev-choice", {}) + vim.api.nvim_set_keymap("s", "", "luasnip-prev-choice", {}) end -- lsp 回调函数快捷键设置 M.maplsp = function(client, buffer) diff --git a/lua/kide/plugins/config/luasnip.lua b/lua/kide/plugins/config/luasnip.lua index 818dfff1..d5e81e7e 100644 --- a/lua/kide/plugins/config/luasnip.lua +++ b/lua/kide/plugins/config/luasnip.lua @@ -1,37 +1,14 @@ local ls = require("luasnip") --- some shorthands... local s = ls.snippet -local sn = ls.snippet_node local t = ls.text_node -local i = ls.insert_node -local f = ls.function_node -local c = ls.choice_node -local d = ls.dynamic_node -local r = ls.restore_node -local l = require("luasnip.extras").lambda -local rep = require("luasnip.extras").rep -local p = require("luasnip.extras").partial -local m = require("luasnip.extras").match -local n = require("luasnip.extras").nonempty -local dl = require("luasnip.extras").dynamic_lambda -local fmt = require("luasnip.extras.fmt").fmt -local fmta = require("luasnip.extras.fmt").fmta local types = require("luasnip.util.types") -local conds = require("luasnip.extras.expand_conditions") - --- If you're reading this file for the first time, best skip to around line 190 --- where the actual snippet-definitions start. -- Every unspecified option will be set to the default. ls.config.set_config({ history = true, -- Update more often, :h events for more info. updateevents = "TextChanged,TextChangedI", - -- Snippets aren't automatically removed if their text is deleted. - -- `delete_check_events` determines on which events (:h events) a check for - -- deleted snippets is performed. - -- This can be especially useful when `history` is enabled. delete_check_events = "TextChanged", ext_opts = { [types.choiceNode] = { @@ -65,425 +42,6 @@ ls.config.set_config({ end, }) --- args is a table, where 1 is the text in Placeholder 1, 2 the text in --- placeholder 2,... -local function copy(args) - return args[1] -end - --- 'recursive' dynamic snippet. Expands to some text followed by itself. -local rec_ls -rec_ls = function() - return sn( - nil, - c(1, { - -- Order is important, sn(...) first would cause infinite loop of expansion. - t(""), - sn(nil, { t({ "", "\t\\item " }), i(1), d(2, rec_ls, {}) }), - }) - ) -end - --- complicated function for dynamicNode. -local function jdocsnip(args, _, old_state) - -- !!! old_state is used to preserve user-input here. DON'T DO IT THAT WAY! - -- Using a restoreNode instead is much easier. - -- View this only as an example on how old_state functions. - local nodes = { - t({ "/**", " * " }), - i(1, "A short Description"), - t({ "", "" }), - } - - -- These will be merged with the snippet; that way, should the snippet be updated, - -- some user input eg. text can be referred to in the new snippet. - local param_nodes = {} - - if old_state then - nodes[2] = i(1, old_state.descr:get_text()) - end - param_nodes.descr = nodes[2] - - -- At least one param. - if string.find(args[2][1], ", ") then - vim.list_extend(nodes, { t({ " * ", "" }) }) - end - - local insert = 2 - for indx, arg in ipairs(vim.split(args[2][1], ", ", true)) do - -- Get actual name parameter. - arg = vim.split(arg, " ", true)[2] - if arg then - local inode - -- if there was some text in this parameter, use it as static_text for this new snippet. - if old_state and old_state[arg] then - inode = i(insert, old_state["arg" .. arg]:get_text()) - else - inode = i(insert) - end - vim.list_extend(nodes, { t({ " * @param " .. arg .. " " }), inode, t({ "", "" }) }) - param_nodes["arg" .. arg] = inode - - insert = insert + 1 - end - end - - if args[1][1] ~= "void" then - local inode - if old_state and old_state.ret then - inode = i(insert, old_state.ret:get_text()) - else - inode = i(insert) - end - - vim.list_extend(nodes, { t({ " * ", " * @return " }), inode, t({ "", "" }) }) - param_nodes.ret = inode - insert = insert + 1 - end - - if vim.tbl_count(args[3]) ~= 1 then - local exc = string.gsub(args[3][2], " throws ", "") - local ins - if old_state and old_state.ex then - ins = i(insert, old_state.ex:get_text()) - else - ins = i(insert) - end - vim.list_extend(nodes, { t({ " * ", " * @throws " .. exc .. " " }), ins, t({ "", "" }) }) - param_nodes.ex = ins - insert = insert + 1 - end - - vim.list_extend(nodes, { t({ " */" }) }) - - local snip = sn(nil, nodes) - -- Error on attempting overwrite. - snip.old_state = param_nodes - return snip -end - --- Make sure to not pass an invalid command, as io.popen() may write over nvim-text. -local function bash(_, _, command) - local file = io.popen(command, "r") - local res = {} - for line in file:lines() do - table.insert(res, line) - end - return res -end - --- Returns a snippet_node wrapped around an insert_node whose initial --- text value is set to the current date in the desired format. -local date_input = function(args, state, fmt) - local fmt = fmt or "%Y-%m-%d" - return sn(nil, i(1, os.date(fmt))) -end - -ls.snippets = { - -- When trying to expand a snippet, luasnip first searches the tables for - -- each filetype specified in 'filetype' followed by 'all'. - -- If ie. the filetype is 'lua.c' - -- - luasnip.lua - -- - luasnip.c - -- - luasnip.all - -- are searched in that order. - all = { - -- trigger is `fn`, second argument to snippet-constructor are the nodes to insert into the buffer on expansion. - s("fn", { - -- Simple static text. - t("//Parameters: "), - -- function, first parameter is the function, second the Placeholders - -- whose text it gets as input. - f(copy, 2), - t({ "", "function " }), - -- Placeholder/Insert. - i(1), - t("("), - -- Placeholder with initial text. - i(2, "int foo"), - -- Linebreak - t({ ") {", "\t" }), - -- Last Placeholder, exit Point of the snippet. - i(0), - t({ "", "}" }), - }), - s("class", { - -- Choice: Switch between two different Nodes, first parameter is its position, second a list of nodes. - c(1, { - t("public "), - t("private "), - }), - t("class "), - i(2), - t(" "), - c(3, { - t("{"), - -- sn: Nested Snippet. Instead of a trigger, it has a position, just like insert-nodes. !!! These don't expect a 0-node!!!! - -- Inside Choices, Nodes don't need a position as the choice node is the one being jumped to. - sn(nil, { - t("extends "), - -- restoreNode: stores and restores nodes. - -- pass position, store-key and nodes. - r(1, "other_class", i(1)), - t(" {"), - }), - sn(nil, { - t("implements "), - -- no need to define the nodes for a given key a second time. - r(1, "other_class"), - t(" {"), - }), - }), - t({ "", "\t" }), - i(0), - t({ "", "}" }), - }), - -- Alternative printf-like notation for defining snippets. It uses format - -- string with placeholders similar to the ones used with Python's .format(). - s( - "fmt1", - fmt("To {title} {} {}.", { - i(2, "Name"), - i(3, "Surname"), - title = c(1, { t("Mr."), t("Ms.") }), - }) - ), - -- To escape delimiters use double them, e.g. `{}` -> `{{}}`. - -- Multi-line format strings by default have empty first/last line removed. - -- Indent common to all lines is also removed. Use the third `opts` argument - -- to control this behaviour. - s( - "fmt2", - fmt( - [[ - foo({1}, {3}) {{ - return {2} * {4} - }} - ]], - { - i(1, "x"), - rep(1), - i(2, "y"), - rep(2), - } - ) - ), - -- Empty placeholders are numbered automatically starting from 1 or the last - -- value of a numbered placeholder. Named placeholders do not affect numbering. - s( - "fmt3", - fmt("{} {a} {} {1} {}", { - t("1"), - t("2"), - a = t("A"), - }) - ), - -- The delimiters can be changed from the default `{}` to something else. - s("fmt4", fmt("foo() { return []; }", i(1, "x"), { delimiters = "[]" })), - -- `fmta` is a convenient wrapper that uses `<>` instead of `{}`. - s("fmt5", fmta("foo() { return <>; }", i(1, "x"))), - -- By default all args must be used. Use strict=false to disable the check - s("fmt6", fmt("use {} only", { t("this"), t("not this") }, { strict = false })), - -- Use a dynamic_node to interpolate the output of a - -- function (see date_input above) into the initial - -- value of an insert_node. - s("novel", { - t("It was a dark and stormy night on "), - d(1, date_input, {}, "%A, %B %d of %Y"), - t(" and the clocks were striking thirteen."), - }), - -- Parsing snippets: First parameter: Snippet-Trigger, Second: Snippet body. - -- Placeholders are parsed into choices with 1. the placeholder text(as a snippet) and 2. an empty string. - -- This means they are not SELECTed like in other editors/Snippet engines. - ls.parser.parse_snippet("lspsyn", "Wow! This ${1:Stuff} really ${2:works. ${3:Well, a bit.}}"), - - -- When wordTrig is set to false, snippets may also expand inside other words. - ls.parser.parse_snippet({ trig = "te", wordTrig = false }, "${1:cond} ? ${2:true} : ${3:false}"), - - -- When regTrig is set, trig is treated like a pattern, this snippet will expand after any number. - ls.parser.parse_snippet({ trig = "%d", regTrig = true }, "A Number!!"), - -- Using the condition, it's possible to allow expansion only in specific cases. - s("cond", { - t("will only expand in c-style comments"), - }, { - condition = function(line_to_cursor, matched_trigger, captures) - -- optional whitespace followed by // - return line_to_cursor:match("%s*//") - end, - }), - -- there's some built-in conditions in "luasnip.extras.expand_conditions". - s("cond2", { - t("will only expand at the beginning of the line"), - }, { - condition = conds.line_begin, - }), - -- The last entry of args passed to the user-function is the surrounding snippet. - s( - { trig = "a%d", regTrig = true }, - f(function(_, snip) - return "Triggered with " .. snip.trigger .. "." - end, {}) - ), - -- It's possible to use capture-groups inside regex-triggers. - s( - { trig = "b(%d)", regTrig = true }, - f(function(_, snip) - return "Captured Text: " .. snip.captures[1] .. "." - end, {}) - ), - s({ trig = "c(%d+)", regTrig = true }, { - t("will only expand for even numbers"), - }, { - condition = function(line_to_cursor, matched_trigger, captures) - return tonumber(captures[1]) % 2 == 0 - end, - }), - -- Use a function to execute any shell command and print its text. - s("bash", f(bash, {}, "ls")), - -- Short version for applying String transformations using function nodes. - s("transform", { - i(1, "initial text"), - t({ "", "" }), - -- lambda nodes accept an l._1,2,3,4,5, which in turn accept any string transformations. - -- This list will be applied in order to the first node given in the second argument. - l(l._1:match("[^i]*$"):gsub("i", "o"):gsub(" ", "_"):upper(), 1), - }), - s("transform2", { - i(1, "initial text"), - t("::"), - i(2, "replacement for e"), - t({ "", "" }), - -- Lambdas can also apply transforms USING the text of other nodes: - l(l._1:gsub("e", l._2), { 1, 2 }), - }), - s({ trig = "trafo(%d+)", regTrig = true }, { - -- env-variables and captures can also be used: - l(l.CAPTURE1:gsub("1", l.TM_FILENAME), {}), - }), - -- Set store_selection_keys = "" (for example) in your - -- luasnip.config.setup() call to populate - -- TM_SELECTED_TEXT/SELECT_RAW/SELECT_DEDENT. - -- In this case: select a URL, hit Tab, then expand this snippet. - s("link_url", { - t(''), - i(1), - t(""), - i(0), - }), - -- Shorthand for repeating the text in a given node. - s("repeat", { i(1, "text"), t({ "", "" }), rep(1) }), - -- Directly insert the ouput from a function evaluated at runtime. - s("part", p(os.date, "%Y")), - -- use matchNodes (`m(argnode, condition, then, else)`) to insert text - -- based on a pattern/function/lambda-evaluation. - -- It's basically a shortcut for simple functionNodes: - s("mat", { - i(1, { "sample_text" }), - t(": "), - m(1, "%d", "contains a number", "no number :("), - }), - -- The `then`-text defaults to the first capture group/the entire - -- match if there are none. - s("mat2", { - i(1, { "sample_text" }), - t(": "), - m(1, "[abc][abc][abc]"), - }), - -- It is even possible to apply gsubs' or other transformations - -- before matching. - s("mat3", { - i(1, { "sample_text" }), - t(": "), - m(1, l._1:gsub("[123]", ""):match("%d"), "contains a number that isn't 1, 2 or 3!"), - }), - -- `match` also accepts a function in place of the condition, which in - -- turn accepts the usual functionNode-args. - -- The condition is considered true if the function returns any - -- non-nil/false-value. - -- If that value is a string, it is used as the `if`-text if no if is explicitly given. - s("mat4", { - i(1, { "sample_text" }), - t(": "), - m(1, function(args) - -- args is a table of multiline-strings (as usual). - return (#args[1][1] % 2 == 0 and args[1]) or nil - end), - }), - -- The nonempty-node inserts text depending on whether the arg-node is - -- empty. - s("nempty", { - i(1, "sample_text"), - n(1, "i(1) is not empty!"), - }), - -- dynamic lambdas work exactly like regular lambdas, except that they - -- don't return a textNode, but a dynamicNode containing one insertNode. - -- This makes it easier to dynamically set preset-text for insertNodes. - s("dl1", { - i(1, "sample_text"), - t({ ":", "" }), - dl(2, l._1, 1), - }), - -- Obviously, it's also possible to apply transformations, just like lambdas. - s("dl2", { - i(1, "sample_text"), - i(2, "sample_text_2"), - t({ "", "" }), - dl(3, l._1:gsub("\n", " linebreak ") .. l._2, { 1, 2 }), - }), - }, - java = { - -- Very long example for a java class. - s("fn", { - d(6, jdocsnip, { 2, 4, 5 }), - t({ "", "" }), - c(1, { - t("public "), - t("private "), - }), - c(2, { - t("void"), - t("String"), - t("char"), - t("int"), - t("double"), - t("boolean"), - i(nil, ""), - }), - t(" "), - i(3, "myFunc"), - t("("), - i(4), - t(")"), - c(5, { - t(""), - sn(nil, { - t({ "", " throws " }), - i(1), - }), - }), - t({ " {", "\t" }), - i(0), - t({ "", "}" }), - }), - }, - tex = { - -- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many - -- \item as necessary by utilizing a choiceNode. - s("ls", { - t({ "\\begin{itemize}", "\t\\item " }), - i(1), - d(2, rec_ls, {}), - t({ "", "\\end{itemize}" }), - }), - }, -} - -- autotriggered snippets have to be defined in a separate table, luasnip.autosnippets. ls.autosnippets = { all = { @@ -498,9 +56,6 @@ ls.filetype_extend("lua", { "c" }) -- in a cpp file: search c-snippets, then all-snippets only (no cpp-snippets!!). ls.filetype_set("cpp", { "c" }) --- Beside defining your own snippets you can also load snippets from "vscode-like" packages --- that expose snippets in json files, for example . --- Mind that this will extend `ls.snippets` so you need to do it after your own snippets or you --- will need to extend the table yourself instead of setting a new one. +-- require("luasnip.loaders.from_vscode").lazy_load() -require("luasnip.loaders.from_vscode").lazy_load() +require("kide.snippets.java") diff --git a/lua/kide/snippets/java.lua b/lua/kide/snippets/java.lua new file mode 100644 index 00000000..33fded53 --- /dev/null +++ b/lua/kide/snippets/java.lua @@ -0,0 +1,80 @@ +local ls = require("luasnip") + +-- some shorthands... +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local l = require("luasnip.extras").lambda +local rep = require("luasnip.extras").rep +local p = require("luasnip.extras").partial +local m = require("luasnip.extras").match +local n = require("luasnip.extras").nonempty +local dl = require("luasnip.extras").dynamic_lambda +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local types = require("luasnip.util.types") +local conds = require("luasnip.extras.expand_conditions") + +ls.add_snippets("java", { + s("sout", { + t({ "System.out.println(" }), + i(1), + t({ ");" }), + }), + s("main", { + t({ "public static void main(String[] args) {" }), + t({ "", "\t" }), + i(0), + t({ "", "}" }), + }), + s("field", { + c(1, { + t("private"), + t("public"), + t("protected"), + }), + t(" "), + c(2, { + t(""), + t({ "static " }), + t({ "final static " }), + }), + i(3, "String"), + t(" "), + i(4, "name"), + t({ ";" }), + }), + s("fn", { + c(1, { + t("public"), + t("protected"), + t("private"), + }), + t(" "), + c(2, { + t(""), + t({ "static " }), + t({ "final static " }), + }), + i(3, "void"), + t(" "), + i(4, "name"), + t("()"), + c(5, { + t(""), + sn(nil, { + t({ " throws " }), + i(1, "Exception"), + }), + }), + t(" {"), + t({ "", "\t" }), + i(0), + t({ "", "}" }), + }), +}) From 80a56e405ce8987a722cbb15a5a160034ec9efa3 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 18 Feb 2023 21:49:03 +0800 Subject: [PATCH 009/708] ifn, afn --- lua/kide/snippets/java.lua | 181 ++++++++++++++++++++++++++++++++++++- 1 file changed, 180 insertions(+), 1 deletion(-) diff --git a/lua/kide/snippets/java.lua b/lua/kide/snippets/java.lua index 33fded53..6c1f3bc7 100644 --- a/lua/kide/snippets/java.lua +++ b/lua/kide/snippets/java.lua @@ -64,8 +64,56 @@ ls.add_snippets("java", { i(3, "void"), t(" "), i(4, "name"), - t("()"), + t("("), c(5, { + t(""), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + t(", "), + i(5, { "String" }), + t(" "), + i(6, { "arg3" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + t(", "), + i(5, { "String" }), + t(" "), + i(6, { "arg3" }), + t(", "), + i(7, { "String" }), + t(" "), + i(8, { "arg4" }), + }), + }), + t(")"), + c(6, { t(""), sn(nil, { t({ " throws " }), @@ -77,4 +125,135 @@ ls.add_snippets("java", { i(0), t({ "", "}" }), }), + + s("afn", { + c(1, { + t("protected"), + t("public"), + }), + t(" abstract "), + i(2, "void"), + t(" "), + i(3, "name"), + t("("), + c(4, { + t(""), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + t(", "), + i(5, { "String" }), + t(" "), + i(6, { "arg3" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + t(", "), + i(5, { "String" }), + t(" "), + i(6, { "arg3" }), + t(", "), + i(7, { "String" }), + t(" "), + i(8, { "arg4" }), + }), + }), + t(")"), + c(5, { + t(""), + sn(nil, { + t({ " throws " }), + i(1, "Exception"), + }), + }), + t(";"), + }), + + s("ifn", { + i(1, "void"), + t(" "), + i(2, "name"), + t("("), + c(3, { + t(""), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + t(", "), + i(5, { "String" }), + t(" "), + i(6, { "arg3" }), + }), + sn(nil, { + i(1, { "String" }), + t(" "), + i(2, { "arg1" }), + t(", "), + i(3, { "String" }), + t(" "), + i(4, { "arg2" }), + t(", "), + i(5, { "String" }), + t(" "), + i(6, { "arg3" }), + t(", "), + i(7, { "String" }), + t(" "), + i(8, { "arg4" }), + }), + }), + t(")"), + c(4, { + t(""), + sn(nil, { + t({ " throws " }), + i(1, "Exception"), + }), + }), + t(";"), + }), }) From cfeadfbfbf5dc7fe8222b1b571f8d430b388c079 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 19 Feb 2023 10:50:28 +0800 Subject: [PATCH 010/708] final --- lua/kide/snippets/java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/snippets/java.lua b/lua/kide/snippets/java.lua index 6c1f3bc7..8843e85b 100644 --- a/lua/kide/snippets/java.lua +++ b/lua/kide/snippets/java.lua @@ -59,7 +59,7 @@ ls.add_snippets("java", { c(2, { t(""), t({ "static " }), - t({ "final static " }), + t({ "final " }), }), i(3, "void"), t(" "), From dd8d9a799976bb8c5f71ac7abffd7cc4978f9702 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 19 Feb 2023 11:18:39 +0800 Subject: [PATCH 011/708] final --- lua/kide/snippets/java.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/snippets/java.lua b/lua/kide/snippets/java.lua index 8843e85b..b858046d 100644 --- a/lua/kide/snippets/java.lua +++ b/lua/kide/snippets/java.lua @@ -42,6 +42,7 @@ ls.add_snippets("java", { c(2, { t(""), t({ "static " }), + t({ "final " }), t({ "final static " }), }), i(3, "String"), From bbd9dea121219106c06865541742997370551fdc Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 20 Feb 2023 09:25:49 +0800 Subject: [PATCH 012/708] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=BF=87=E6=97=B6?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/nvim-tree.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/kide/plugins/config/nvim-tree.lua b/lua/kide/plugins/config/nvim-tree.lua index 6e0e98d5..93830b5f 100644 --- a/lua/kide/plugins/config/nvim-tree.lua +++ b/lua/kide/plugins/config/nvim-tree.lua @@ -4,8 +4,6 @@ end require("nvim-tree").setup({ disable_netrw = true, hijack_netrw = true, - open_on_setup = false, - ignore_ft_on_setup = { "dashboard", "alpha" }, -- auto_close = true, auto_reload_on_write = true, open_on_tab = false, From d6c2032798d67853cb698571d03896b82689d419 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 20 Feb 2023 09:53:40 +0800 Subject: [PATCH 013/708] bufopts --- lua/kide/core/keybindings.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 3cedeb71..4d76a318 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -159,6 +159,7 @@ M.maplsp = function(client, buffer) vim.api.nvim_buf_set_option(buffer, "omnifunc", "v:lua.vim.lsp.omnifunc") vim.api.nvim_buf_set_option(buffer, "formatexpr", "v:lua.vim.lsp.formatexpr()") + local bufopts = { noremap = true, silent = true, buffer = buffer } vim.api.nvim_buf_set_keymap(buffer, "n", "K", "lua vim.lsp.buf.hover()", opt) -- rename vim.api.nvim_buf_set_keymap(buffer, "n", "rn", "lua vim.lsp.buf.rename()", opt) @@ -224,7 +225,7 @@ M.maplsp = function(client, buffer) return require("kide.lsp.utils").filter_format_lsp_client(c, bfn) end, }) - end, opt) + end, bufopts) vim.api.nvim_buf_set_keymap( buffer, "v", From 6af18ad8f34e56145299fe2945b067f0ca95ded8 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 22 Feb 2023 23:40:53 +0800 Subject: [PATCH 014/708] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/basic.lua | 58 ++++---- lua/kide/core/keybindings.lua | 132 +++++-------------- lua/kide/core/utils/init.lua | 9 +- lua/kide/plugins/config/markdown-preview.lua | 93 +------------ lua/kide/plugins/config/rest-nvim.lua | 10 ++ lua/kide/plugins/lazy-nvim.lua | 16 +-- 6 files changed, 72 insertions(+), 246 deletions(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 5fd37c16..c40df75d 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -32,7 +32,7 @@ vim.opt.ruler = false vim.wo.cursorline = true -- 右侧参考线,超过表示代码太长了,考虑换行 --- vim.wo.colorcolumn = "80" +vim.wo.colorcolumn = "120" -- 边搜索边高亮 vim.o.incsearch = true @@ -79,17 +79,6 @@ autocmd("FileType", { end, }) --- vim.cmd("autocmd Filetype lua setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype js setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype javascript setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype json setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype css setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype html setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype xml setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype yaml setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype http setlocal ts=2 sw=2 expandtab") --- vim.cmd("autocmd Filetype markdown setlocal ts=2 sw=2 expandtab") - -- 新行对齐当前行,空格替代tab vim.o.expandtab = true vim.bo.expandtab = true @@ -148,26 +137,25 @@ vim.api.nvim_create_autocmd({ "TextYankPost" }, { end, }) -vim.cmd([[ -set completeopt=menu,menuone,noselect - -if exists('g:neovide') - " let g:neovide_refresh_rate=60 - let g:neovide_cursor_vfx_mode = "railgun" - set guifont=Hack\ Nerd\ Font\ Mono,Hack:h13 - " let g:neovide_transparency=1 - let g:neovide_fullscreen=v:true - " let g:neovide_remember_window_size = v:true - let g:neovide_input_use_logo=v:true - let g:neovide_profiler = v:false -else -endif -if has("autocmd") - au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif -endif - -" set grepprg=rg\ --vimgrep -set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case -" set grepformat^=%f:%l:%c:%m -set grepformat=%f:%l:%c:%m,%f:%l:%m -]]) +vim.opt_global.completeopt = "menu,menuone,noselect" +if vim.g.neovide then + vim.g.neovide_cursor_vfx_mode = "railgun" + vim.opt_global.guifont = "Hack Nerd Font Mono,Hack:h13" + vim.g.neovide_transparency = 1 + vim.g.neovide_fullscreen = true + vim.g.neovide_input_use_logo = true + vim.g.neovide_profiler = false +end + +autocmd("BufReadPost", { + pattern = "*", + callback = function() + local l = vim.fn.line("'\"") + if l > 1 and l <= vim.fn.line("$") then + vim.fn.execute("normal! g'\"") + end + end, +}) + +vim.opt_global.grepprg = "rg --vimgrep --no-heading --smart-case" +vim.opt_global.grepformat = "%f:%l:%c:%m,%f:%l:%m" diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 4d76a318..311884d7 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -4,12 +4,11 @@ local map = vim.api.nvim_set_keymap local opt = { noremap = true, silent = true } local keymap = vim.keymap.set - local M = {} M.setup = function() -- Esc - -- map('i', 'jk', '', opt) + map("i", "jk", "", opt) -- n 模式下复制内容到系统剪切板 map("n", "c", '"+yy', opt) -- v 模式下复制内容到系统剪切板 @@ -18,9 +17,12 @@ M.setup = function() map("n", "v", '"+p', opt) -- 取消搜索高亮显示 map("n", "", ":nohlsearch", opt) - -- %bd 删除所有缓冲区, e# 打开最后一个缓冲区, bd# 关闭[No Name] - -- map('n', 'o', ':%bd|e#|bd#', opt) - -- map('n', 'o', 'lua require("kide.core.utils").close_other_bufline()', opt) + + keymap("n", "", "h", opt) + keymap("n", "", "j", opt) + keymap("n", "", "k", opt) + keymap("n", "", "l", opt) + vim.api.nvim_create_user_command("BufferCloseOther", function() require("kide.core.utils").close_other_bufline() end, {}) @@ -39,29 +41,12 @@ M.setup = function() map("t", "", "", opt) map("t", "jk", "", opt) - -- Leaderf - -- vim.g.Lf_ShortcutF = '' - -- map('n', '', ':=printf("Leaderf! rg -e %s ", expand(""))', {}) - -- map('v', '', ':=printf("Leaderf! rg -e %s ", leaderf#Rg#visual())', {}) - -- map('n', 'r', ':Leaderf --nowrap task', {}) - - -- vim-floaterm - -- vim.g.floaterm_keymap_new = 'ft' - -- map('n', '', ':FloatermToggle', opt) - -- map('t', ' ', '::FloatermToggle', opt) + -- ToggleTerm map("n", "", ":ToggleTerm", opt) -- symbols-outline.nvim map("n", "o", ":SymbolsOutline", opt) - -- trouble.nvim - -- see lsp map - -- map('n', 'x', 'Trouble', opt) - - -- lspsaga - -- map('n', 'K', ':Lspsaga hover_doc', opt) - -- map('n', 'gr', ':Lspsaga lsp_finder', opt) - -- Telescope map("n", "ff", "Telescope find_files", opt) keymap("v", "ff", function() @@ -88,59 +73,36 @@ M.setup = function() -- camel_case require("kide.core.utils").camel_case_init() - -- vim-easy-align - vim.cmd([[ -" Start interactive EasyAlign in visual mode (e.g. vipga) -xmap ga (EasyAlign) - -" Start interactive EasyAlign for a motion/text object (e.g. gaip) -nmap ga (EasyAlign) -]]) - -- nvim-dap - vim.cmd([[ -nnoremap :lua require'dap'.continue() -nnoremap :lua require'dap'.step_over() -nnoremap :lua require'dap'.step_into() -nnoremap :lua require'dap'.step_out() -nnoremap db :lua require'dap'.toggle_breakpoint() -nnoremap dB :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: ')) -nnoremap dp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) -nnoremap dr :lua require'dap'.repl.open() -nnoremap dl :lua require'dap'.run_last() -]]) + keymap("n", "", ":lua require'dap'.continue()", opt) + keymap("n", "", ":lua require'dap'.step_over()", opt) + keymap("n", "", ":lua require'dap'.step_into()", opt) + keymap("n", "", ":lua require'dap'.step_out()", opt) + keymap("n", "db", ":lua require'dap'.toggle_breakpoint()", opt) + keymap("n", "dB", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))", opt) + keymap("n", "dp", ":lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))", opt) + keymap("n", "dr", ":lua require'dap'.repl.open()", opt) + keymap("n", "dl", ":lua require'dap'.run_last()", opt) -- nvim-dap-ui - vim.cmd([[ -nnoremap dr :lua require("dapui").float_element(vim.Nil, { enter = true}) -]]) + keymap("n", "ds", ':lua require("dapui").float_element(vim.Nil, { enter = true}) ', opt) -- bufferline.nvim - vim.cmd([[ -nnoremap 1 BufferLineGoToBuffer 1 -nnoremap 2 BufferLineGoToBuffer 2 -nnoremap 3 BufferLineGoToBuffer 3 -nnoremap 4 BufferLineGoToBuffer 4 -nnoremap 5 BufferLineGoToBuffer 5 -nnoremap 6 BufferLineGoToBuffer 6 -nnoremap 7 BufferLineGoToBuffer 7 -nnoremap 8 BufferLineGoToBuffer 8 -nnoremap 9 BufferLineGoToBuffer 9 - -nnoremap h -nnoremap j -nnoremap k -nnoremap l -]]) + keymap("n", "1", "BufferLineGoToBuffer 1", opt) + keymap("n", "2", "BufferLineGoToBuffer 2", opt) + keymap("n", "3", "BufferLineGoToBuffer 3", opt) + keymap("n", "4", "BufferLineGoToBuffer 4", opt) + keymap("n", "5", "BufferLineGoToBuffer 5", opt) + keymap("n", "6", "BufferLineGoToBuffer 6", opt) + keymap("n", "7", "BufferLineGoToBuffer 7", opt) + keymap("n", "8", "BufferLineGoToBuffer 8", opt) + keymap("n", "9", "BufferLineGoToBuffer 9", opt) -- nvim-spectre map("n", "S", "lua require('spectre').open()", opt) -- search current word map("n", "fr", "lua require('spectre').open_visual({select_word=true})", opt) map("v", "fr", ":lua require('spectre').open_visual()", opt) - -- search in current file - -- map("n", "fp", "viw:lua require('spectre').open_file_search()", opt) - -- run command :Spectre -- ToggleTask map("n", "ts", "Telescope toggletasks spawn", opt) @@ -212,10 +174,6 @@ M.maplsp = function(client, buffer) "lua vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR })", opt ) - -- mapbuf('n', 'q', 'lua vim.diagnostic.setloclist()', opt) - -- leader + = - -- vim.api.nvim_buf_set_keymap(bufnr, 'n', '=', 'lua vim.lsp.buf.format()', opt) - -- vim.api.nvim_buf_set_keymap(bufnr, 'v', '=', 'lua vim.lsp.buf.range_formatting()', opt) keymap("n", "=", function() local bfn = vim.api.nvim_get_current_buf() @@ -233,12 +191,6 @@ M.maplsp = function(client, buffer) 'lua require("kide.lsp.utils").format_range_operator()', opt ) - -- mapbuf('v', '=', 'lua vim.lsp.buf.formatting()', opt) - -- mapbuf('n', '', 'lua vim.lsp.buf.signature_help()', opt) - -- mapbuf('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opt) - -- mapbuf('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opt) - -- mapbuf('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opt) - -- mapbuf('n', 'D', 'lua vim.lsp.buf.type_definition()', opt) vim.api.nvim_buf_set_keymap(buffer, "n", "xw", "Telescope diagnostics", opt) vim.api.nvim_buf_set_keymap( @@ -248,12 +200,6 @@ M.maplsp = function(client, buffer) "lua require('telescope.builtin').diagnostics({ severity = vim.diagnostic.severity.ERROR })", opt ) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "xw", "Trouble workspace_diagnostics", opt) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "xx", "Trouble", opt) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "xw", "Trouble workspace_diagnostics", opt) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "xd", "Trouble document_diagnostics", opt) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "xq", "Trouble quickfix", opt) - -- >= 0.8.x if client.server_capabilities.documentHighlightProvider then vim.cmd(string.format("au CursorHold lua vim.lsp.buf.document_highlight()", buffer)) @@ -275,15 +221,6 @@ M.cmp = function(cmp) return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end return { - -- 上一个 - -- [''] = cmp.mapping.select_prev_item(), - -- 下一个 - -- [''] = cmp.mapping.select_next_item(), - -- [""] = cmp.mapping.select_prev_item(), - -- [''] = cmp.mapping.close(), - -- 确认 - -- Accept currently selected item. If none selected, `select` first item. - -- Set `select` to `false` to only confirm explicitly selected items. -- [""] = cmp.mapping.scroll_docs(-4), -- [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.select_prev_item(), @@ -328,19 +265,16 @@ M.cmp = function(cmp) } end -M.rest_nvim = function() - -- rest-nvim - vim.cmd([[ -command! -buffer Http :lua require'rest-nvim'.run() -command! -buffer HttpCurl :lua require'rest-nvim'.run(true) -command! -buffer HttpLast :lua require'rest-nvim'.last() -]]) -end - M.ufo_mapkey = function() -- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself vim.keymap.set("n", "zR", require("ufo").openAllFolds) vim.keymap.set("n", "zM", require("ufo").closeAllFolds) end +M.easy_align = function() + -- vim-easy-align + keymap("n", "ga", "(EasyAlign)") + keymap("x", "ga", "(EasyAlign)") +end + return M diff --git a/lua/kide/core/utils/init.lua b/lua/kide/core/utils/init.lua index c6211a42..2f21695e 100644 --- a/lua/kide/core/utils/init.lua +++ b/lua/kide/core/utils/init.lua @@ -148,12 +148,9 @@ M.test = function(a) print(a) end M.camel_case_init = function() - vim.cmd([[ - " command! -complete=customlist,coreutils#cmdline#complete -nargs=* -bang -range - command! -nargs=* -range - \ CamelCase - \ lua require('kide.core.utils').camel_case_start(, , ) -]]) + vim.api.nvim_create_user_command("CamelCase", function(o) + require("kide.core.utils").camel_case_start(o.range, o.line1, o.line2) + end, { range = 0, nargs = 0 }) end -- print(M.camel_case("helloWorldAaAaAxC")) diff --git a/lua/kide/plugins/config/markdown-preview.lua b/lua/kide/plugins/config/markdown-preview.lua index 13a23f5d..3c8ce8bf 100644 --- a/lua/kide/plugins/config/markdown-preview.lua +++ b/lua/kide/plugins/config/markdown-preview.lua @@ -1,92 +1 @@ -vim.cmd([[ -" set to 1, nvim will open the preview window after entering the markdown buffer -" default: 0 -let g:mkdp_auto_start = 0 - -" set to 1, the nvim will auto close current preview window when change -" from markdown buffer to another buffer -" default: 1 -let g:mkdp_auto_close = 1 - -" set to 1, the vim will refresh markdown when save the buffer or -" leave from insert mode, default 0 is auto refresh markdown as you edit or -" move the cursor -" default: 0 -let g:mkdp_refresh_slow = 0 - -" set to 1, the MarkdownPreview command can be use for all files, -" by default it can be use in markdown file -" default: 0 -let g:mkdp_command_for_global = 0 - -" set to 1, preview server available to others in your network -" by default, the server listens on localhost (127.0.0.1) -" default: 0 -let g:mkdp_open_to_the_world = 0 - -" use custom IP to open preview page -" useful when you work in remote vim and preview on local browser -" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9 -" default empty -let g:mkdp_open_ip = '' - -" specify browser to open preview page -" default: '' -let g:mkdp_browser = '' - -" set to 1, echo preview page url in command line when open preview page -" default is 0 -let g:mkdp_echo_preview_url = 0 - -" a custom vim function name to open preview page -" this function will receive url as param -" default is empty -let g:mkdp_browserfunc = '' - -" options for markdown render -" mkit: markdown-it options for render -" katex: katex options for math -" uml: markdown-it-plantuml options -" maid: mermaid options -" disable_sync_scroll: if disable sync scroll, default 0 -" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle' -" middle: mean the cursor position alway show at the middle of the preview page -" top: mean the vim top viewport alway show at the top of the preview page -" relative: mean the cursor position alway show at the relative positon of the preview page -" hide_yaml_meta: if hide yaml metadata, default is 1 -" sequence_diagrams: js-sequence-diagrams options -" content_editable: if enable content editable for preview page, default: v:false -" disable_filename: if disable filename header for preview page, default: 0 -let g:mkdp_preview_options = { - \ 'mkit': {}, - \ 'katex': {}, - \ 'uml': {}, - \ 'maid': {}, - \ 'disable_sync_scroll': 0, - \ 'sync_scroll_type': 'middle', - \ 'hide_yaml_meta': 1, - \ 'sequence_diagrams': {}, - \ 'flowchart_diagrams': {}, - \ 'content_editable': v:false, - \ 'disable_filename': 0 - \ } - -" use a custom markdown style must be absolute path -" like '/Users/username/markdown.css' or expand('~/markdown.css') -let g:mkdp_markdown_css = '' - -" use a custom highlight style must absolute path -" like '/Users/username/highlight.css' or expand('~/highlight.css') -let g:mkdp_highlight_css = '' - -" use a custom port to start server or random for empty -let g:mkdp_port = '' - -" preview page title -" ${name} will be replace with the file name -let g:mkdp_page_title = '${name}' - -" recognized filetypes -" these filetypes will have MarkdownPreview... commands -let g:mkdp_filetypes = ['markdown'] -]]) +vim.g.mkdp_page_title = "${name}" diff --git a/lua/kide/plugins/config/rest-nvim.lua b/lua/kide/plugins/config/rest-nvim.lua index 8efe3902..ecbc4ffe 100644 --- a/lua/kide/plugins/config/rest-nvim.lua +++ b/lua/kide/plugins/config/rest-nvim.lua @@ -20,3 +20,13 @@ require("rest-nvim").setup({ custom_dynamic_variables = {}, yank_dry_run = true, }) +local group = vim.api.nvim_create_augroup("kide_jdtls_rest_http", { clear = true }) +vim.api.nvim_create_autocmd({ "FileType" }, { + group = group, + pattern = { "http" }, + callback = function(o) + vim.api.nvim_buf_create_user_command(o.buf, "Http", ":lua require'rest-nvim'.run()", { nargs = 0 }) + vim.api.nvim_buf_create_user_command(o.buf, "HttpCurl", ":lua require'rest-nvim'.run(true)", { nargs = 0 }) + vim.api.nvim_buf_create_user_command(o.buf, "HttpLast", ":lua require'rest-nvim'.last()", { nargs = 0 }) + end, +}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index afdf24db..8a894479 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -460,10 +460,7 @@ require("lazy").setup({ lazy = true, cmd = "EasyAlign", config = function() - vim.cmd([[ - xmap ga (EasyAlign) - nmap ga (EasyAlign) - ]]) + require("kide.core.keybindings").easy_align() end, }, @@ -503,16 +500,7 @@ require("lazy").setup({ lazy = true, ft = "http", config = function() - vim.cmd([[ - function! s:http_rest_init() abort - lua require('kide.plugins.config.rest-nvim') - lua require('kide.core.keybindings').rest_nvim() - endfunction - augroup http_rest - autocmd! - autocmd FileType http call s:http_rest_init() - augroup end - ]]) + require("kide.plugins.config.rest-nvim") end, }, From 017299f6923725a7ecf3e02f66fb260ac6662704 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 24 Feb 2023 20:43:52 +0800 Subject: [PATCH 015/708] try --- lua/kide/snippets/java.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/kide/snippets/java.lua b/lua/kide/snippets/java.lua index b858046d..72e3fedd 100644 --- a/lua/kide/snippets/java.lua +++ b/lua/kide/snippets/java.lua @@ -21,6 +21,17 @@ local types = require("luasnip.util.types") local conds = require("luasnip.extras.expand_conditions") ls.add_snippets("java", { + s("try_catch", { + t({ "try {" }), + t({ "", "\t" }), + i(1), + t({ "", "} catch (" }), + i(2, "Throwable"), + t({ " e) {" }), + t({ "", "\t" }), + i(3), + t({ "", "}" }), + }), s("sout", { t({ "System.out.println(" }), i(1), From 74fd6d39ee201759b42f0045d7e8c9261b1354d3 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 24 Feb 2023 21:16:27 +0800 Subject: [PATCH 016/708] try_catch_finally --- lua/kide/snippets/java.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lua/kide/snippets/java.lua b/lua/kide/snippets/java.lua index 72e3fedd..77f95ca9 100644 --- a/lua/kide/snippets/java.lua +++ b/lua/kide/snippets/java.lua @@ -32,6 +32,29 @@ ls.add_snippets("java", { i(3), t({ "", "}" }), }), + s("try_finally", { + t({ "try {" }), + t({ "", "\t" }), + i(1), + t({ "", "} finally {" }), + t({ "", "\t" }), + i(2), + t({ "", "}" }), + }), + s("try_catch_finally", { + t({ "try {" }), + t({ "", "\t" }), + i(1), + t({ "", "} catch (" }), + i(2, "Throwable"), + t({ " e) {" }), + t({ "", "\t" }), + i(3), + t({ "", "} finally {" }), + t({ "", "\t" }), + i(4), + t({ "", "}" }), + }), s("sout", { t({ "System.out.println(" }), i(1), From a98e724c20b17adfed24f2222fce48b9423f1b56 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 27 Feb 2023 15:17:05 +0800 Subject: [PATCH 017/708] todo-comments --- lua/kide/core/keybindings.lua | 9 +++++++++ lua/kide/plugins/lazy-nvim.lua | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 311884d7..84e3899e 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -115,6 +115,15 @@ M.setup = function() vim.api.nvim_set_keymap("s", "", "luasnip-next-choice", {}) vim.api.nvim_set_keymap("i", "", "luasnip-prev-choice", {}) vim.api.nvim_set_keymap("s", "", "luasnip-prev-choice", {}) + + -- todo-comments + vim.keymap.set("n", "]t", function() + require("todo-comments").jump_next() + end, { desc = "Next todo comment" }) + + vim.keymap.set("n", "[t", function() + require("todo-comments").jump_prev() + end, { desc = "Previous todo comment" }) end -- lsp 回调函数快捷键设置 M.maplsp = function(client, buffer) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 8a894479..f98b02ef 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -677,6 +677,13 @@ require("lazy").setup({ require("chatgpt").setup({}) end, }, + { + "folke/todo-comments.nvim", + lazy = true, + config = function() + require("todo-comments").setup({}) + end, + }, }, { ui = { icons = { From c798e00d6649136ebbe629f63f48b4cad0112946 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 1 Mar 2023 20:12:34 +0800 Subject: [PATCH 018/708] scala --- lua/kide/lsp/metals.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lua/kide/lsp/metals.lua diff --git a/lua/kide/lsp/metals.lua b/lua/kide/lsp/metals.lua new file mode 100644 index 00000000..be770880 --- /dev/null +++ b/lua/kide/lsp/metals.lua @@ -0,0 +1,23 @@ +local M = {} +local metals_config = require("metals").bare_config() +metals_config.settings = { + showImplicitArguments = true, +} + +metals_config.on_attach = function(client, buffer) + require("kide.core.keybindings").maplsp(client, buffer) +end + +M.setup = function() + local group = vim.api.nvim_create_augroup("kide_metals", { clear = true }) + vim.api.nvim_create_autocmd({ "FileType" }, { + group = group, + pattern = { "scala" }, + callback = function() + require("metals").initialize_or_attach(metals_config) + end, + }) + return group +end + +return M From d78464c727a3aceb340a45fb1e6c8c845065302e Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 1 Mar 2023 20:12:38 +0800 Subject: [PATCH 019/708] scala lsp --- lua/kide/plugins/lazy-nvim.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index f98b02ef..df2e3233 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -170,7 +170,15 @@ require("lazy").setup({ require("java-deps").setup({}) end, }, - + { + "scalameta/nvim-metals", + lazy = true, + ft = "scala", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function () + require("kide.lsp.metals").setup() + end + }, -- debug { "mfussenegger/nvim-dap", From 0d86d10c819590a476e0e43325d8d37f687a320c Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 3 Mar 2023 20:14:18 +0800 Subject: [PATCH 020/708] cursorcolumn --- lua/kide/core/basic.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index c40df75d..613658de 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -30,6 +30,7 @@ vim.opt.ruler = false -- 高亮所在行 vim.wo.cursorline = true +vim.wo.cursorcolumn = true -- 右侧参考线,超过表示代码太长了,考虑换行 vim.wo.colorcolumn = "120" From 4125f63893e7d535f8c5cd12f9e0a5692944e999 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 5 Mar 2023 10:50:50 +0800 Subject: [PATCH 021/708] c snippets --- lua/kide/plugins/config/luasnip.lua | 2 +- lua/kide/snippets/c.lua | 31 +++++++++++++++++++++++++++++ lua/kide/snippets/init.lua | 8 ++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 lua/kide/snippets/c.lua create mode 100644 lua/kide/snippets/init.lua diff --git a/lua/kide/plugins/config/luasnip.lua b/lua/kide/plugins/config/luasnip.lua index d5e81e7e..edb99add 100644 --- a/lua/kide/plugins/config/luasnip.lua +++ b/lua/kide/plugins/config/luasnip.lua @@ -58,4 +58,4 @@ ls.filetype_set("cpp", { "c" }) -- require("luasnip.loaders.from_vscode").lazy_load() -require("kide.snippets.java") +require("kide.snippets").setup() diff --git a/lua/kide/snippets/c.lua b/lua/kide/snippets/c.lua new file mode 100644 index 00000000..a0989c86 --- /dev/null +++ b/lua/kide/snippets/c.lua @@ -0,0 +1,31 @@ +local ls = require("luasnip") + +-- some shorthands... +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local l = require("luasnip.extras").lambda +local rep = require("luasnip.extras").rep +local p = require("luasnip.extras").partial +local m = require("luasnip.extras").match +local n = require("luasnip.extras").nonempty +local dl = require("luasnip.extras").dynamic_lambda +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local types = require("luasnip.util.types") +local conds = require("luasnip.extras.expand_conditions") + +ls.add_snippets("c", { + s("main", { + t({ "int main() {" }), + t({ "", "\t" }), + i(0), + t({ "", "\t return 0;" }), + t({ "", "}" }), + }), +}) diff --git a/lua/kide/snippets/init.lua b/lua/kide/snippets/init.lua new file mode 100644 index 00000000..cef1dde4 --- /dev/null +++ b/lua/kide/snippets/init.lua @@ -0,0 +1,8 @@ +local M = {} + +M.setup = function() + require("kide.snippets.c") + require("kide.snippets.java") +end + +return M From 0e7eb69b73471bbf5eeb937102ff9a982a446bb6 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 6 Mar 2023 11:22:10 +0800 Subject: [PATCH 022/708] loaders.from_vscode --- lua/kide/snippets/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/kide/snippets/init.lua b/lua/kide/snippets/init.lua index cef1dde4..913cc0e8 100644 --- a/lua/kide/snippets/init.lua +++ b/lua/kide/snippets/init.lua @@ -3,6 +3,9 @@ local M = {} M.setup = function() require("kide.snippets.c") require("kide.snippets.java") + require("luasnip.loaders.from_vscode").lazy_load({ + include = { "go", "c", "python", "sh", "json", "lua", "gitcommit", "sql", "html" }, + }) end return M From 5d7dd6e012bc16f587f1b6f172e47f5f72c592dc Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 7 Mar 2023 14:41:09 +0800 Subject: [PATCH 023/708] =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=85=A8=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/alpha-nvim.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/alpha-nvim.lua b/lua/kide/plugins/config/alpha-nvim.lua index b8fee2d3..2f378a2f 100644 --- a/lua/kide/plugins/config/alpha-nvim.lua +++ b/lua/kide/plugins/config/alpha-nvim.lua @@ -17,7 +17,7 @@ local opt = { noremap = true, silent = true } dashboard.section.buttons.val = { dashboard.button(" ff", " Find File", ":Telescope find_files", opt), dashboard.button(" fg", " Find Word ", ":Telescope live_grep", opt), - dashboard.button(" fp", " Recent Projects", ":Telescope project", opt), + dashboard.button(" fp", " Recent Projects", ":lua require'telescope'.extensions.project.project{ display_type = 'full' }", opt), dashboard.button(" fo", " Recent File", ":Telescope oldfiles", opt), dashboard.button(" ns", " Settings", ":e $MYVIMRC | :cd %:p:h ", opt), dashboard.button(" q ", " Quit NVIM", ":qa", opt), From 97b79e0c12c5594101e851eff04f67e2e8db471b Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 8 Mar 2023 09:24:02 +0800 Subject: [PATCH 024/708] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/aerial.lua | 242 ----------------------------- 1 file changed, 242 deletions(-) delete mode 100644 lua/kide/plugins/config/aerial.lua diff --git a/lua/kide/plugins/config/aerial.lua b/lua/kide/plugins/config/aerial.lua deleted file mode 100644 index 2ee401c0..00000000 --- a/lua/kide/plugins/config/aerial.lua +++ /dev/null @@ -1,242 +0,0 @@ --- Call the setup function to change the default behavior -require("aerial").setup({ - -- Priority list of preferred backends for aerial. - -- This can be a filetype map (see :help aerial-filetype-map) - backends = { "treesitter", "lsp", "markdown" }, - - -- Enum: persist, close, auto, global - -- persist - aerial window will stay open until closed - -- close - aerial window will close when original file is no longer visible - -- auto - aerial window will stay open as long as there is a visible - -- buffer to attach to - -- global - same as 'persist', and will always show symbols for the current buffer - close_behavior = "auto", - - -- Set to false to remove the default keybindings for the aerial buffer - default_bindings = true, - - -- Enum: prefer_right, prefer_left, right, left, float - -- Determines the default direction to open the aerial window. The 'prefer' - -- options will open the window in the other direction *if* there is a - -- different buffer in the way of the preferred direction - default_direction = "prefer_right", - - -- Disable aerial on files with this many lines - disable_max_lines = 10000, - - -- Disable aerial on files this size or larger (in bytes) - disable_max_size = 2000000, -- Default 2MB - - -- A list of all symbols to display. Set to false to display all symbols. - -- This can be a filetype map (see :help aerial-filetype-map) - -- To see all available values, see :help SymbolKind - filter_kind = { - "Array", - "Boolean", - "Class", - "Constant", - "Constructor", - "Enum", - "EnumMember", - "Event", - "Field", - "File", - "Function", - "Interface", - "Key", - "Method", - "Module", - "Namespace", - "Null", - "Number", - "Object", - "Operator", - "Package", - "Property", - "String", - "Struct", - "TypeParameter", - "Variable", - }, - - -- Enum: split_width, full_width, last, none - -- Determines line highlighting mode when multiple splits are visible. - -- split_width Each open window will have its cursor location marked in the - -- aerial buffer. Each line will only be partially highlighted - -- to indicate which window is at that location. - -- full_width Each open window will have its cursor location marked as a - -- full-width highlight in the aerial buffer. - -- last Only the most-recently focused window will have its location - -- marked in the aerial buffer. - -- none Do not show the cursor locations in the aerial window. - highlight_mode = "split_width", - - -- Highlight the closest symbol if the cursor is not exactly on one. - highlight_closest = true, - - -- Highlight the symbol in the source buffer when cursor is in the aerial win - highlight_on_hover = false, - - -- When jumping to a symbol, highlight the line for this many ms. - -- Set to false to disable - highlight_on_jump = 300, - - -- Define symbol icons. You can also specify "Collapsed" to change the - -- icon when the tree is collapsed at that symbol, or "Collapsed" to specify a - -- default collapsed icon. The default icon set is determined by the - -- "nerd_font" option below. - -- If you have lspkind-nvim installed, it will be the default icon set. - -- This can be a filetype map (see :help aerial-filetype-map) - icons = {}, - - -- Control which windows and buffers aerial should ignore. - -- If close_behavior is "global", focusing an ignored window/buffer will - -- not cause the aerial window to update. - -- If open_automatic is true, focusing an ignored window/buffer will not - -- cause an aerial window to open. - -- If open_automatic is a function, ignore rules have no effect on aerial - -- window opening behavior; it's entirely handled by the open_automatic - -- function. - ignore = { - -- Ignore unlisted buffers. See :help buflisted - unlisted_buffers = true, - - -- List of filetypes to ignore. - filetypes = {}, - - -- Ignored buftypes. - -- Can be one of the following: - -- false or nil - No buftypes are ignored. - -- "special" - All buffers other than normal buffers are ignored. - -- table - A list of buftypes to ignore. See :help buftype for the - -- possible values. - -- function - A function that returns true if the buffer should be - -- ignored or false if it should not be ignored. - -- Takes two arguments, `bufnr` and `buftype`. - buftypes = "special", - - -- Ignored wintypes. - -- Can be one of the following: - -- false or nil - No wintypes are ignored. - -- "special" - All windows other than normal windows are ignored. - -- table - A list of wintypes to ignore. See :help win_gettype() for the - -- possible values. - -- function - A function that returns true if the window should be - -- ignored or false if it should not be ignored. - -- Takes two arguments, `winid` and `wintype`. - wintypes = "special", - }, - - -- When you fold code with za, zo, or zc, update the aerial tree as well. - -- Only works when manage_folds = true - link_folds_to_tree = false, - - -- Fold code when you open/collapse symbols in the tree. - -- Only works when manage_folds = true - link_tree_to_folds = true, - - -- Use symbol tree for folding. Set to true or false to enable/disable - -- 'auto' will manage folds if your previous foldmethod was 'manual' - manage_folds = false, - - -- These control the width of the aerial window. - -- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) - -- min_width and max_width can be a list of mixed types. - -- max_width = {40, 0.2} means "the lesser of 40 columns or 20% of total" - max_width = { 40, 0.2 }, - width = nil, - min_width = 32, - - -- Set default symbol icons to use patched font icons (see https://www.nerdfonts.com/) - -- "auto" will set it to true if nvim-web-devicons or lspkind-nvim is installed. - nerd_font = "true", - - -- Call this function when aerial attaches to a buffer. - -- Useful for setting keymaps. Takes a single `bufnr` argument. - on_attach = nil, - - -- Call this function when aerial first sets symbols on a buffer. - -- Takes a single `bufnr` argument. - on_first_symbols = nil, - - -- Automatically open aerial when entering supported buffers. - -- This can be a function (see :help aerial-open-automatic) - open_automatic = false, - - -- Set to true to only open aerial at the far right/left of the editor - -- Default behavior opens aerial relative to current window - placement_editor_edge = false, - - -- Run this command after jumping to a symbol (false will disable) - post_jump_cmd = "normal! zz", - - -- When true, aerial will automatically close after jumping to a symbol - close_on_select = false, - - -- Show box drawing characters for the tree hierarchy - show_guides = false, - - -- The autocmds that trigger symbols update (not used for LSP backend) - update_events = "TextChanged,InsertLeave", - - -- Customize the characters used when show_guides = true - guides = { - -- When the child item has a sibling below it - mid_item = "├─", - -- When the child item is the last in the list - last_item = "└─", - -- When there are nested child guides to the right - nested_top = "│ ", - -- Raw indentation - whitespace = " ", - }, - - -- Options for opening aerial in a floating win - float = { - -- Controls border appearance. Passed to nvim_open_win - border = "rounded", - - -- Enum: cursor, editor, win - -- cursor - Opens float on top of the cursor - -- editor - Opens float centered in the editor - -- win - Opens float centered in the window - relative = "cursor", - - -- These control the height of the floating window. - -- They can be integers or a float between 0 and 1 (e.g. 0.4 for 40%) - -- min_height and max_height can be a list of mixed types. - -- min_height = {8, 0.1} means "the greater of 8 rows or 10% of total" - max_height = 0.9, - height = nil, - min_height = { 8, 0.1 }, - - override = function(conf) - -- This is the config that will be passed to nvim_open_win. - -- Change values here to customize the layout - return conf - end, - }, - - lsp = { - -- Fetch document symbols when LSP diagnostics update. - -- If false, will update on buffer changes. - diagnostics_trigger_update = true, - - -- Set to false to not update the symbols when there are LSP errors - update_when_errors = true, - - -- How long to wait (in ms) after a buffer change before updating - -- Only used when diagnostics_trigger_update = false - update_delay = 300, - }, - - treesitter = { - -- How long to wait (in ms) after a buffer change before updating - update_delay = 300, - }, - - markdown = { - -- How long to wait (in ms) after a buffer change before updating - update_delay = 300, - }, -}) From 912192368b6f69d5ec15fa4188a226724ec7834f Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 14 Mar 2023 12:54:18 +0800 Subject: [PATCH 025/708] =?UTF-8?q?=E8=B0=83=E6=95=B4telescope=E9=85=8D?= =?UTF-8?q?=E8=89=B2=E5=8A=A0=E8=BD=BD=E4=BC=98=E5=85=88=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/gruvbox.lua | 2 -- lua/kide/plugins/config/telescope.lua | 2 ++ lua/kide/theme/gruvbox.lua | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index c1864f18..eecb6a3c 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -13,8 +13,6 @@ local overrides = { -- cmp, wilder } -overrides = vim.tbl_extend("force", overrides, kgrubox.flat_telescope) - require("gruvbox").setup({ undercurl = true, underline = true, diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index 28e77717..c4104ff6 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -158,3 +158,5 @@ require("telescope").load_extension("project") require("telescope").load_extension("ui-select") require("telescope").load_extension("fzf") require("telescope").load_extension("env") + +require("kide.theme.gruvbox").load_telescope_highlights() diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index 124abbf8..14a156c2 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -11,7 +11,7 @@ local colors = { yellow = "#fabd2f", } M.colors = colors -M.flat_telescope = { +local flat_telescope = { TelescopeBorder = { fg = colors.darker_black, @@ -65,4 +65,13 @@ M.flat_telescope = { TelescopeSelection = { bg = colors.black2, fg = colors.yellow }, } + +M.load_telescope_highlights = function() + M.load_highlights(flat_telescope) +end +M.load_highlights = function(hl_groups) + for hl, col in pairs(hl_groups) do + vim.api.nvim_set_hl(0, hl, col) + end +end return M From 751f7ef68cf3e713e613d7429539ba541f6c8155 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 14 Mar 2023 12:56:16 +0800 Subject: [PATCH 026/708] q telescope close --- lua/kide/plugins/config/telescope.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index c4104ff6..8a345187 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -107,6 +107,7 @@ telescope.setup({ }, n = { -- [""] = trouble.open_with_trouble, + ["q"] = require("telescope.actions").close, }, }, }, From efa9d451046b254f1b00d47eac5c63b85b3914c0 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 15 Mar 2023 00:17:01 +0800 Subject: [PATCH 027/708] dict --- lua/kide/plugins/config/nvim-cmp.lua | 2 ++ lua/kide/plugins/lazy-nvim.lua | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 1030cafd..2c945728 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -32,6 +32,7 @@ cmp.setup({ }, { { name = "path" }, { name = "buffer" }, + { name = "cmp-dictionary-nanny" }, }), -- 快捷键 @@ -50,6 +51,7 @@ cmp.setup({ nvim_lsp = "[LSP]", luasnip = "[Lsnip]", path = "[Path]", + ["cmp-dictionary-nanny"] = "[Dict]", -- buffer = "[Buffer]", }, }), diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index df2e3233..61bfa1cd 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -175,9 +175,9 @@ require("lazy").setup({ lazy = true, ft = "scala", dependencies = { "nvim-lua/plenary.nvim" }, - config = function () + config = function() require("kide.lsp.metals").setup() - end + end, }, -- debug { @@ -692,6 +692,14 @@ require("lazy").setup({ require("todo-comments").setup({}) end, }, + { + "denstiny/cmp-dictionary-nanny", + build = "./install.sh", + config = function() + require("cmp-dictionary-nanny.config").setup({}) + end, + event = { "InsertEnter" }, + }, }, { ui = { icons = { From 4c5416c7991f8045245d2789a17e700b82917d31 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 15 Mar 2023 10:38:29 +0800 Subject: [PATCH 028/708] fix send msg --- lua/kide/plugins/lazy-nvim.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 61bfa1cd..84fea109 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -682,7 +682,11 @@ require("lazy").setup({ "ChatGPT", }, config = function() - require("chatgpt").setup({}) + require("chatgpt").setup({ + keymaps = { + submit = "", + }, + }) end, }, { From 8c7b3c1082d8a02c76777da61c113f3325248468 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 16 Mar 2023 11:47:57 +0800 Subject: [PATCH 029/708] trans --- lua/kide/plugins/lazy-nvim.lua | 25 ++++++++++++++++ lua/kide/theme/gruvbox.lua | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 84fea109..65bcc3ae 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -704,6 +704,31 @@ require("lazy").setup({ end, event = { "InsertEnter" }, }, + { + "JuanZoran/Trans.nvim", + keys = { + -- 可以换成其他你想映射的键 + { "mm", mode = { "n", "x" }, "Translate", desc = " Translate" }, + { "mk", mode = { "n", "x" }, "TransPlay", desc = " 自动发音" }, + + -- 目前这个功能的视窗还没有做好,可以在配置里将view.i改成hover + { "mi", "TranslateInput", desc = " Translate From Input" }, + }, + dependencies = { "kkharji/sqlite.lua", lazy = true }, + config = function() + require("Trans").setup({ + db_path = "$HOME/.local/share/nvim/data/ultimate.db", + icon = { + star = "", + notfound = " ", + yes = "", + no = "", + cell = "■", + }, + }) + require("kide.theme.gruvbox").load_trans_highlights() + end, + }, }, { ui = { icons = { diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index 14a156c2..6cf7f7e2 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -9,6 +9,9 @@ local colors = { red = "#fb4934", green = "#b8bb26", yellow = "#fabd2f", + yellow2 = "#d79921", + blue = "#83a598", + blue2 = "#458588", } M.colors = colors local flat_telescope = { @@ -65,6 +68,51 @@ local flat_telescope = { TelescopeSelection = { bg = colors.black2, fg = colors.yellow }, } +local flat_trans = { + TransWord = { + fg = colors.green, + bold = true, + }, + TransPhonetic = { + link = "Linenr", + }, + TransTitle = { + fg = colors.white, + bg = colors.blue2, + bold = true, + }, + TransTitleRound = { + fg = colors.blue2, + }, + TransTag = { + fg = colors.yellow2, + }, + TransExchange = { + link = "TransTag", + }, + TransPos = { + link = "TransTag", + }, + TransTranslation = { + link = "TransWord", + }, + TransDefinition = { + link = "Moremsg", + }, + TransWin = { + link = "Normal", + }, + TransBorder = { + link = "FloatBorder", + }, + TransCollins = { + fg = colors.green, + bold = true, + }, + TransFailed = { + fg = colors.blue, + }, +} M.load_telescope_highlights = function() M.load_highlights(flat_telescope) @@ -74,4 +122,8 @@ M.load_highlights = function(hl_groups) vim.api.nvim_set_hl(0, hl, col) end end + +M.load_trans_highlights = function() + M.load_highlights(flat_trans) +end return M From ed3005abd394a5381490da83093d3a0c33bd237f Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 16 Mar 2023 11:48:02 +0800 Subject: [PATCH 030/708] fmt --- lua/kide/plugins/config/alpha-nvim.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/alpha-nvim.lua b/lua/kide/plugins/config/alpha-nvim.lua index 2f378a2f..0fb04a6e 100644 --- a/lua/kide/plugins/config/alpha-nvim.lua +++ b/lua/kide/plugins/config/alpha-nvim.lua @@ -17,7 +17,12 @@ local opt = { noremap = true, silent = true } dashboard.section.buttons.val = { dashboard.button(" ff", " Find File", ":Telescope find_files", opt), dashboard.button(" fg", " Find Word ", ":Telescope live_grep", opt), - dashboard.button(" fp", " Recent Projects", ":lua require'telescope'.extensions.project.project{ display_type = 'full' }", opt), + dashboard.button( + " fp", + " Recent Projects", + ":lua require'telescope'.extensions.project.project{ display_type = 'full' }", + opt + ), dashboard.button(" fo", " Recent File", ":Telescope oldfiles", opt), dashboard.button(" ns", " Settings", ":e $MYVIMRC | :cd %:p:h ", opt), dashboard.button(" q ", " Quit NVIM", ":qa", opt), From 6995a787efddfd2bbfbb7c4a056baac61b950599 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 16 Mar 2023 11:59:07 +0800 Subject: [PATCH 031/708] =?UTF-8?q?=E6=9A=82=E6=97=B6=E7=A6=81=E7=94=A8=20?= =?UTF-8?q?trans,=20=E4=BC=9A=E5=AF=BC=E8=87=B4=E6=96=87=E4=BB=B6=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=8C=E9=A2=91=E7=B9=81=E8=AF=B7=E6=B1=82=20LSP=20?= =?UTF-8?q?server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/lazy-nvim.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 65bcc3ae..a9dea65d 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -706,6 +706,7 @@ require("lazy").setup({ }, { "JuanZoran/Trans.nvim", + enabled = false, keys = { -- 可以换成其他你想映射的键 { "mm", mode = { "n", "x" }, "Translate", desc = " Translate" }, From 70cc1f19c8ae711300cfc48130f2886d7b436004 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 16 Mar 2023 22:17:42 +0800 Subject: [PATCH 032/708] opt --- lua/kide/core/basic.lua | 62 +++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 613658de..ebbed11e 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -29,34 +29,31 @@ vim.opt.numberwidth = 2 vim.opt.ruler = false -- 高亮所在行 -vim.wo.cursorline = true -vim.wo.cursorcolumn = true +vim.opt.cursorline = true +vim.opt.cursorcolumn = true -- 右侧参考线,超过表示代码太长了,考虑换行 -vim.wo.colorcolumn = "120" +vim.opt.colorcolumn = "120" -- 边搜索边高亮 -vim.o.incsearch = true +vim.opt.incsearch = true -- 忽悠大小写 -vim.o.ignorecase = true +vim.opt.ignorecase = true -- 智能大小写 -vim.o.smartcase = true +vim.opt.smartcase = true -vim.g.encoding = "UTF-8" +vim.opt_global.encoding = "UTF-8" -vim.o.fileencoding = "UTF-8" +vim.opt.fileencoding = "UTF-8" -- jk移动时光标下上方保留8行 -vim.o.scrolloff = 3 -vim.o.sidescrolloff = 3 +vim.opt.scrolloff = 3 +vim.opt.sidescrolloff = 3 -- 缩进配置 -vim.o.tabstop = 4 -vim.bo.tabstop = 4 -vim.o.softtabstop = 4 --- vim.o.softround=true +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 -- > < 时移动长度 -vim.o.shiftwidth = 4 -vim.bo.shiftwidth = 4 +vim.opt.shiftwidth = 4 local autocmd = vim.api.nvim_create_autocmd autocmd("FileType", { @@ -81,36 +78,33 @@ autocmd("FileType", { }) -- 新行对齐当前行,空格替代tab -vim.o.expandtab = true -vim.bo.expandtab = true -vim.o.autoindent = true -vim.bo.autoindent = true -vim.o.smartindent = true +vim.opt.expandtab = true +vim.opt.autoindent = true +vim.opt.smartindent = true -- 使用增强状态栏后不再需要 vim 的模式提示 -vim.o.showmode = false +vim.opt.showmode = false -- 当文件被外部程序修改时,自动加载 -vim.o.autoread = true -vim.bo.autoread = true +vim.opt.autoread = true -- 禁止创建备份文件 -vim.o.backup = false -vim.o.writebackup = false -vim.o.swapfile = false +vim.opt.backup = false +vim.opt.writebackup = false +vim.opt.swapfile = false -- smaller updatetime -vim.o.updatetime = 300 +vim.opt.updatetime = 300 -- split window 从下边和右边出现 -vim.o.splitbelow = false -vim.o.splitright = true +vim.opt.splitbelow = false +vim.opt.splitright = true -- 样式 vim.opt.background = "dark" vim.opt.termguicolors = true -- 补全增强 -vim.o.wildmenu = true +vim.opt.wildmenu = true vim.opt.confirm = true @@ -120,15 +114,15 @@ vim.opt.confirm = true vim.opt.list = true vim.opt.cul = true -- cursor line -vim.o.timeout = true +vim.opt.timeout = true vim.opt.timeoutlen = 450 vim.opt.mouse = "a" -- 默认不要折叠 -- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file -vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value -vim.o.foldlevelstart = 99 +vim.opt.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value +vim.opt.foldlevelstart = 99 -- Highlight on yank vim.api.nvim_create_autocmd({ "TextYankPost" }, { From 098e4905d8ddf13122ca1891d89e5eb704c63bad Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 16 Mar 2023 22:52:20 +0800 Subject: [PATCH 033/708] visual-multi --- lua/kide/plugins/lazy-nvim.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index a9dea65d..0a3aead4 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -322,7 +322,9 @@ require("lazy").setup({ { "mg979/vim-visual-multi", lazy = true, - keys = { "" }, + keys = { + { "", mode = { "n", "x" }, desc = "visual multi" }, + }, }, -- 状态栏插件 From 69558c4aee5b9a578a2d30949ee1a5bbb84a5089 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 16 Mar 2023 23:17:19 +0800 Subject: [PATCH 034/708] Comment --- lua/kide/plugins/lazy-nvim.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 0a3aead4..fb17ab2b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -387,7 +387,10 @@ require("lazy").setup({ { "numToStr/Comment.nvim", - keys = { "gcc", "gb" }, + keys = { + { "gcc", mode = { "n" }, desc = "Comment" }, + { "gc", mode = { "x" }, desc = "Comment" }, + }, config = function() require("kide.plugins.config.comment") end, From e92aa75d6f69e040353342bb814858ad3e1e026d Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 19 Mar 2023 23:07:02 +0800 Subject: [PATCH 035/708] wilder.nvim -> cmp-cmdline --- lua/kide/plugins/config/nvim-cmp.lua | 30 +++++++++++++++------------- lua/kide/plugins/lazy-nvim.lua | 9 ++++++++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 2c945728..2f5a5e5f 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -58,18 +58,20 @@ cmp.setup({ }, }) --- Use buffer source for `/`. --- cmp.setup.cmdline('/', { --- sources = { --- { name = 'buffer' } --- } --- }) +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, +}) --- Use cmdline & path source for ':'. --- cmp.setup.cmdline(':', { --- sources = cmp.config.sources({ --- { name = 'path' } --- }, { --- { name = 'cmdline' } --- }) --- }) +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), +}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index fb17ab2b..321d8f4d 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -64,10 +64,12 @@ require("lazy").setup({ { "hrsh7th/nvim-cmp", event = { "InsertEnter" }, + keys = { ":", "/", "?" }, dependencies = { "hrsh7th/cmp-path", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", + "hrsh7th/cmp-cmdline", "saadparwaiz1/cmp_luasnip", "onsails/lspkind-nvim", }, @@ -80,6 +82,10 @@ require("lazy").setup({ "hrsh7th/cmp-nvim-lsp", lazy = true, }, + { + "hrsh7th/cmp-cmdline", + lazy = true, + }, { "hrsh7th/cmp-buffer", lazy = true, @@ -370,7 +376,8 @@ require("lazy").setup({ -- wildmenu 补全美化 { "gelguy/wilder.nvim", - keys = { ":", "/" }, + enabled = false, + keys = { ":", "/", "?" }, config = function() require("kide.plugins.config.wilder") end, From 1f88c20717258743ceb3531fc347a781704d42e7 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 21 Mar 2023 09:59:57 +0800 Subject: [PATCH 036/708] =?UTF-8?q?=E4=B8=8D=E5=86=8D=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/nvim-cmp.lua | 2 -- lua/kide/plugins/lazy-nvim.lua | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 2f5a5e5f..90eca963 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -32,7 +32,6 @@ cmp.setup({ }, { { name = "path" }, { name = "buffer" }, - { name = "cmp-dictionary-nanny" }, }), -- 快捷键 @@ -51,7 +50,6 @@ cmp.setup({ nvim_lsp = "[LSP]", luasnip = "[Lsnip]", path = "[Path]", - ["cmp-dictionary-nanny"] = "[Dict]", -- buffer = "[Buffer]", }, }), diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 321d8f4d..0a7ac760 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -710,6 +710,7 @@ require("lazy").setup({ }, { "denstiny/cmp-dictionary-nanny", + enabled = false, build = "./install.sh", config = function() require("cmp-dictionary-nanny.config").setup({}) From ebbd48f97385c4b2da612e833d5479d18dfc4d4c Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 21 Mar 2023 20:10:18 +0800 Subject: [PATCH 037/708] update gruvbox --- lua/kide/plugins/config/gruvbox.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index eecb6a3c..89dfbbd1 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -16,8 +16,6 @@ local overrides = { require("gruvbox").setup({ undercurl = true, underline = true, - bold = true, - italic = true, -- will make italic comments and special strings inverse = true, -- invert background for search, diffs, statuslines and errors invert_selection = false, invert_signs = false, From b0d0ecc4f3c0f78b4bd3764e2ffa1d082a19b8f7 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 22 Mar 2023 17:34:26 +0800 Subject: [PATCH 038/708] =?UTF-8?q?alpha=20=E4=B8=8D=E5=8A=A0=E8=BD=BD=20l?= =?UTF-8?q?ualine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/lualine.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index f93062ac..8e4ac30b 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -7,7 +7,7 @@ local config = { component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = { - -- "dap-repl", "dapui_watches", "dapui_stacks", "dapui_breakpoints", "dapui_scopes" + "alpha", }, always_divide_middle = true, }, From dda30e7ac4e28b4626e34b5d77269665ea0d4874 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 26 Mar 2023 13:44:43 +0800 Subject: [PATCH 039/708] copilot --- lua/kide/plugins/lazy-nvim.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 0a7ac760..39336bfc 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -743,6 +743,14 @@ require("lazy").setup({ require("kide.theme.gruvbox").load_trans_highlights() end, }, + + { + "github/copilot.vim", + lazy = true, + cmd = { + "Copilot", + }, + }, }, { ui = { icons = { From 8192bdde1d48ec60163c43b87aa90cc33bfebb5d Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 26 Mar 2023 15:02:01 +0800 Subject: [PATCH 040/708] copilot --- lua/kide/core/keybindings.lua | 5 ++++- lua/kide/plugins/config/nvim-cmp.lua | 9 ++++++++- lua/kide/plugins/lazy-nvim.lua | 22 +++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 84e3899e..0556642f 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -226,8 +226,11 @@ end M.cmp = function(cmp) local luasnip = require("luasnip") local has_words_before = function() + if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then + return false + end local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil end return { -- [""] = cmp.mapping.scroll_docs(-4), diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 90eca963..57a24f84 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -1,6 +1,11 @@ local lspkind = require("lspkind") local cmp = require("cmp") - +lspkind.init({ + symbol_map = { + Copilot = "", + }, +}) +vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" }) cmp.setup({ -- 指定 snippet 引擎 snippet = { @@ -20,6 +25,7 @@ cmp.setup({ }, -- 来源 sources = cmp.config.sources({ + { name = "copilot" }, { name = "nvim_lsp" }, -- For vsnip users. -- { name = 'vsnip' }, @@ -50,6 +56,7 @@ cmp.setup({ nvim_lsp = "[LSP]", luasnip = "[Lsnip]", path = "[Path]", + copilot = "[Copilot]", -- buffer = "[Buffer]", }, }), diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 39336bfc..6bde7e5b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -743,13 +743,25 @@ require("lazy").setup({ require("kide.theme.gruvbox").load_trans_highlights() end, }, - { - "github/copilot.vim", + "zbirenbaum/copilot.lua", lazy = true, - cmd = { - "Copilot", - }, + cmd = "Copilot", + config = function() + require("copilot").setup({ + suggestion = { enabled = false }, + panel = { enabled = false }, + }) + end, + }, + { + "zbirenbaum/copilot-cmp", + lazy = true, + dependencies = { "zbirenbaum/copilot.lua" }, + event = "InsertEnter", + config = function() + require("copilot_cmp").setup() + end, }, }, { ui = { From 2fa48b3f42e29c2351ac7cbc32bfa0bafc72ec3e Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 28 Mar 2023 15:32:17 +0800 Subject: [PATCH 041/708] open_classfile --- lua/kide/lsp/java.lua | 4 +- lua/kide/lsp/utils/jdtls.lua | 150 ++++++++++++++++---------- lua/kide/plugins/config/telescope.lua | 2 +- 3 files changed, 96 insertions(+), 60 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index f5b867e0..60cb3453 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -520,7 +520,7 @@ M.setup = function() vim.api.nvim_create_autocmd({ "BufReadCmd" }, { pattern = "jdt://*", callback = function(e) - require("jdtls").open_jdt_link(e.file) + require("jdtls").open_classfile(e.file) end, }) vim.api.nvim_create_user_command("JdtWipeDataAndRestart", "lua require('jdtls.setup').wipe_data_and_restart()", {}) @@ -535,7 +535,7 @@ M.setup = function() -- vim.notify("load: " .. o.buf, vim.log.levels.INFO) -- print(vim.inspect(e)) -- 忽略 telescope 预览的情况 - if e.file == "java" then + if e.file == "java" and vim.bo[e.buf].buftype == "nofile" then -- ignore else M.start() diff --git a/lua/kide/lsp/utils/jdtls.lua b/lua/kide/lsp/utils/jdtls.lua index 8eb32f36..11ed90aa 100644 --- a/lua/kide/lsp/utils/jdtls.lua +++ b/lua/kide/lsp/utils/jdtls.lua @@ -1,68 +1,104 @@ +-- code from https://github.com/mfussenegger/nvim-jdtls/blob/f8fb45e05e/lua/jdtls.lua +local api = vim.api local M = {} -M.open_jdt_link = function(uri, buf, timeout) - local client - for _, c in ipairs(vim.lsp.get_active_clients()) do - if - c.config.init_options - and c.config.init_options.extendedClientCapabilities - and c.config.init_options.extendedClientCapabilities.classFileContentsSupport - then - client = c - break +function M.execute_command(command, callback, bufnr) + local clients = {} + local candidates = bufnr and vim.lsp.buf_get_clients(bufnr) or vim.lsp.get_active_clients() + for _, c in pairs(candidates) do + local command_provider = c.server_capabilities.executeCommandProvider + local commands = type(command_provider) == "table" and command_provider.commands or {} + if vim.tbl_contains(commands, command.command) then + table.insert(clients, c) end end - assert(client, "Must have a buffer open with a language client connected to eclipse.jdt.ls to load JDT URI") - local params = { - uri = uri, - } - local response = nil - local cb = function(err, result) - response = { err, result } - end - local ok, request_id = client.request("java/classFileContents", params, cb, buf) - assert(ok, "Request to `java/classFileContents` must succeed to open JDT URI. Client shutdown?") - local timeout_ms = timeout or 500 - local wait_ok, reason = vim.wait(timeout_ms, function() - return response - end) - local log_path = require("jdtls.path").join(vim.fn.stdpath("cache"), "lsp.log") - local buf_content - if wait_ok and #response == 2 and response[2] then - local content = response[2] - if content == "" then - buf_content = { - "Received response from server, but it was empty. Check the log file for errors", - log_path, - } + local num_clients = vim.tbl_count(clients) + if num_clients == 0 then + if bufnr then + -- User could've switched buffer to non-java file, try all clients + return M.execute_command(command, callback, nil) else - buf_content = vim.split(response[2], "\n", true) + vim.notify("No LSP client found that supports " .. command.command, vim.log.levels.ERROR) + return + end + end + + if num_clients > 1 then + vim.notify( + "Multiple LSP clients found that support " + .. command.command + .. " you should have at most one JDTLS server running", + vim.log.levels.WARN + ) + end + + local co + if not callback then + co = coroutine.running() + if co then + callback = function(err, resp) + coroutine.resume(co, err, resp) + end end + end + clients[1].request("workspace/executeCommand", command, callback) + if co then + return coroutine.yield() + end +end +--- Open `jdt://` uri or decompile class contents and load them into the buffer +--- +--- nvim-jdtls by defaults configures a `BufReadCmd` event which uses this function. +--- You shouldn't need to call this manually. +--- +---@param fname string +function M.open_classfile(fname, buf, timeout_ms) + local uri + local use_cmd + if vim.startswith(fname, "jdt://") then + uri = fname + use_cmd = false else - local error_msg - if not wait_ok then - client.cancel_request(request_id) - local wait_failure = { - [-1] = "timeout", - [-2] = "interrupted", - [-3] = "error", - } - error_msg = wait_failure[reason] - else - error_msg = response[1] + uri = vim.uri_from_fname(fname) + use_cmd = true + if not vim.startswith(uri, "file://") then + return end - buf_content = { - "Failed to load content for uri", - uri, - "", - "Error was: ", + end + vim.bo[buf].modifiable = true + vim.bo[buf].swapfile = false + vim.bo[buf].buftype = "nofile" + -- This triggers FileType event which should fire up the lsp client if not already running + vim.bo[buf].filetype = "java" + vim.wait(timeout_ms, function() + return next(vim.lsp.get_active_clients({ name = "jdtls" })) ~= nil + end) + local client = vim.lsp.get_active_clients({ name = "jdtls" })[1] + assert(client, "Must have a `jdtls` client to load class file or jdt uri") + + local content + local function handler(err, result) + assert(not err, vim.inspect(err)) + content = result + api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(result, "\n", { plain = true })) + vim.bo[buf].modifiable = false + end + + if use_cmd then + local command = { + command = "java.decompile", + arguments = { uri }, } - vim.list_extend(buf_content, vim.split(vim.inspect(error_msg), "\n")) - vim.list_extend(buf_content, { "", "Check the log file for errors", log_path }) + M.execute_command(command, handler) + else + local params = { + uri = uri, + } + client.request("java/classFileContents", params, handler, buf) end - vim.api.nvim_buf_set_option(buf, "modifiable", true) - vim.api.nvim_buf_set_lines(buf, 0, -1, false, buf_content) - vim.api.nvim_buf_set_option(buf, "filetype", "java") - -- vim.api.nvim_buf_set_option(buf, "syntax", "java") - vim.api.nvim_buf_set_option(buf, "modifiable", false) + -- Need to block. Otherwise logic could run that sets the cursor to a position + -- that's still missing. + vim.wait(timeout_ms, function() + return content ~= nil + end) end return M diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index 8a345187..0285c399 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -91,7 +91,7 @@ telescope.setup({ timeout = 1000, filetype_hook = function(filepath, bufnr, opts) if vim.startswith(filepath, "jdt://") then - require("kide.lsp.utils.jdtls").open_jdt_link(filepath, bufnr, opts.preview.timeout) + require("kide.lsp.utils.jdtls").open_classfile(filepath, bufnr, opts.preview.timeout) end return true end, From 37b204398c1c6736e62a91f0da127791e353658c Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 28 Mar 2023 16:43:54 +0800 Subject: [PATCH 042/708] =?UTF-8?q?=E5=8F=AF=E9=80=89=E9=85=8D=E7=BD=AE=20?= =?UTF-8?q?copilot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/config.lua | 8 ++++++++ lua/kide/plugins/lazy-nvim.lua | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 lua/kide/config.lua diff --git a/lua/kide/config.lua b/lua/kide/config.lua new file mode 100644 index 00000000..5631f65b --- /dev/null +++ b/lua/kide/config.lua @@ -0,0 +1,8 @@ +local M = { + plugin = { + copilot = { + enable = os.getenv("copilot_enable") or false, + }, + }, +} +return M diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 6bde7e5b..757ad031 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -1,3 +1,4 @@ +local config = require("kide.config") local function loadPluginCmd(cmd, module) vim.api.nvim_create_user_command(cmd, function() require(module) @@ -745,6 +746,7 @@ require("lazy").setup({ }, { "zbirenbaum/copilot.lua", + enabled = config.plugin.copilot.enable, lazy = true, cmd = "Copilot", config = function() @@ -756,6 +758,7 @@ require("lazy").setup({ }, { "zbirenbaum/copilot-cmp", + enabled = config.plugin.copilot.enable, lazy = true, dependencies = { "zbirenbaum/copilot.lua" }, event = "InsertEnter", From b8a65a6560cf0215b6e00f713eca0c098e69c48b Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 22 Mar 2023 17:34:26 +0800 Subject: [PATCH 043/708] =?UTF-8?q?alpha=20=E4=B8=8D=E5=8A=A0=E8=BD=BD=20l?= =?UTF-8?q?ualine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/lualine.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index f93062ac..8e4ac30b 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -7,7 +7,7 @@ local config = { component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = { - -- "dap-repl", "dapui_watches", "dapui_stacks", "dapui_breakpoints", "dapui_scopes" + "alpha", }, always_divide_middle = true, }, From 78183c9b1eaefc7da04ab8f45f8a9e0ddd4a3e8f Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 26 Mar 2023 13:44:43 +0800 Subject: [PATCH 044/708] copilot --- lua/kide/plugins/lazy-nvim.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 0a7ac760..39336bfc 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -743,6 +743,14 @@ require("lazy").setup({ require("kide.theme.gruvbox").load_trans_highlights() end, }, + + { + "github/copilot.vim", + lazy = true, + cmd = { + "Copilot", + }, + }, }, { ui = { icons = { From db4b3d4b09dada3c77d955226a6c7014517d5eef Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 26 Mar 2023 15:02:01 +0800 Subject: [PATCH 045/708] copilot --- lua/kide/core/keybindings.lua | 5 ++++- lua/kide/plugins/config/nvim-cmp.lua | 9 ++++++++- lua/kide/plugins/lazy-nvim.lua | 22 +++++++++++++++++----- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 84e3899e..0556642f 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -226,8 +226,11 @@ end M.cmp = function(cmp) local luasnip = require("luasnip") local has_words_before = function() + if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then + return false + end local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil end return { -- [""] = cmp.mapping.scroll_docs(-4), diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 90eca963..57a24f84 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -1,6 +1,11 @@ local lspkind = require("lspkind") local cmp = require("cmp") - +lspkind.init({ + symbol_map = { + Copilot = "", + }, +}) +vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" }) cmp.setup({ -- 指定 snippet 引擎 snippet = { @@ -20,6 +25,7 @@ cmp.setup({ }, -- 来源 sources = cmp.config.sources({ + { name = "copilot" }, { name = "nvim_lsp" }, -- For vsnip users. -- { name = 'vsnip' }, @@ -50,6 +56,7 @@ cmp.setup({ nvim_lsp = "[LSP]", luasnip = "[Lsnip]", path = "[Path]", + copilot = "[Copilot]", -- buffer = "[Buffer]", }, }), diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 39336bfc..6bde7e5b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -743,13 +743,25 @@ require("lazy").setup({ require("kide.theme.gruvbox").load_trans_highlights() end, }, - { - "github/copilot.vim", + "zbirenbaum/copilot.lua", lazy = true, - cmd = { - "Copilot", - }, + cmd = "Copilot", + config = function() + require("copilot").setup({ + suggestion = { enabled = false }, + panel = { enabled = false }, + }) + end, + }, + { + "zbirenbaum/copilot-cmp", + lazy = true, + dependencies = { "zbirenbaum/copilot.lua" }, + event = "InsertEnter", + config = function() + require("copilot_cmp").setup() + end, }, }, { ui = { From 815469ed58065c399787f94adcaf6b1eee4b4d65 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 28 Mar 2023 15:32:17 +0800 Subject: [PATCH 046/708] open_classfile --- lua/kide/lsp/java.lua | 4 +- lua/kide/lsp/utils/jdtls.lua | 150 ++++++++++++++++---------- lua/kide/plugins/config/telescope.lua | 2 +- 3 files changed, 96 insertions(+), 60 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index f5b867e0..60cb3453 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -520,7 +520,7 @@ M.setup = function() vim.api.nvim_create_autocmd({ "BufReadCmd" }, { pattern = "jdt://*", callback = function(e) - require("jdtls").open_jdt_link(e.file) + require("jdtls").open_classfile(e.file) end, }) vim.api.nvim_create_user_command("JdtWipeDataAndRestart", "lua require('jdtls.setup').wipe_data_and_restart()", {}) @@ -535,7 +535,7 @@ M.setup = function() -- vim.notify("load: " .. o.buf, vim.log.levels.INFO) -- print(vim.inspect(e)) -- 忽略 telescope 预览的情况 - if e.file == "java" then + if e.file == "java" and vim.bo[e.buf].buftype == "nofile" then -- ignore else M.start() diff --git a/lua/kide/lsp/utils/jdtls.lua b/lua/kide/lsp/utils/jdtls.lua index 8eb32f36..11ed90aa 100644 --- a/lua/kide/lsp/utils/jdtls.lua +++ b/lua/kide/lsp/utils/jdtls.lua @@ -1,68 +1,104 @@ +-- code from https://github.com/mfussenegger/nvim-jdtls/blob/f8fb45e05e/lua/jdtls.lua +local api = vim.api local M = {} -M.open_jdt_link = function(uri, buf, timeout) - local client - for _, c in ipairs(vim.lsp.get_active_clients()) do - if - c.config.init_options - and c.config.init_options.extendedClientCapabilities - and c.config.init_options.extendedClientCapabilities.classFileContentsSupport - then - client = c - break +function M.execute_command(command, callback, bufnr) + local clients = {} + local candidates = bufnr and vim.lsp.buf_get_clients(bufnr) or vim.lsp.get_active_clients() + for _, c in pairs(candidates) do + local command_provider = c.server_capabilities.executeCommandProvider + local commands = type(command_provider) == "table" and command_provider.commands or {} + if vim.tbl_contains(commands, command.command) then + table.insert(clients, c) end end - assert(client, "Must have a buffer open with a language client connected to eclipse.jdt.ls to load JDT URI") - local params = { - uri = uri, - } - local response = nil - local cb = function(err, result) - response = { err, result } - end - local ok, request_id = client.request("java/classFileContents", params, cb, buf) - assert(ok, "Request to `java/classFileContents` must succeed to open JDT URI. Client shutdown?") - local timeout_ms = timeout or 500 - local wait_ok, reason = vim.wait(timeout_ms, function() - return response - end) - local log_path = require("jdtls.path").join(vim.fn.stdpath("cache"), "lsp.log") - local buf_content - if wait_ok and #response == 2 and response[2] then - local content = response[2] - if content == "" then - buf_content = { - "Received response from server, but it was empty. Check the log file for errors", - log_path, - } + local num_clients = vim.tbl_count(clients) + if num_clients == 0 then + if bufnr then + -- User could've switched buffer to non-java file, try all clients + return M.execute_command(command, callback, nil) else - buf_content = vim.split(response[2], "\n", true) + vim.notify("No LSP client found that supports " .. command.command, vim.log.levels.ERROR) + return + end + end + + if num_clients > 1 then + vim.notify( + "Multiple LSP clients found that support " + .. command.command + .. " you should have at most one JDTLS server running", + vim.log.levels.WARN + ) + end + + local co + if not callback then + co = coroutine.running() + if co then + callback = function(err, resp) + coroutine.resume(co, err, resp) + end end + end + clients[1].request("workspace/executeCommand", command, callback) + if co then + return coroutine.yield() + end +end +--- Open `jdt://` uri or decompile class contents and load them into the buffer +--- +--- nvim-jdtls by defaults configures a `BufReadCmd` event which uses this function. +--- You shouldn't need to call this manually. +--- +---@param fname string +function M.open_classfile(fname, buf, timeout_ms) + local uri + local use_cmd + if vim.startswith(fname, "jdt://") then + uri = fname + use_cmd = false else - local error_msg - if not wait_ok then - client.cancel_request(request_id) - local wait_failure = { - [-1] = "timeout", - [-2] = "interrupted", - [-3] = "error", - } - error_msg = wait_failure[reason] - else - error_msg = response[1] + uri = vim.uri_from_fname(fname) + use_cmd = true + if not vim.startswith(uri, "file://") then + return end - buf_content = { - "Failed to load content for uri", - uri, - "", - "Error was: ", + end + vim.bo[buf].modifiable = true + vim.bo[buf].swapfile = false + vim.bo[buf].buftype = "nofile" + -- This triggers FileType event which should fire up the lsp client if not already running + vim.bo[buf].filetype = "java" + vim.wait(timeout_ms, function() + return next(vim.lsp.get_active_clients({ name = "jdtls" })) ~= nil + end) + local client = vim.lsp.get_active_clients({ name = "jdtls" })[1] + assert(client, "Must have a `jdtls` client to load class file or jdt uri") + + local content + local function handler(err, result) + assert(not err, vim.inspect(err)) + content = result + api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(result, "\n", { plain = true })) + vim.bo[buf].modifiable = false + end + + if use_cmd then + local command = { + command = "java.decompile", + arguments = { uri }, } - vim.list_extend(buf_content, vim.split(vim.inspect(error_msg), "\n")) - vim.list_extend(buf_content, { "", "Check the log file for errors", log_path }) + M.execute_command(command, handler) + else + local params = { + uri = uri, + } + client.request("java/classFileContents", params, handler, buf) end - vim.api.nvim_buf_set_option(buf, "modifiable", true) - vim.api.nvim_buf_set_lines(buf, 0, -1, false, buf_content) - vim.api.nvim_buf_set_option(buf, "filetype", "java") - -- vim.api.nvim_buf_set_option(buf, "syntax", "java") - vim.api.nvim_buf_set_option(buf, "modifiable", false) + -- Need to block. Otherwise logic could run that sets the cursor to a position + -- that's still missing. + vim.wait(timeout_ms, function() + return content ~= nil + end) end return M diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index 8a345187..0285c399 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -91,7 +91,7 @@ telescope.setup({ timeout = 1000, filetype_hook = function(filepath, bufnr, opts) if vim.startswith(filepath, "jdt://") then - require("kide.lsp.utils.jdtls").open_jdt_link(filepath, bufnr, opts.preview.timeout) + require("kide.lsp.utils.jdtls").open_classfile(filepath, bufnr, opts.preview.timeout) end return true end, From e36651e33e80517ac988ed932bd1c1563b120971 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 28 Mar 2023 16:43:54 +0800 Subject: [PATCH 047/708] =?UTF-8?q?=E5=8F=AF=E9=80=89=E9=85=8D=E7=BD=AE=20?= =?UTF-8?q?copilot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/config.lua | 8 ++++++++ lua/kide/plugins/lazy-nvim.lua | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 lua/kide/config.lua diff --git a/lua/kide/config.lua b/lua/kide/config.lua new file mode 100644 index 00000000..5631f65b --- /dev/null +++ b/lua/kide/config.lua @@ -0,0 +1,8 @@ +local M = { + plugin = { + copilot = { + enable = os.getenv("copilot_enable") or false, + }, + }, +} +return M diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 6bde7e5b..757ad031 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -1,3 +1,4 @@ +local config = require("kide.config") local function loadPluginCmd(cmd, module) vim.api.nvim_create_user_command(cmd, function() require(module) @@ -745,6 +746,7 @@ require("lazy").setup({ }, { "zbirenbaum/copilot.lua", + enabled = config.plugin.copilot.enable, lazy = true, cmd = "Copilot", config = function() @@ -756,6 +758,7 @@ require("lazy").setup({ }, { "zbirenbaum/copilot-cmp", + enabled = config.plugin.copilot.enable, lazy = true, dependencies = { "zbirenbaum/copilot.lua" }, event = "InsertEnter", From 1ff6f3573d1195d0a181c224f6c402613839c3e1 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 7 Apr 2023 09:39:16 +0800 Subject: [PATCH 048/708] sqlls --- lua/kide/lsp/init.lua | 2 +- lua/kide/lsp/{sqls.lua => sqlls.lua} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lua/kide/lsp/{sqls.lua => sqlls.lua} (100%) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 2ddec97d..5861ef32 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -18,7 +18,7 @@ local server_configs = { html = require("kide.lsp.html"), pyright = require("kide.lsp.pyright"), rust_analyzer = require("kide.lsp.rust_analyzer"), - sqls = require("kide.lsp.sqls"), + sqlls = require("kide.lsp.sqlls"), gopls = require("kide.lsp.gopls"), kotlin_language_server = {}, vuels = {}, diff --git a/lua/kide/lsp/sqls.lua b/lua/kide/lsp/sqlls.lua similarity index 100% rename from lua/kide/lsp/sqls.lua rename to lua/kide/lsp/sqlls.lua From 72ab0ee82d35df4a697f5693710359f0a4135c6c Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 7 Apr 2023 10:18:11 +0800 Subject: [PATCH 049/708] udpate java md doc --- lua/kide/lsp/java.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 60cb3453..255c1f96 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -407,11 +407,12 @@ local function markdown_format(input) -- input = string.gsub(input, "[\r\n]( +)(%*)", function (i1) -- return i1 .. "-" -- end) - input = string.gsub(input, "%[([^:/]*)%]", function(i1) + input = string.gsub(input, "%[([%a%$_]+[%.%w%(%)]*)%]%(file:/[^%)]+%)", function(i1) + return "`" .. i1 .. "`" + end) + input = string.gsub(input, "%[([%a%$_]+[%.%w%(%)]*)%]%(jdt://[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%(file:/[^%)]+%)", "") - input = string.gsub(input, "%(jdt://[^%)]+%)", "") end return input end From a92c791840d0adfb5f9264606b37afd2658c2e37 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 7 Apr 2023 17:02:28 +0800 Subject: [PATCH 050/708] java md doc --- lua/kide/lsp/java.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 255c1f96..13618c20 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -407,10 +407,10 @@ local function markdown_format(input) -- input = string.gsub(input, "[\r\n]( +)(%*)", function (i1) -- return i1 .. "-" -- end) - input = string.gsub(input, "%[([%a%$_]+[%.%w%(%)]*)%]%(file:/[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]+[%.%w%(%),%s ]*)%]%(file:/[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%[([%a%$_]+[%.%w%(%)]*)%]%(jdt://[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]+[%.%w%(%),%s ]*)%]%(jdt://[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) end From ddc9747b51567e33363d17b4bff0283535a159f4 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 11 Apr 2023 10:00:45 +0800 Subject: [PATCH 051/708] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20jdt.ls=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/java.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 13618c20..b16cb876 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -192,7 +192,7 @@ local config = { -- '-XX:+UseStringDeduplication', -- '-Xms512m', "-XX:+UseZGC", - "-Xmx4g", + "-Xmx1g", -- "-Xbootclasspath/a:" .. get_lombok_jar(), "-javaagent:" .. get_lombok_jar(), "--add-modules=ALL-SYSTEM", @@ -221,6 +221,12 @@ local config = { java = { maxConcurrentBuilds = 8, home = get_java_home(), + jdt = { + ls = { + -- 暂时不可用 + lombokSupport = { enabled = true }, + }, + }, project = { encoding = "UTF-8", resourceFilters = { @@ -228,6 +234,8 @@ local config = { ".git", }, }, + foldingRange = { enabled = true }, + selectionRange = { enabled = true }, import = { exclusions = { "**/node_modules/**", @@ -342,6 +350,7 @@ config["init_options"] = { } config["on_attach"] = function(client, buffer) + -- client.server_capabilities.semanticTokensProvider = nil -- With `hotcodereplace = 'auto' the debug adapter will try to apply code changes -- you make during a debug session immediately. -- Remove the option if you do not want that. From 6cb3b4c63350a7b3d29ff9c3c8f3769a965c434e Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 11 Apr 2023 10:22:18 +0800 Subject: [PATCH 052/708] autobuild --- lua/kide/lsp/java.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index b16cb876..56a7fd2e 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -237,6 +237,8 @@ local config = { foldingRange = { enabled = true }, selectionRange = { enabled = true }, import = { + gradle = { enabled = true }, + maven = { enabled = true }, exclusions = { "**/node_modules/**", "**/.metadata/**", @@ -245,6 +247,7 @@ local config = { "**/.git/**", }, }, + autobuild = { enabled = true }, referenceCodeLens = { enabled = true }, implementationsCodeLens = { enabled = true }, templates = { From 94fa9b14a91fbcd3fb473ee81c918ced13a2f8ac Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 11 Apr 2023 11:37:50 +0800 Subject: [PATCH 053/708] test --- lua/kide/lsp/java.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 56a7fd2e..f27562a0 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -419,10 +419,10 @@ local function markdown_format(input) -- input = string.gsub(input, "[\r\n]( +)(%*)", function (i1) -- return i1 .. "-" -- end) - input = string.gsub(input, "%[([%a%$_]+[%.%w%(%),%s ]*)%]%(file:/[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%s ]*)%]%(file:/[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%[([%a%$_]+[%.%w%(%),%s ]*)%]%(jdt://[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%s ]*)%]%(jdt://[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) end From f438b6977a914a2f9d1a21e4ded4ec3a3f61cb97 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Apr 2023 09:09:06 +0800 Subject: [PATCH 054/708] maven --- lua/kide/core/utils/maven.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/core/utils/maven.lua b/lua/kide/core/utils/maven.lua index e4525a61..1df5a0bb 100644 --- a/lua/kide/core/utils/maven.lua +++ b/lua/kide/core/utils/maven.lua @@ -98,7 +98,7 @@ M.maven_command = function(buf) close_on_exit = false, }) create_command(buf, "MavenDownloadSources", "mvn dependency:sources -DdownloadSources=true") - create_command(buf, "MavenTest", "mvn test", maven_args_complete({ "-Dtest=" }, {})) + create_command(buf, "MavenTest", "mvn test", maven_args_complete({ "-Dtest=" }, {}), { close_on_exit = false }) end M.setup = function() From a05af2ca319ae8ba3875afac282991fa565a9014 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 24 Apr 2023 19:56:02 +0800 Subject: [PATCH 055/708] update jdtls --- lua/kide/lsp/java.lua | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index f27562a0..286d9398 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -406,13 +406,8 @@ config.handlers["language/status"] = function(_, s) end end --- 已合并,需要编译最新版本支持 -if not env.JDTLS_HOME then - -- java 暂时兼容 fidget, 等待上游支持 - -- https://github.com/eclipse/eclipse.jdt.ls/pull/2258 - vim.lsp.handlers["$/progress"] = nil - require("fidget").setup({}) -end +vim.lsp.handlers["$/progress"] = nil +require("fidget").setup({}) local function markdown_format(input) if input then From 713c5f03d0d9ce31f0328fe53f27b0f1d478de9f Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 25 Apr 2023 18:09:26 +0800 Subject: [PATCH 056/708] lemminx --- README.md | 5 +++++ lua/kide/lsp/init.lua | 4 ++++ lua/kide/lsp/lemminx.lua | 25 ++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index caddbde2..015f1dbb 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,11 @@ git clone https://github.com/JavaHello/nvim.git Debug +
+Maven(pom.xml 自动补全) + Debug +
+ ## 我的 VIM 插件列表 | 插件名称 | 插件描述 | 推荐等级 | 备注 | diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 5861ef32..4fa289c7 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -22,6 +22,7 @@ local server_configs = { gopls = require("kide.lsp.gopls"), kotlin_language_server = {}, vuels = {}, + lemminx = require("kide.lsp.lemminx"), } -- Setup lspconfig. @@ -68,6 +69,9 @@ require("mason-lspconfig").setup_handlers({ end end, }) +if server_configs.lemminx.setup then + server_configs.lemminx.setup() +end -- LSP 相关美化参考 https://github.com/NvChad/NvChad local function lspSymbol(name, icon) diff --git a/lua/kide/lsp/lemminx.lua b/lua/kide/lsp/lemminx.lua index a5647075..1549713a 100644 --- a/lua/kide/lsp/lemminx.lua +++ b/lua/kide/lsp/lemminx.lua @@ -1 +1,24 @@ -return {} +local M = {} +local lemminx_home = os.getenv("LEMMINX_HOME") +if lemminx_home then + M.setup = function() + local lspconfig = require("lspconfig") + local utils = require("kide.core.utils") + + local lemminx_jars = {} + for _, bundle in ipairs(vim.split(vim.fn.glob(lemminx_home .. "/*.jar"), "\n")) do + table.insert(lemminx_jars, bundle) + end + vim.fn.join(lemminx_jars, utils.is_win and ";" or ":") + lspconfig["lemminx"].setup({ + cmd = { + "java", + "-cp", + vim.fn.join(lemminx_jars, ":"), + "org.eclipse.lemminx.XMLServerLauncher", + }, + }) + end +end + +return M From ee835ded746c19c0c90db5d87b986e41e37a071c Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 26 Apr 2023 18:17:43 +0800 Subject: [PATCH 057/708] =?UTF-8?q?=E4=B8=8D=E4=B9=A0=E6=83=AF=20jk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/keybindings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 0556642f..59f87790 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -8,7 +8,7 @@ local M = {} M.setup = function() -- Esc - map("i", "jk", "", opt) + -- map("i", "jk", "", opt) -- n 模式下复制内容到系统剪切板 map("n", "c", '"+yy', opt) -- v 模式下复制内容到系统剪切板 From 4a96059ad543f662bebfc22f399db0d9ee3c0135 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 26 Apr 2023 20:06:32 +0800 Subject: [PATCH 058/708] =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/lemminx.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/kide/lsp/lemminx.lua b/lua/kide/lsp/lemminx.lua index 1549713a..f8907d23 100644 --- a/lua/kide/lsp/lemminx.lua +++ b/lua/kide/lsp/lemminx.lua @@ -17,6 +17,12 @@ if lemminx_home then vim.fn.join(lemminx_jars, ":"), "org.eclipse.lemminx.XMLServerLauncher", }, + on_attach = function(client, buffer) + require("kide.core.keybindings").maplsp(client, buffer) + if client.server_capabilities.documentSymbolProvider then + require("nvim-navic").attach(client, buffer) + end + end, }) end end From 2cd87cc46857c54ca779d74c038b44c883dcdd97 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 26 Apr 2023 20:22:51 +0800 Subject: [PATCH 059/708] navic --- lua/kide/plugins/config/lualine.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index 8e4ac30b..e90dee9e 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -1,5 +1,3 @@ -local navic = require("nvim-navic") - local config = { options = { icons_enabled = true, @@ -30,7 +28,7 @@ local config = { end, }, "filename", - { navic.get_location, cond = navic.is_available }, + "navic", }, lualine_x = { "encoding", "fileformat", "filetype" }, lualine_y = { "progress" }, From 2a3d801548abfaca0e621cd7e33e1d20524dcefe Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 27 Apr 2023 11:47:23 +0800 Subject: [PATCH 060/708] load --- lua/kide/plugins/lazy-nvim.lua | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 757ad031..63b76b9f 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -1,9 +1,4 @@ local config = require("kide.config") -local function loadPluginCmd(cmd, module) - vim.api.nvim_create_user_command(cmd, function() - require(module) - end, {}) -end require("lazy").setup({ @@ -190,23 +185,17 @@ require("lazy").setup({ { "mfussenegger/nvim-dap", lazy = true, - event = { "BufNewFile", "BufReadPost" }, + event = { "VeryLazy" }, config = function() require("kide.dap") - require("nvim-dap-virtual-text").setup({}) - require("telescope").load_extension("dap") + -- require("telescope").load_extension("dap") end, }, { "rcarriga/nvim-dap-ui", lazy = true, dependencies = { "mfussenegger/nvim-dap" }, - cmd = { - "LoadDapUI", - }, - init = function() - loadPluginCmd("LoadDapUI", "dapui") - end, + event = { "VeryLazy" }, config = function() require("kide.plugins.config.nvim-dap-ui") end, @@ -214,7 +203,11 @@ require("lazy").setup({ { "theHamsta/nvim-dap-virtual-text", lazy = true, + event = { "VeryLazy" }, dependencies = { "mfussenegger/nvim-dap" }, + config = function() + require("nvim-dap-virtual-text").setup({}) + end, }, -- 搜索插件 @@ -222,6 +215,7 @@ require("lazy").setup({ "nvim-telescope/telescope.nvim", lazy = true, dependencies = { "ellisonleao/gruvbox.nvim" }, + event = { "VeryLazy" }, cmd = { "Telescope" }, keys = { "" }, tag = "0.1.1", @@ -290,7 +284,7 @@ require("lazy").setup({ { "lewis6991/gitsigns.nvim", layz = true, - event = { "BufReadPost" }, + event = { "VeryLazy", "BufReadPost" }, config = function() require("kide.plugins.config.gitsigns-nvim") end, From 34119e452bdaba526603323890c4c73863859541 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 27 Apr 2023 15:46:18 +0800 Subject: [PATCH 061/708] autoclose dapui_console --- lua/kide/plugins/config/lualine.lua | 1 + lua/kide/plugins/config/nvim-dap-ui.lua | 71 ++++++++++++++++++++----- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index e90dee9e..8380c28d 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -55,6 +55,7 @@ dap.sections = { } dap.filetypes = { "dap-terminal", + "dapui_console", } table.insert(config.extensions, dap) diff --git a/lua/kide/plugins/config/nvim-dap-ui.lua b/lua/kide/plugins/config/nvim-dap-ui.lua index 8d0bc361..99c5b727 100644 --- a/lua/kide/plugins/config/nvim-dap-ui.lua +++ b/lua/kide/plugins/config/nvim-dap-ui.lua @@ -26,33 +26,78 @@ dapui.setup({ }, { elements = { - { id = "repl", size = 1 }, - -- { id = "console", size = 0.5 }, + { id = "repl", size = 0.3 }, + { id = "console", size = 0.7 }, }, size = 0.25, position = "bottom", }, }, }) +local M = { dapui_active = false } -dap.defaults.fallback.terminal_win_cmd = "belowright 12new | set filetype=dap-terminal" - -dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() +local function auto_close(bufnr) + local acid + acid = vim.api.nvim_create_autocmd({ "BufDelete", "BufHidden" }, { + buffer = bufnr, + callback = function() + if M.dapui_active then + require("dapui").close() + M.dapui_active = false + else + dap.repl.close() + end + vim.api.nvim_del_autocmd(acid) + end, + }) end -dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() + +-- dap.defaults.fallback.terminal_win_cmd = "belowright 12new | set filetype=dap-terminal" +local dapui_console = dap.defaults.fallback.terminal_win_cmd +dap.defaults.fallback.terminal_win_cmd = function() + if M.dapui_active then + local bufnr = dapui_console() + auto_close(bufnr) + return bufnr + else + local cur_win = vim.api.nvim_get_current_win() + -- open terminal + vim.api.nvim_command("belowright 12new") + local bufnr = vim.api.nvim_get_current_buf() + vim.bo[bufnr].modifiable = false + vim.bo[bufnr].swapfile = false + vim.bo[bufnr].buftype = "nofile" + vim.bo[bufnr].filetype = "dap-terminal" + + local win = vim.api.nvim_get_current_win() + vim.api.nvim_set_current_win(cur_win) + auto_close(bufnr) + return bufnr, win + end end -dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() + +dap.listeners.after.event_initialized["dapui_config"] = function() + -- dapui.open() + if not M.dapui_active then + dap.repl.open() + end end +-- dap.listeners.before.event_terminated["dapui_config"] = function() +-- dapui.close() +-- end +-- dap.listeners.before.event_exited["dapui_config"] = function() +-- dapui.close() +-- end -- nvim-dap vim.api.nvim_create_user_command("DapUIOpen", function() - require("dapui").open({}) + M.dapui_active = true + require("dapui").open() end, {}) vim.api.nvim_create_user_command("DapUIClose", function() - require("dapui").close({}) + M.dapui_active = false + require("dapui").close() end, {}) vim.api.nvim_create_user_command("DapUIToggle", function() - require("dapui").toggle({}) + M.dapui_active = not M.dapui_active + require("dapui").toggle() end, {}) From 3e7d40f815a0053820a040080b3271bf7bfb09d7 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 27 Apr 2023 16:23:51 +0800 Subject: [PATCH 062/708] update version --- lua/kide/plugins/config/bufferline.lua | 2 +- lua/kide/plugins/lazy-nvim.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/plugins/config/bufferline.lua b/lua/kide/plugins/config/bufferline.lua index a722632c..937c8895 100644 --- a/lua/kide/plugins/config/bufferline.lua +++ b/lua/kide/plugins/config/bufferline.lua @@ -74,7 +74,7 @@ require("bufferline").setup({ }, color_icons = true, show_buffer_close_icons = true, - show_buffer_default_icon = true, + -- show_buffer_default_icon = true, show_close_icon = false, show_tab_indicators = true, -- separator_style = "slant" | "thick" | "thin" | { 'any', 'any' }, diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 63b76b9f..fa7e1f82 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -126,7 +126,7 @@ require("lazy").setup({ -- using packer.nvim { "akinsho/bufferline.nvim", - tag = "v3.0.1", + version = "*", dependencies = { "ellisonleao/gruvbox.nvim" }, requires = "kyazdani42/nvim-web-devicons", config = function() From 79b5a674676206756c3ff3ec11597fe55f5db846 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 27 Apr 2023 16:26:12 +0800 Subject: [PATCH 063/708] nvim-tree update --- lua/kide/plugins/config/nvim-tree.lua | 2 +- lua/kide/plugins/lazy-nvim.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/plugins/config/nvim-tree.lua b/lua/kide/plugins/config/nvim-tree.lua index 93830b5f..a4590928 100644 --- a/lua/kide/plugins/config/nvim-tree.lua +++ b/lua/kide/plugins/config/nvim-tree.lua @@ -48,7 +48,6 @@ require("nvim-tree").setup({ view = { width = 34, -- height = 40, - hide_root_folder = true, side = "left", preserve_window_proportions = false, number = false, @@ -64,6 +63,7 @@ require("nvim-tree").setup({ }, }, renderer = { + hide_root_folder = true, indent_markers = { enable = false, icons = { diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index fa7e1f82..75327049 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -117,7 +117,7 @@ require("lazy").setup({ "kyazdani42/nvim-tree.lua", lazy = true, cmd = "NvimTreeToggle", - tag = "nightly", + version = "*", config = function() require("kide.plugins.config.nvim-tree") end, From 02bb8106f40e30d6582dd28b388b0bcc02287ed0 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 27 Apr 2023 16:39:02 +0800 Subject: [PATCH 064/708] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=BF=87=E6=97=B6?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/nvim-tree.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/kide/plugins/config/nvim-tree.lua b/lua/kide/plugins/config/nvim-tree.lua index a4590928..b4ab81e6 100644 --- a/lua/kide/plugins/config/nvim-tree.lua +++ b/lua/kide/plugins/config/nvim-tree.lua @@ -49,21 +49,22 @@ require("nvim-tree").setup({ width = 34, -- height = 40, side = "left", + hide_root_folder = false, preserve_window_proportions = false, number = false, relativenumber = false, signcolumn = "yes", mappings = { custom_only = false, - list = { - - { key = "ff", cb = custom_callback("launch_find_files") }, - { key = "fg", cb = custom_callback("launch_live_grep") }, - }, + -- list = { + -- + -- { key = "ff", cb = custom_callback("launch_find_files") }, + -- { key = "fg", cb = custom_callback("launch_live_grep") }, + -- }, }, }, renderer = { - hide_root_folder = true, + root_folder_label = false, indent_markers = { enable = false, icons = { From 8e13cba2281aa4697b0b5c3188331d7ded737514 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 2 May 2023 23:17:09 +0800 Subject: [PATCH 065/708] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/lazy-nvim.lua | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 75327049..921443ef 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -158,9 +158,33 @@ require("lazy").setup({ init = function() -- 不加载 nvim-jdtls.vim vim.g.nvim_jdtls = 1 - end, - config = function() - require("kide.lsp.java").setup() + vim.api.nvim_create_autocmd({ "BufReadCmd" }, { + pattern = "jdt://*", + callback = function(e) + require("jdtls").open_classfile(e.file) + end, + }) + vim.api.nvim_create_user_command( + "JdtWipeDataAndRestart", + "lua require('jdtls.setup').wipe_data_and_restart()", + {} + ) + vim.api.nvim_create_user_command("JdtShowLogs", "lua require('jdtls.setup').show_logs()", {}) + + local group = vim.api.nvim_create_augroup("kide_jdtls_java", { clear = true }) + vim.api.nvim_create_autocmd({ "FileType" }, { + group = group, + pattern = { "java" }, + desc = "jdtls", + callback = function(e) + if e.file == "java" and vim.bo[e.buf].buftype == "nofile" then + -- ignore + else + require("kide.lsp.java").start() + end + end, + }) + return group end, }, { From df9c7f1f8ef64d96d253e7aee7dcd940f039a6aa Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 3 May 2023 10:01:42 +0800 Subject: [PATCH 066/708] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/alpha-nvim.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/kide/plugins/config/alpha-nvim.lua b/lua/kide/plugins/config/alpha-nvim.lua index 0fb04a6e..bb8293a5 100644 --- a/lua/kide/plugins/config/alpha-nvim.lua +++ b/lua/kide/plugins/config/alpha-nvim.lua @@ -16,16 +16,16 @@ local opt = { noremap = true, silent = true } -- Set menu dashboard.section.buttons.val = { dashboard.button(" ff", " Find File", ":Telescope find_files", opt), - dashboard.button(" fg", " Find Word ", ":Telescope live_grep", opt), + dashboard.button(" fg", "󰈭 Find Word ", ":Telescope live_grep", opt), dashboard.button( " fp", " Recent Projects", ":lua require'telescope'.extensions.project.project{ display_type = 'full' }", opt ), - dashboard.button(" fo", " Recent File", ":Telescope oldfiles", opt), + dashboard.button(" fo", " Recent File", ":Telescope oldfiles", opt), dashboard.button(" ns", " Settings", ":e $MYVIMRC | :cd %:p:h ", opt), - dashboard.button(" q ", " Quit NVIM", ":qa", opt), + dashboard.button(" q ", "󰅚 Quit NVIM", ":qa", opt), } -- Send config to alpha From 78187e225fb7a7a9594218b36aa2107857306a7d Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 3 May 2023 13:25:12 +0800 Subject: [PATCH 067/708] =?UTF-8?q?[]=20=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/java.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 286d9398..4d63c0ab 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -414,10 +414,10 @@ local function markdown_format(input) -- input = string.gsub(input, "[\r\n]( +)(%*)", function (i1) -- return i1 .. "-" -- end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%s ]*)%]%(file:/[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s ]*)%]%(file:/[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%s ]*)%]%(jdt://[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s ]*)%]%(jdt://[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) end From 53e0761cb6409e54b413eab4d80718b85306840e Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 3 May 2023 15:58:04 +0800 Subject: [PATCH 068/708] gdscript --- lua/kide/lsp/gdscript.lua | 6 ++++++ lua/kide/lsp/init.lua | 12 ++++++++++-- lua/kide/lsp/lemminx.lua | 8 +++++--- 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 lua/kide/lsp/gdscript.lua diff --git a/lua/kide/lsp/gdscript.lua b/lua/kide/lsp/gdscript.lua new file mode 100644 index 00000000..4767469f --- /dev/null +++ b/lua/kide/lsp/gdscript.lua @@ -0,0 +1,6 @@ +local M = {} +M.setup = function(opt) + require("lspconfig").gdscript.setup(opt) +end + +return M diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 4fa289c7..6fd9c826 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -23,6 +23,7 @@ local server_configs = { kotlin_language_server = {}, vuels = {}, lemminx = require("kide.lsp.lemminx"), + gdscript = require("kide.lsp.gdscript"), } -- Setup lspconfig. @@ -69,8 +70,15 @@ require("mason-lspconfig").setup_handlers({ end end, }) -if server_configs.lemminx.setup then - server_configs.lemminx.setup() + +for _, value in pairs(server_configs) do + if value.setup then + value.setup({ + flags = { + debounce_text_changes = 150, + }, + }) + end end -- LSP 相关美化参考 https://github.com/NvChad/NvChad diff --git a/lua/kide/lsp/lemminx.lua b/lua/kide/lsp/lemminx.lua index f8907d23..4483d61c 100644 --- a/lua/kide/lsp/lemminx.lua +++ b/lua/kide/lsp/lemminx.lua @@ -1,7 +1,7 @@ local M = {} local lemminx_home = os.getenv("LEMMINX_HOME") if lemminx_home then - M.setup = function() + M.setup = function(opt) local lspconfig = require("lspconfig") local utils = require("kide.core.utils") @@ -10,7 +10,8 @@ if lemminx_home then table.insert(lemminx_jars, bundle) end vim.fn.join(lemminx_jars, utils.is_win and ";" or ":") - lspconfig["lemminx"].setup({ + + local config = vim.tbl_deep_extend("keep", { cmd = { "java", "-cp", @@ -23,7 +24,8 @@ if lemminx_home then require("nvim-navic").attach(client, buffer) end end, - }) + }, opt) + lspconfig["lemminx"].setup(config) end end From 929247019039d9a3874d1fafdd0a6b5b12ec215c Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 3 May 2023 16:01:37 +0800 Subject: [PATCH 069/708] lsp config --- lua/kide/lsp/init.lua | 8 ++++++++ lua/kide/lsp/lemminx.lua | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 6fd9c826..3025619d 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -77,6 +77,14 @@ for _, value in pairs(server_configs) do flags = { debounce_text_changes = 150, }, + capabilities = capabilities, + on_attach = function(client, buffer) + -- 绑定快捷键 + require("kide.core.keybindings").maplsp(client, buffer) + if client.server_capabilities.documentSymbolProvider then + require("nvim-navic").attach(client, buffer) + end + end, }) end end diff --git a/lua/kide/lsp/lemminx.lua b/lua/kide/lsp/lemminx.lua index 4483d61c..7ccb45d6 100644 --- a/lua/kide/lsp/lemminx.lua +++ b/lua/kide/lsp/lemminx.lua @@ -18,12 +18,6 @@ if lemminx_home then vim.fn.join(lemminx_jars, ":"), "org.eclipse.lemminx.XMLServerLauncher", }, - on_attach = function(client, buffer) - require("kide.core.keybindings").maplsp(client, buffer) - if client.server_capabilities.documentSymbolProvider then - require("nvim-navic").attach(client, buffer) - end - end, }, opt) lspconfig["lemminx"].setup(config) end From 054dc1160f1297dd897e15098909ebbfa7ee2909 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 3 May 2023 16:08:40 +0800 Subject: [PATCH 070/708] gd expandtab=false --- lua/kide/core/basic.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index ebbed11e..946cc0ef 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -76,6 +76,18 @@ autocmd("FileType", { vim.opt_local.expandtab = true end, }) +autocmd("FileType", { + pattern = { + "gd", + "gdscript", + "gdscript3", + }, + callback = function() + vim.opt_local.tabstop = 4 + vim.opt_local.shiftwidth = 4 + vim.opt_local.expandtab = false + end, +}) -- 新行对齐当前行,空格替代tab vim.opt.expandtab = true From 733bed8160d0cb9fd08418e645c755e63052c699 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 4 May 2023 10:39:09 +0800 Subject: [PATCH 071/708] update neovim version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 015f1dbb..04742331 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 可配置 `Java`, `Rust`, `C/C++`, `JavaScript` 等编程语言开发环境。 极速启动 (`startuptime` 20 ~ 70 ms)。 -使用 `neovim v0.8.3`+ 版本。 +使用 `neovim v0.9.0`+ 版本。 ## 安装 From 61f210f530e1addebe35a03daa0817094dd67c7d Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 7 May 2023 21:27:44 +0800 Subject: [PATCH 072/708] Esc noh --- lua/kide/core/keybindings.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 59f87790..f458f049 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -17,6 +17,7 @@ M.setup = function() map("n", "v", '"+p', opt) -- 取消搜索高亮显示 map("n", "", ":nohlsearch", opt) + map("n", "", ":nohlsearch", opt) keymap("n", "", "h", opt) keymap("n", "", "j", opt) From 7763df18fe70e34cdfe375326c1f2d0e48f76fa1 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 7 May 2023 22:00:41 +0800 Subject: [PATCH 073/708] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/keybindings.lua | 2 +- lua/kide/plugins/lazy-nvim.lua | 51 +++++++--------------------------- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index f458f049..f52e7705 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -142,7 +142,7 @@ M.maplsp = function(client, buffer) -- mapbuf('n', 'ca', 'lua require("lspsaga.codeaction").code_action()', opt) -- go xx -- mapbuf('n', 'gd', 'lua vim.lsp.buf.definition()', opt) - -- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'Trouble lsp_definitions', opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "gD", "lua vim.lsp.buf.declaration()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "Telescope lsp_definitions", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gh", "lua vim.lsp.buf.hover()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gs", "lua vim.lsp.buf.signature_help()", opt) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 921443ef..0b968422 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -9,6 +9,9 @@ require("lazy").setup({ { "kyazdani42/nvim-web-devicons", + config = function() + require("nvim-web-devicons").setup({}) + end, lazy = true, }, { @@ -59,7 +62,7 @@ require("lazy").setup({ -- nvim-cmp { "hrsh7th/nvim-cmp", - event = { "InsertEnter" }, + event = { "InsertEnter", "VeryLazy" }, keys = { ":", "/", "?" }, dependencies = { "hrsh7th/cmp-path", @@ -405,7 +408,7 @@ require("lazy").setup({ -- 颜色显示 { "norcalli/nvim-colorizer.lua", - event = { "BufReadPost", "InsertEnter" }, + event = { "BufReadPost", "InsertEnter", "VeryLazy" }, config = function() require("kide.plugins.config.nvim-colorizer") end, @@ -465,7 +468,7 @@ require("lazy").setup({ { "folke/which-key.nvim", lazy = true, - keys = "", + event = { "VeryLazy" }, config = function() require("kide.plugins.config.which-key") end, @@ -513,7 +516,7 @@ require("lazy").setup({ -- () 自动补全 { "windwp/nvim-autopairs", - event = { "InsertEnter" }, + event = { "InsertEnter", "VeryLazy" }, config = function() require("kide.plugins.config.nvim-autopairs") end, @@ -650,7 +653,8 @@ require("lazy").setup({ { "kylechui/nvim-surround", lazy = true, - event = { "InsertEnter" }, + version = "*", + event = { "VeryLazy" }, config = function() require("nvim-surround").setup({}) end, @@ -727,41 +731,6 @@ require("lazy").setup({ require("todo-comments").setup({}) end, }, - { - "denstiny/cmp-dictionary-nanny", - enabled = false, - build = "./install.sh", - config = function() - require("cmp-dictionary-nanny.config").setup({}) - end, - event = { "InsertEnter" }, - }, - { - "JuanZoran/Trans.nvim", - enabled = false, - keys = { - -- 可以换成其他你想映射的键 - { "mm", mode = { "n", "x" }, "Translate", desc = " Translate" }, - { "mk", mode = { "n", "x" }, "TransPlay", desc = " 自动发音" }, - - -- 目前这个功能的视窗还没有做好,可以在配置里将view.i改成hover - { "mi", "TranslateInput", desc = " Translate From Input" }, - }, - dependencies = { "kkharji/sqlite.lua", lazy = true }, - config = function() - require("Trans").setup({ - db_path = "$HOME/.local/share/nvim/data/ultimate.db", - icon = { - star = "", - notfound = " ", - yes = "", - no = "", - cell = "■", - }, - }) - require("kide.theme.gruvbox").load_trans_highlights() - end, - }, { "zbirenbaum/copilot.lua", enabled = config.plugin.copilot.enable, @@ -779,7 +748,7 @@ require("lazy").setup({ enabled = config.plugin.copilot.enable, lazy = true, dependencies = { "zbirenbaum/copilot.lua" }, - event = "InsertEnter", + event = { "InsertEnter", "VeryLazy" }, config = function() require("copilot_cmp").setup() end, From 4d82c85cf5d7df0d107d70da301151b4571775a4 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 7 May 2023 22:06:59 +0800 Subject: [PATCH 074/708] event VeryLazy --- lua/kide/plugins/lazy-nvim.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 0b968422..5497abd9 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -17,7 +17,7 @@ require("lazy").setup({ { "williamboman/mason.nvim", lazy = true, - cmd = { "Mason", "MasonInstall", "MasonLog", "MasonUninstall" }, + event = { "VeryLazy" }, config = function() require("kide.plugins.config.mason-nvim") end, From 8cc206f5a39cfb66dad84532a6a660a6538b7bd6 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 8 May 2023 20:17:47 +0800 Subject: [PATCH 075/708] close_with_q --- lua/kide/core/basic.lua | 41 +++++++++++++++++++++++++++------- lua/kide/plugins/lazy-nvim.lua | 1 + 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 946cc0ef..562f83c1 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -136,14 +136,6 @@ vim.opt.mouse = "a" vim.opt.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value vim.opt.foldlevelstart = 99 --- Highlight on yank -vim.api.nvim_create_autocmd({ "TextYankPost" }, { - pattern = { "*" }, - callback = function() - vim.highlight.on_yank() - end, -}) - vim.opt_global.completeopt = "menu,menuone,noselect" if vim.g.neovide then vim.g.neovide_cursor_vfx_mode = "railgun" @@ -166,3 +158,36 @@ autocmd("BufReadPost", { vim.opt_global.grepprg = "rg --vimgrep --no-heading --smart-case" vim.opt_global.grepformat = "%f:%l:%c:%m,%f:%l:%m" + +--- see https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua +local function augroup(name) + return vim.api.nvim_create_augroup("kide" .. name, { clear = true }) +end +-- Highlight on yank +autocmd({ "TextYankPost" }, { + group = augroup("highlight_yank"), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- close some filetypes with +autocmd("FileType", { + group = augroup("close_with_q"), + pattern = { + "PlenaryTestPopup", + "help", + "lspinfo", + "man", + "notify", + "qf", + "spectre_panel", + "startuptime", + "tsplayground", + "checkhealth", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) + end, +}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 5497abd9..665df275 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -427,6 +427,7 @@ require("lazy").setup({ { "danymat/neogen", lazy = true, + event = { "VeryLazy" }, config = function() require("kide.plugins.config.neogen") end, From 2b95004a66cd7e57c96b502d5954a8d3194d8f43 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 8 May 2023 20:48:41 +0800 Subject: [PATCH 076/708] dap-python --- lua/kide/config.lua | 3 +++ lua/kide/lsp/pyright.lua | 12 +++++++++++- lua/kide/plugins/lazy-nvim.lua | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/kide/config.lua b/lua/kide/config.lua index 5631f65b..ecf905e2 100644 --- a/lua/kide/config.lua +++ b/lua/kide/config.lua @@ -1,4 +1,7 @@ local M = { + env = { + py_bin = os.getenv("py_bin") or "/usr/bin/python3", + }, plugin = { copilot = { enable = os.getenv("copilot_enable") or false, diff --git a/lua/kide/lsp/pyright.lua b/lua/kide/lsp/pyright.lua index a5647075..711bab84 100644 --- a/lua/kide/lsp/pyright.lua +++ b/lua/kide/lsp/pyright.lua @@ -1 +1,11 @@ -return {} +return { + server = { + on_attach = function(_, bufnr) + local dap_py = require("dap-python") + local opts = { silent = true, buffer = bufnr } + vim.keymap.set("n", "dc", dap_py.test_class, opts) + vim.keymap.set("n", "dm", dap_py.test_method, opts) + vim.keymap.set("v", "ds", dap_py.debug_selection, opts) + end, + }, +} diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 665df275..a4ecd6b4 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -237,6 +237,16 @@ require("lazy").setup({ end, }, + { + "mfussenegger/nvim-dap-python", + lazy = true, + ft = "java", + dependencies = { "mfussenegger/nvim-dap" }, + config = function() + require("dap-python").setup(config.env.py_bin) + end, + }, + -- 搜索插件 { "nvim-telescope/telescope.nvim", From ab03ba4234eafe4281167041c6874db7060d87c2 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 9 May 2023 18:15:11 +0800 Subject: [PATCH 077/708] toggleterm --- lua/kide/config.lua | 4 ++-- lua/kide/core/basic.lua | 12 ++++++++++++ lua/kide/core/keybindings.lua | 4 ++++ lua/kide/plugins/lazy-nvim.lua | 3 ++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lua/kide/config.lua b/lua/kide/config.lua index ecf905e2..2a8fb60e 100644 --- a/lua/kide/config.lua +++ b/lua/kide/config.lua @@ -1,10 +1,10 @@ local M = { env = { - py_bin = os.getenv("py_bin") or "/usr/bin/python3", + py_bin = os.getenv("PY_BIN") or "/usr/bin/python3", }, plugin = { copilot = { - enable = os.getenv("copilot_enable") or false, + enable = os.getenv("COPILOT_ENABLE") or false, }, }, } diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 562f83c1..6b076ac5 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -191,3 +191,15 @@ autocmd("FileType", { vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) end, }) + +-- toggle_term +autocmd("FileType", { + group = augroup("toggle_term"), + pattern = { + "toggleterm", + }, + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set("n", "tt", ":ToggleTerm", { buffer = event.buf, silent = true }) + end, +}) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index f52e7705..f922e4be 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -44,6 +44,10 @@ M.setup = function() -- ToggleTerm map("n", "", ":ToggleTerm", opt) + map("t", "", ":ToggleTerm", opt) + map("n", "tt", ":ToggleTerm", opt) + map("v", "tt", ":ToggleTermSendVisualSelection", opt) + map("t", "tt", ":ToggleTerm", opt) -- symbols-outline.nvim map("n", "o", ":SymbolsOutline", opt) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index a4ecd6b4..743019ff 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -181,7 +181,7 @@ require("lazy").setup({ desc = "jdtls", callback = function(e) if e.file == "java" and vim.bo[e.buf].buftype == "nofile" then - -- ignore + -- ignore else require("kide.lsp.java").start() end @@ -331,6 +331,7 @@ require("lazy").setup({ { "akinsho/toggleterm.nvim", lazy = true, + version = "*", cmd = { "ToggleTerm" }, config = function() require("toggleterm").setup({ From 0d94a9e1bd76325a71c5aeeaf6bb7bea5ccfeba3 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 18:06:42 +0800 Subject: [PATCH 078/708] =?UTF-8?q?=E4=B8=8D=E4=B9=A0=E6=83=AFjk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/keybindings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index f922e4be..ac4e6daa 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -40,7 +40,7 @@ M.setup = function() -- " 退出 terminal 模式 map("t", "", "", opt) - map("t", "jk", "", opt) + -- map("t", "jk", "", opt) -- ToggleTerm map("n", "", ":ToggleTerm", opt) From e417dea45dde85caff7ab2e7d9965637b6f50702 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 21:01:13 +0800 Subject: [PATCH 079/708] lspkind_symbol_map --- lua/kide/lsp/lsp_ui.lua | 66 ++++++++++++++-------------- lua/kide/plugins/config/nvim-cmp.lua | 6 --- lua/kide/plugins/lazy-nvim.lua | 10 +++++ 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 6d09b2bf..66e55022 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -1,42 +1,44 @@ local M = {} +local lspkind_symbol_map = require("lspkind").symbol_map + -- remove obsolete TS* highlight groups https://github.com/nvim-treesitter/nvim-treesitter/pull/3656 M.symbol_map = { - Text = { icon = "" }, - Method = { icon = "", hl = "@method" }, - Function = { icon = "", hl = "@function" }, - Constructor = { icon = "", hl = "@constructor" }, - Field = { icon = "ﰠ", hl = "@field" }, - Variable = { icon = "", hl = "@constant" }, - Class = { icon = "ﴯ", hl = "@type" }, - Interface = { icon = "", hl = "@type" }, - Module = { icon = "", hl = "@namespace" }, - Property = { icon = "ﰠ", hl = "@method" }, - Unit = { icon = "塞" }, - Value = { icon = "" }, - Enum = { icon = "", hl = "TSType" }, - Keyword = { icon = "" }, - Snippet = { icon = "" }, - Color = { icon = "" }, - File = { icon = "", hl = "@text.uri" }, - Reference = { icon = "" }, - Folder = { icon = "" }, - EnumMember = { icon = "", hl = "@field" }, - Constant = { icon = "", hl = "@constant" }, - Struct = { icon = "פּ", hl = "@type" }, - Event = { icon = "", hl = "@type" }, - Operator = { icon = "", hl = "@operator" }, + Text = { icon = lspkind_symbol_map.Text }, + Method = { icon = lspkind_symbol_map.Method, hl = "@method" }, + Function = { icon = lspkind_symbol_map.Function, hl = "@function" }, + Constructor = { icon = lspkind_symbol_map.Constructor, hl = "@constructor" }, + Field = { icon = lspkind_symbol_map.Field, hl = "@field" }, + Variable = { icon = lspkind_symbol_map.Variable, hl = "@constant" }, + Class = { icon = lspkind_symbol_map.Class, hl = "@type" }, + Interface = { icon = lspkind_symbol_map.Interface, hl = "@type" }, + Module = { icon = lspkind_symbol_map.Module, hl = "@namespace" }, + Property = { icon = lspkind_symbol_map.Property, hl = "@method" }, + Unit = { icon = lspkind_symbol_map.Unit }, + Value = { icon = lspkind_symbol_map.Value }, + Enum = { icon = lspkind_symbol_map.Enum, hl = "TSType" }, + Keyword = { icon = lspkind_symbol_map.Keyword }, + Snippet = { icon = lspkind_symbol_map.Snippet }, + Color = { icon = lspkind_symbol_map.Color }, + File = { icon = lspkind_symbol_map.File, hl = "@text.uri" }, + Reference = { icon = lspkind_symbol_map.Reference }, + Folder = { icon = lspkind_symbol_map.Folder }, + EnumMember = { icon = lspkind_symbol_map.EnumMember, hl = "@field" }, + Constant = { icon = lspkind_symbol_map.Constant, hl = "@constant" }, + Struct = { icon = lspkind_symbol_map.Struct, hl = "@type" }, + Event = { icon = lspkind_symbol_map.Event, hl = "@type" }, + Operator = { icon = lspkind_symbol_map.Operator, hl = "@operator" }, TypeParameter = { icon = "", hl = "@parameter" }, --------------------------------------------------------- Namespace = { icon = "", hl = "@namespace" }, Package = { icon = "", hl = "@namespace" }, - String = { icon = "", hl = "@string" }, + String = { icon = "", hl = "@string" }, Number = { icon = "", hl = "@number" }, - Boolean = { icon = "", hl = "@boolean" }, + Boolean = { icon = "", hl = "@boolean" }, Array = { icon = "", hl = "@constant" }, Object = { icon = "", hl = "@type" }, - Key = { icon = "", hl = "@type" }, - Null = { icon = "ﳠ", hl = "@type" }, + Key = { icon = "󰌋", hl = "@type" }, + Null = { icon = "󰟢", hl = "@type" }, Component = { icon = "", hl = "@function" }, Fragment = { icon = "", hl = "@constant" }, } @@ -62,10 +64,10 @@ M.signs = { M.diagnostics = { icons = { - hint = "", - info = "", - warning = "", - error = "", + hint = "󰌶", + info = "", + warning = "", + error = "", }, } return M diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 57a24f84..1f714a5e 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -1,11 +1,5 @@ local lspkind = require("lspkind") local cmp = require("cmp") -lspkind.init({ - symbol_map = { - Copilot = "", - }, -}) -vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" }) cmp.setup({ -- 指定 snippet 引擎 snippet = { diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 743019ff..53038992 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -58,6 +58,16 @@ require("lazy").setup({ { "onsails/lspkind-nvim", lazy = true, + event = { "VeryLazy" }, + config = function() + require("lspkind").init({ + -- preset = "codicons", + symbol_map = { + Copilot = "", + }, + }) + vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" }) + end, }, -- nvim-cmp { From 5b1a9ca29984ba781e181b3e5c0c6161bf49201b Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 21:21:12 +0800 Subject: [PATCH 080/708] gitsigns-nvim --- lua/kide/plugins/config/gitsigns-nvim.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/kide/plugins/config/gitsigns-nvim.lua b/lua/kide/plugins/config/gitsigns-nvim.lua index 78687bc5..b2d37183 100644 --- a/lua/kide/plugins/config/gitsigns-nvim.lua +++ b/lua/kide/plugins/config/gitsigns-nvim.lua @@ -1,10 +1,10 @@ require("gitsigns").setup({ signs = { - add = { hl = "DiffAdd", text = "│", numhl = "GitSignsAddNr" }, + add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" }, change = { hl = "DiffChange", text = "│", numhl = "GitSignsChangeNr" }, - delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" }, + delete = { hl = "DiffDelete", text = "", numhl = "GitSignsDeleteNr" }, topdelete = { hl = "DiffDelete", text = "‾", numhl = "GitSignsDeleteNr" }, - changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" }, + changedelete = { hl = "GitSignsChangedelete", text = "", numhl = "GitSignsChangedeleteNr" }, untracked = { hl = "GitSignsAdd", text = "│", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, }, signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` From da0b45a6150ee4fa2bd1d7f8e77f89c63d1f0411 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 21:23:17 +0800 Subject: [PATCH 081/708] fmt --- lua/kide/lsp/lsp_ui.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 66e55022..4f75a5b6 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -1,7 +1,6 @@ local M = {} local lspkind_symbol_map = require("lspkind").symbol_map - -- remove obsolete TS* highlight groups https://github.com/nvim-treesitter/nvim-treesitter/pull/3656 M.symbol_map = { Text = { icon = lspkind_symbol_map.Text }, From 14016941e89f734c25e93c4bebc22674954e6095 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 21:35:44 +0800 Subject: [PATCH 082/708] diagnostics icon --- lua/kide/lsp/lsp_ui.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 4f75a5b6..434fd88f 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -63,10 +63,10 @@ M.signs = { M.diagnostics = { icons = { - hint = "󰌶", - info = "", - warning = "", - error = "", + hint = "", + info = "", + warning = "", + error = "", }, } return M From 2c98d764fde8018dd4583b855d5c174ac842dcd8 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 21:42:40 +0800 Subject: [PATCH 083/708] alpha icon --- lua/kide/plugins/config/alpha-nvim.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/kide/plugins/config/alpha-nvim.lua b/lua/kide/plugins/config/alpha-nvim.lua index bb8293a5..a86b67ff 100644 --- a/lua/kide/plugins/config/alpha-nvim.lua +++ b/lua/kide/plugins/config/alpha-nvim.lua @@ -15,17 +15,17 @@ dashboard.section.header.val = { local opt = { noremap = true, silent = true } -- Set menu dashboard.section.buttons.val = { - dashboard.button(" ff", " Find File", ":Telescope find_files", opt), + dashboard.button(" ff", "󰈞 Find File", ":Telescope find_files", opt), dashboard.button(" fg", "󰈭 Find Word ", ":Telescope live_grep", opt), dashboard.button( " fp", - " Recent Projects", + " Recent Projects", ":lua require'telescope'.extensions.project.project{ display_type = 'full' }", opt ), dashboard.button(" fo", " Recent File", ":Telescope oldfiles", opt), dashboard.button(" ns", " Settings", ":e $MYVIMRC | :cd %:p:h ", opt), - dashboard.button(" q ", "󰅚 Quit NVIM", ":qa", opt), + dashboard.button(" q ", "󰅙 Quit NVIM", ":qa", opt), } -- Send config to alpha From 57f70af6a6de7afa47137e025accfe9dfb11cff9 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 22:11:19 +0800 Subject: [PATCH 084/708] colorscheme --- lua/kide/plugins/lazy-nvim.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 53038992..41e15c8b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -117,13 +117,27 @@ require("lazy").setup({ -- use 'morhetz/gruvbox' { "ellisonleao/gruvbox.nvim", + enabled = true, lazy = false, priority = 1000, config = function() require("kide.plugins.config.gruvbox") end, }, - -- use 'sainnhe/gruvbox-material' + { + "sainnhe/gruvbox-material", + enabled = false, + lazy = false, + priority = 1000, + config = function() + -- require("kide.plugins.config.gruvbox") + + vim.opt.background = "dark" + vim.g.gruvbox_material_background = "hard" + vim.g.gruvbox_material_better_performance = true + vim.cmd([[colorscheme gruvbox-material]]) + end, + }, -- 文件管理 { @@ -140,7 +154,6 @@ require("lazy").setup({ { "akinsho/bufferline.nvim", version = "*", - dependencies = { "ellisonleao/gruvbox.nvim" }, requires = "kyazdani42/nvim-web-devicons", config = function() require("kide.plugins.config.bufferline") @@ -151,7 +164,6 @@ require("lazy").setup({ { "nvim-treesitter/nvim-treesitter", event = { "BufNewFile", "BufReadPost" }, - dependencies = { "ellisonleao/gruvbox.nvim" }, build = ":TSUpdate", config = function() require("kide.plugins.config.nvim-treesitter") @@ -261,7 +273,6 @@ require("lazy").setup({ { "nvim-telescope/telescope.nvim", lazy = true, - dependencies = { "ellisonleao/gruvbox.nvim" }, event = { "VeryLazy" }, cmd = { "Telescope" }, keys = { "" }, @@ -379,7 +390,6 @@ require("lazy").setup({ -- 状态栏插件 { "nvim-lualine/lualine.nvim", - dependencies = { "ellisonleao/gruvbox.nvim" }, config = function() require("kide.plugins.config.lualine") end, From 2aa948b4e13df5ea7762559c195491a889a3b857 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 22:11:49 +0800 Subject: [PATCH 085/708] bufferline --- lua/kide/plugins/config/bufferline.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/plugins/config/bufferline.lua b/lua/kide/plugins/config/bufferline.lua index 937c8895..ef1c4fc6 100644 --- a/lua/kide/plugins/config/bufferline.lua +++ b/lua/kide/plugins/config/bufferline.lua @@ -5,7 +5,7 @@ require("bufferline").setup({ diagnostics_indicator = function(count, level, diagnostics_dict, context) local s = " " for e, n in pairs(diagnostics_dict) do - local sym = e == "error" and " " or (e == "warning" and " " or "") + local sym = e == "error" and " " or (e == "warning" and " " or " ") s = s .. n .. sym end return s @@ -78,6 +78,6 @@ require("bufferline").setup({ show_close_icon = false, show_tab_indicators = true, -- separator_style = "slant" | "thick" | "thin" | { 'any', 'any' }, - separator_style = "slant", + -- separator_style = "slant", }, }) From 0ad78c5d7eccc03960085ba550046cee0a2a8a33 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 10 May 2023 22:55:47 +0800 Subject: [PATCH 086/708] =?UTF-8?q?=E5=A4=9A=E7=89=88=E6=9C=AC=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/vscode/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/vscode/init.lua b/lua/kide/core/vscode/init.lua index 1000037f..070f74cd 100644 --- a/lua/kide/core/vscode/init.lua +++ b/lua/kide/core/vscode/init.lua @@ -10,7 +10,8 @@ M.find_one = function(extension_path) local v = vim.fn.glob(M.get_vscode_extensions() .. extension_path) if v and v ~= "" then if type(v) == "string" then - return vim.split(v, "\n")[1] + local pt = vim.split(v, "\n") + return pt[#pt] elseif type(v) == "table" then return v[1] end From 097a25c1a3ee029212cab8ed4181cd1719248e8c Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 11 May 2023 09:21:57 +0800 Subject: [PATCH 087/708] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20jdtls=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/java.lua | 60 ++++++------------------------------------- 1 file changed, 8 insertions(+), 52 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 4d63c0ab..45289fd7 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -1,5 +1,4 @@ local M = {} -local cutils = require("kide.core.utils") local env = { HOME = vim.loop.os_homedir(), JAVA_HOME = os.getenv("JAVA_HOME"), @@ -24,13 +23,6 @@ end local function get_java_ver_sources(v, dv) return os.getenv("JAVA_" .. v .. "_SOURCES") or dv end -local function get_java_ver_doc(v, dv) - return os.getenv("JAVA_" .. v .. "_DOC") or dv -end - -local function get_java() - return or_default(env.JDTLS_RUN_JAVA, get_java_home() .. "/bin/java") -end local function get_jdtls_workspace() return or_default(env.JDTLS_WORKSPACE, env.HOME .. "/jdtls-workspace/") @@ -45,16 +37,6 @@ local function get_jol_jar() return env.JOL_JAR or "/opt/software/java/jol-cli-0.16-full.jar" end -local _config = (function() - if cutils.is_win then - return "config_win" - elseif cutils.is_mac then - return "config_mac" - else - return "config_linux" - end -end)() - -- see https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request local ExecutionEnvironment = { J2SE_1_5 = "J2SE-1.5", @@ -121,9 +103,8 @@ local function get_jdtls_path() end local jdtls_path = get_jdtls_path() -local jdtls_launcher = vim.fn.glob(jdtls_path .. "/plugins/org.eclipse.equinox.launcher_*.jar") +local jdtls_launcher = vim.fn.glob(jdtls_path .. "/bin/jdtls") -local jdtls_config = vim.fn.glob(jdtls_path .. "/" .. _config) local bundles = {} -- This bundles definition is the same as in the previous section (java-debug installation) @@ -173,39 +154,14 @@ local config = { -- The command that starts the language server -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line cmd = { - get_java(), -- or '/path/to/java11_or_newer/bin/java' - "-Declipse.application=org.eclipse.jdt.ls.core.id1", - "-Dosgi.bundles.defaultStartLevel=4", - "-Declipse.product=org.eclipse.jdt.ls.core.product", - -- "-Dosgi.configuration.cascaded=true", - -- "-Dosgi.sharedConfiguration.area=" .. get_jdtls_home() .. "/config_mac", - -- "-Dosgi.sharedConfiguration.area.readOnly=true", - "-Dlog.protocol=true", - "-Dlog.level=ALL", - "-Dsun.zip.disableMemoryMapping=true", - -- "-Djava.util.concurrent.ForkJoinPool.common.parallelism=16", - -- "-noverify", - -- '-XX:+UseParallelGC', - -- '-XX:GCTimeRatio=4', - -- '-XX:AdaptiveSizePolicyWeight=90', - -- '-XX:+UseG1GC', - -- '-XX:+UseStringDeduplication', - -- '-Xms512m', - "-XX:+UseZGC", - "-Xmx1g", - -- "-Xbootclasspath/a:" .. get_lombok_jar(), - "-javaagent:" .. get_lombok_jar(), - "--add-modules=ALL-SYSTEM", - "--add-opens", - "java.base/java.util=ALL-UNNAMED", - "--add-opens", - "java.base/java.lang=ALL-UNNAMED", - "-jar", jdtls_launcher, - "-configuration", - jdtls_config, - "-data", - workspace_dir, + "--jvm-arg=-Dlog.protocol=true", + "--jvm-arg=-Dlog.level=ALL", + "--jvm-arg=-Dsun.zip.disableMemoryMapping=true", + "--jvm-arg=" .. "-javaagent:" .. get_lombok_jar(), + "--jvm-arg=" .. "-XX:+UseZGC", + "--jvm-arg=" .. "-Xmx1g", + "-data=" .. workspace_dir, }, filetypes = { "java" }, From c9a51ba0ea38d20114d02f7a109ad294e1e30f7f Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 12 May 2023 21:08:22 +0800 Subject: [PATCH 088/708] git q close --- lua/kide/core/basic.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 6b076ac5..72ad3f44 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -185,6 +185,9 @@ autocmd("FileType", { "startuptime", "tsplayground", "checkhealth", + "fugitive", + "gitcommit", + "git", }, callback = function(event) vim.bo[event.buf].buflisted = false @@ -192,6 +195,15 @@ autocmd("FileType", { end, }) +autocmd({ "BufReadCmd" }, { + group = augroup("git_close_with_q"), + pattern = "fugitive://*", + callback = function(event) + vim.bo[event.buf].buflisted = false + vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) + end, +}) + -- toggle_term autocmd("FileType", { group = augroup("toggle_term"), From c21385490d0833aff83e7cfe6e9df6cd6691861e Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 14 May 2023 12:04:12 +0800 Subject: [PATCH 089/708] font --- lua/kide/plugins/config/pandoc.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/kide/plugins/config/pandoc.lua b/lua/kide/plugins/config/pandoc.lua index d613b2ff..2d5b1256 100644 --- a/lua/kide/plugins/config/pandoc.lua +++ b/lua/kide/plugins/config/pandoc.lua @@ -31,6 +31,8 @@ local function markdown_to_pdf() { "--toc" }, { "--variable", "CJKmainfont=" .. cjk_mainfont() }, { "--variable", "mainfont=Hack" }, + { "--variable", "sansfont=Hack" }, + { "--variable", "monofont=Hack" }, { "--variable", "geometry:top=2cm, bottom=1.5cm, left=2cm, right=2cm" }, }) end, { From 84e303f290f8d45feb8edf58a668578de11269b0 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 14 May 2023 12:11:27 +0800 Subject: [PATCH 090/708] pandoc --- lua/kide/core/init.lua | 1 + lua/kide/core/utils/pandoc.lua | 44 ++++++++++++++++++++++++++++++ lua/kide/lsp/java.lua | 1 - lua/kide/plugins/config/pandoc.lua | 39 -------------------------- 4 files changed, 45 insertions(+), 40 deletions(-) create mode 100644 lua/kide/core/utils/pandoc.lua diff --git a/lua/kide/core/init.lua b/lua/kide/core/init.lua index 45806a9c..ff1ebaad 100644 --- a/lua/kide/core/init.lua +++ b/lua/kide/core/init.lua @@ -4,4 +4,5 @@ vim.schedule(function() require("kide.core.utils.plantuml").setup() require("kide.core.utils.maven").setup() require("kide.core.utils.jdtls").setup() + require("kide.core.utils.pandoc").setup() end) diff --git a/lua/kide/core/utils/pandoc.lua b/lua/kide/core/utils/pandoc.lua new file mode 100644 index 00000000..e8ccaee8 --- /dev/null +++ b/lua/kide/core/utils/pandoc.lua @@ -0,0 +1,44 @@ +local utils = require("kide.core.utils") +local M = {} +local cjk_mainfont = function() + if utils.is_win then + return "Microsoft YaHei UI" + elseif utils.is_linux then + return "Noto Sans CJK SC" + else + return "Yuanti SC" + end +end + +-- pandoc --pdf-engine=xelatex --highlight-style tango -N --toc -V CJKmainfont="Yuanti SC" -V mainfont="Hack" -V geometry:"top=2cm, bottom=1.5cm, left=2cm, right=2cm" test.md -o out.pdf +M.markdown_to_pdf = function() + local group = vim.api.nvim_create_augroup("kide_utils_pandoc", { clear = true }) + vim.api.nvim_create_autocmd({ "FileType" }, { + group = group, + pattern = { "markdown" }, + desc = "Markdown to PDF", + callback = function(o) + vim.api.nvim_buf_create_user_command(o.buf, "PandocMdToPdf", function(_) + require("pandoc.render").file({ + { "--pdf-engine", "xelatex" }, + { "--highlight-style", "tango" }, + { "--number-sections" }, + { "--toc" }, + { "--variable", "CJKmainfont=" .. cjk_mainfont() }, + { "--variable", "mainfont=Hack" }, + { "--variable", "sansfont=Hack" }, + { "--variable", "monofont=Hack" }, + { "--variable", "geometry:top=2cm, bottom=1.5cm, left=2cm, right=2cm" }, + }) + end, { + nargs = "*", + complete = require("pandoc.utils").complete, + }) + end, + }) +end + +M.setup = function() + M.markdown_to_pdf() +end +return M diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 45289fd7..fbdf7acd 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -105,7 +105,6 @@ local jdtls_path = get_jdtls_path() local jdtls_launcher = vim.fn.glob(jdtls_path .. "/bin/jdtls") - local bundles = {} -- This bundles definition is the same as in the previous section (java-debug installation) local vscode_java_debug_path = vscode.find_one("/vscjava.vscode-java-debug-*/server") diff --git a/lua/kide/plugins/config/pandoc.lua b/lua/kide/plugins/config/pandoc.lua index 2d5b1256..e22bbfca 100644 --- a/lua/kide/plugins/config/pandoc.lua +++ b/lua/kide/plugins/config/pandoc.lua @@ -5,45 +5,6 @@ require("pandoc").setup({ }, }) -local cjk_mainfont = function() - if utils.is_win then - return "Microsoft YaHei UI" - elseif utils.is_linux then - return "Noto Sans CJK SC" - else - return "Yuanti SC" - end -end - --- pandoc --pdf-engine=xelatex --highlight-style tango -N --toc -V CJKmainfont="Yuanti SC" -V mainfont="Hack" -V geometry:"top=2cm, bottom=1.5cm, left=2cm, right=2cm" test.md -o out.pdf -local function markdown_to_pdf() - local group = vim.api.nvim_create_augroup("kide_utils_pandoc", { clear = true }) - vim.api.nvim_create_autocmd({ "FileType" }, { - group = group, - pattern = { "markdown" }, - desc = "Markdown to PDF", - callback = function(o) - vim.api.nvim_buf_create_user_command(o.buf, "PandocMdToPdf", function(_) - require("pandoc.render").file({ - { "--pdf-engine", "xelatex" }, - { "--highlight-style", "tango" }, - { "--number-sections" }, - { "--toc" }, - { "--variable", "CJKmainfont=" .. cjk_mainfont() }, - { "--variable", "mainfont=Hack" }, - { "--variable", "sansfont=Hack" }, - { "--variable", "monofont=Hack" }, - { "--variable", "geometry:top=2cm, bottom=1.5cm, left=2cm, right=2cm" }, - }) - end, { - nargs = "*", - complete = require("pandoc.utils").complete, - }) - end, - }) -end -markdown_to_pdf() - local uv = vim.loop require("pandoc.process").spawn = function(bin, args, callback) local stdout = uv.new_pipe(false) From 40b2b8a15f8874bb80f4b5fd60428d0d50afff34 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 14 May 2023 19:31:31 +0800 Subject: [PATCH 091/708] telescope --- lua/kide/plugins/config/telescope.lua | 34 +++++++------------ lua/kide/theme/gruvbox.lua | 48 --------------------------- 2 files changed, 12 insertions(+), 70 deletions(-) diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index 0285c399..99bd5aea 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -27,16 +27,16 @@ end telescope.setup({ defaults = { - -- vimgrep_arguments = { - -- "rg", - -- "--color=never", - -- "--no-heading", - -- "--with-filename", - -- "--line-number", - -- "--column", - -- "--smart-case", - -- }, - -- prompt_prefix = "  ", + vimgrep_arguments = { + "rg", + "-L", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, prompt_prefix = "  ", selection_caret = " ", entry_prefix = " ", @@ -59,20 +59,10 @@ telescope.setup({ }, winblend = 0, -- border = {}, - -- borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, - -- borderchars = { - -- prompt = { '▀', '▐', '▄', '▌', '▛', '▜', '▟', '▙' }; - -- results = { '▀', '▐', '▄', '▌', '▛', '▜', '▟', '▙' }; - -- preview = { '▀', '▐', '▄', '▌', '▛', '▜', '▟', '▙' }; - -- }, - -- borderchars = { - -- prompt = { '▀', '▐', '▄', '▌', '▛', '▜', '▟', '▙' }; - -- results = { ' ', '▐', '▄', '▌', '▌', '▐', '▟', '▙' }; - -- preview = { '▀', '▐', '▄', '▌', '▛', '▜', '▟', '▙' }; - -- }, + borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" }, color_devicons = true, -- use_less = true, - -- set_env = { ["COLORTERM"] = "gruvbox" }, -- default = nil, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, -- file_sorter = require("telescope.sorters").get_fuzzy_file, file_ignore_patterns = { "node_modules" }, -- generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index 6cf7f7e2..e0e3ef92 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -68,51 +68,6 @@ local flat_telescope = { TelescopeSelection = { bg = colors.black2, fg = colors.yellow }, } -local flat_trans = { - TransWord = { - fg = colors.green, - bold = true, - }, - TransPhonetic = { - link = "Linenr", - }, - TransTitle = { - fg = colors.white, - bg = colors.blue2, - bold = true, - }, - TransTitleRound = { - fg = colors.blue2, - }, - TransTag = { - fg = colors.yellow2, - }, - TransExchange = { - link = "TransTag", - }, - TransPos = { - link = "TransTag", - }, - TransTranslation = { - link = "TransWord", - }, - TransDefinition = { - link = "Moremsg", - }, - TransWin = { - link = "Normal", - }, - TransBorder = { - link = "FloatBorder", - }, - TransCollins = { - fg = colors.green, - bold = true, - }, - TransFailed = { - fg = colors.blue, - }, -} M.load_telescope_highlights = function() M.load_highlights(flat_telescope) @@ -123,7 +78,4 @@ M.load_highlights = function(hl_groups) end end -M.load_trans_highlights = function() - M.load_highlights(flat_trans) -end return M From 2f1ed518406a74900d82a28fe2c10f46888211df Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 14 May 2023 22:04:20 +0800 Subject: [PATCH 092/708] icon --- lua/kide/lsp/lsp_ui.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 434fd88f..f40a449b 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -27,19 +27,19 @@ M.symbol_map = { Struct = { icon = lspkind_symbol_map.Struct, hl = "@type" }, Event = { icon = lspkind_symbol_map.Event, hl = "@type" }, Operator = { icon = lspkind_symbol_map.Operator, hl = "@operator" }, - TypeParameter = { icon = "", hl = "@parameter" }, + TypeParameter = { icon = "󰗴", hl = "@parameter" }, --------------------------------------------------------- - Namespace = { icon = "", hl = "@namespace" }, + Namespace = { icon = "", hl = "@namespace" }, Package = { icon = "", hl = "@namespace" }, String = { icon = "", hl = "@string" }, Number = { icon = "", hl = "@number" }, Boolean = { icon = "", hl = "@boolean" }, - Array = { icon = "", hl = "@constant" }, - Object = { icon = "", hl = "@type" }, + Array = { icon = "", hl = "@constant" }, + Object = { icon = "", hl = "@type" }, Key = { icon = "󰌋", hl = "@type" }, Null = { icon = "󰟢", hl = "@type" }, - Component = { icon = "", hl = "@function" }, - Fragment = { icon = "", hl = "@constant" }, + Component = { icon = "󰡀", hl = "@function" }, + Fragment = { icon = "", hl = "@constant" }, } M.hover_actions = { From 89d4e6751274ed6eafb8be8fdf5eda6291d76347 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 14 May 2023 22:08:31 +0800 Subject: [PATCH 093/708] Constructor --- lua/kide/lsp/lsp_ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index f40a449b..380233ac 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -27,7 +27,7 @@ M.symbol_map = { Struct = { icon = lspkind_symbol_map.Struct, hl = "@type" }, Event = { icon = lspkind_symbol_map.Event, hl = "@type" }, Operator = { icon = lspkind_symbol_map.Operator, hl = "@operator" }, - TypeParameter = { icon = "󰗴", hl = "@parameter" }, + TypeParameter = { icon = "", hl = "@parameter" }, --------------------------------------------------------- Namespace = { icon = "", hl = "@namespace" }, Package = { icon = "", hl = "@namespace" }, From 1e78648051992b286fbebfc283c62e4d53ee5957 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 14 May 2023 23:20:40 +0800 Subject: [PATCH 094/708] color --- lua/kide/plugins/config/gruvbox.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index 89dfbbd1..ecf2573f 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -16,14 +16,24 @@ local overrides = { require("gruvbox").setup({ undercurl = true, underline = true, - inverse = true, -- invert background for search, diffs, statuslines and errors + bold = true, + italic = { + strings = true, + comments = true, + operators = false, + folds = true, + }, + strikethrough = true, invert_selection = false, invert_signs = false, invert_tabline = false, invert_intend_guides = false, - contrast = "", -- can be "hard" or "soft" + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = "", -- can be "hard", "soft" or empty string + palette_overrides = {}, overrides = overrides, + dim_inactive = false, + transparent_mode = false, }) - vim.opt.background = "dark" vim.cmd([[colorscheme gruvbox]]) From 0746a7ca28c8ac85ce324942256a9a49d4cc76e8 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 15 May 2023 09:22:24 +0800 Subject: [PATCH 095/708] color --- lua/kide/plugins/config/gruvbox.lua | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index ecf2573f..fa2ad52d 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -1,18 +1,3 @@ --- setup must be called before loading the colorscheme --- Default options: - -local kgrubox = require("kide.theme.gruvbox") -local overrides = { - NormalFloat = { - bg = kgrubox.colors.black3, - }, - Pmenu = { - bg = kgrubox.colors.black2, - }, - - -- cmp, wilder -} - require("gruvbox").setup({ undercurl = true, underline = true, @@ -30,8 +15,11 @@ require("gruvbox").setup({ invert_intend_guides = false, inverse = true, -- invert background for search, diffs, statuslines and errors contrast = "", -- can be "hard", "soft" or empty string - palette_overrides = {}, - overrides = overrides, + palette_overrides = { + dark1 = "#313131", + dark2 = "#2e2e2e", + }, + overrides = {}, dim_inactive = false, transparent_mode = false, }) From 2d0034ea0b02b4f927cb336b94cce52635c09ed6 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 15 May 2023 09:48:35 +0800 Subject: [PATCH 096/708] =?UTF-8?q?jdtls=20=E9=85=8D=E7=BD=AE=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/java.lua | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index fbdf7acd..be85abab 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -163,10 +163,6 @@ local config = { "-data=" .. workspace_dir, }, filetypes = { "java" }, - - -- 💀 - -- This is the default if not provided, you can remove it. Or adjust as needed. - -- One dedicated LSP server & client will be started per unique root_dir root_dir = root_dir, -- Here you can configure eclipse.jdt.ls specific settings @@ -176,18 +172,8 @@ local config = { java = { maxConcurrentBuilds = 8, home = get_java_home(), - jdt = { - ls = { - -- 暂时不可用 - lombokSupport = { enabled = true }, - }, - }, project = { encoding = "UTF-8", - resourceFilters = { - "node_modules", - ".git", - }, }, foldingRange = { enabled = true }, selectionRange = { enabled = true }, @@ -222,9 +208,6 @@ local config = { eclipse = { downloadSources = true, }, - server = { - launchMode = "Hybrid", - }, maven = { downloadSources = true, updateSnapshots = true, @@ -264,19 +247,11 @@ local config = { }, configuration = { maven = { - -- userSettings = "/opt/software/apache-maven-3.6.3/conf/settings.xml", - -- globalSettings = "/opt/software/apache-maven-3.6.3/conf/settings.xml", userSettings = maven.get_maven_settings(), globalSettings = maven.get_maven_settings(), }, runtimes = runtimes, }, - -- referencesCodeLens = { - -- enabled = true, - -- }, - -- implementationsCodeLens = { - -- enabled = true, - -- }, }, }, From 98c28daea078fe8e7a0b82f035ae184f4db0fdd3 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 15 May 2023 09:52:42 +0800 Subject: [PATCH 097/708] color --- lua/kide/plugins/config/gruvbox.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index fa2ad52d..279b8164 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -16,8 +16,8 @@ require("gruvbox").setup({ inverse = true, -- invert background for search, diffs, statuslines and errors contrast = "", -- can be "hard", "soft" or empty string palette_overrides = { - dark1 = "#313131", - dark2 = "#2e2e2e", + -- dark1 = "#313131", + -- dark2 = "#2e2e2e", }, overrides = {}, dim_inactive = false, From 32157888d958925f11be2bd539b3fd79c4be1e6a Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 15 May 2023 10:00:32 +0800 Subject: [PATCH 098/708] lsp_ui --- lua/kide/lsp/lsp_ui.lua | 20 ++++++++++---------- lua/kide/plugins/config/gruvbox.lua | 12 ++++++++---- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 380233ac..7787134c 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -44,16 +44,16 @@ M.symbol_map = { M.hover_actions = { width = 120, - border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, - }, + -- border = { + -- { "╭", "FloatBorder" }, + -- { "─", "FloatBorder" }, + -- { "╮", "FloatBorder" }, + -- { "│", "FloatBorder" }, + -- { "╯", "FloatBorder" }, + -- { "─", "FloatBorder" }, + -- { "╰", "FloatBorder" }, + -- { "│", "FloatBorder" }, + -- }, } M.signs = { diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index 279b8164..1fc878b1 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -15,11 +15,15 @@ require("gruvbox").setup({ invert_intend_guides = false, inverse = true, -- invert background for search, diffs, statuslines and errors contrast = "", -- can be "hard", "soft" or empty string - palette_overrides = { - -- dark1 = "#313131", - -- dark2 = "#2e2e2e", + palette_overrides = {}, + overrides = { + NormalFloat = { + bg = "#313131", + }, + Pmenu = { + bg = "#2e2e2e", + }, }, - overrides = {}, dim_inactive = false, transparent_mode = false, }) From 7e3e0227c83e3d128bb169051386db66bebfd634 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 15 May 2023 17:19:27 +0800 Subject: [PATCH 099/708] dbout --- lua/kide/core/basic.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 72ad3f44..83352d49 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -188,6 +188,7 @@ autocmd("FileType", { "fugitive", "gitcommit", "git", + "dbout", }, callback = function(event) vim.bo[event.buf].buflisted = false From 2f60cbfcbd389315820bf65fcc6bc7d3308aa71e Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 15 May 2023 17:22:22 +0800 Subject: [PATCH 100/708] dbui,dbout --- lua/kide/core/basic.lua | 1 + lua/kide/plugins/config/indent-blankline.lua | 2 ++ lua/kide/plugins/config/lualine.lua | 1 + lua/kide/plugins/config/nvim-tree.lua | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 83352d49..f2e9e10a 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -188,6 +188,7 @@ autocmd("FileType", { "fugitive", "gitcommit", "git", + "dbui", "dbout", }, callback = function(event) diff --git a/lua/kide/plugins/config/indent-blankline.lua b/lua/kide/plugins/config/indent-blankline.lua index 676f0f62..10edd347 100644 --- a/lua/kide/plugins/config/indent-blankline.lua +++ b/lua/kide/plugins/config/indent-blankline.lua @@ -28,6 +28,8 @@ require("indent_blankline").setup({ "TelescopePrompt", "TelescopeResults", "", + "dbui", + "dbout", }, buftype_exclude = { "terminal" }, use_treesitter = true, diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index 8380c28d..d47ff60c 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -117,6 +117,7 @@ dbui.sections = { } dbui.filetypes = { "dbui", + "dbout", } table.insert(config.extensions, dbui) diff --git a/lua/kide/plugins/config/nvim-tree.lua b/lua/kide/plugins/config/nvim-tree.lua index b4ab81e6..df72aacc 100644 --- a/lua/kide/plugins/config/nvim-tree.lua +++ b/lua/kide/plugins/config/nvim-tree.lua @@ -21,7 +21,7 @@ require("nvim-tree").setup({ enable = true, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", exclude = { - filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame", "dbui", "dbout" }, buftype = { "nofile", "terminal", "help" }, }, }, From 5471b5db2796a232045c5896617f8122105b8d69 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 15 May 2023 20:01:14 +0800 Subject: [PATCH 101/708] type_definition --- lua/kide/core/keybindings.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index ac4e6daa..031bb753 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -147,6 +147,7 @@ M.maplsp = function(client, buffer) -- go xx -- mapbuf('n', 'gd', 'lua vim.lsp.buf.definition()', opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gD", "lua vim.lsp.buf.declaration()", opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "gt", "lua vim.lsp.buf.type_definition()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "Telescope lsp_definitions", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gh", "lua vim.lsp.buf.hover()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gs", "lua vim.lsp.buf.signature_help()", opt) From b3bde9580aadf41f7ea31e238f06324edd99da4f Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 16 May 2023 09:21:58 +0800 Subject: [PATCH 102/708] vim.env --- lua/kide/config.lua | 4 ++-- lua/kide/core/utils/maven.lua | 4 ++-- lua/kide/core/utils/plantuml.lua | 2 +- lua/kide/core/vscode/init.lua | 2 +- lua/kide/lsp/java.lua | 16 ++++++++-------- lua/kide/lsp/lemminx.lua | 2 +- lua/kide/plugins/config/null-ls.lua | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lua/kide/config.lua b/lua/kide/config.lua index 2a8fb60e..1203525e 100644 --- a/lua/kide/config.lua +++ b/lua/kide/config.lua @@ -1,10 +1,10 @@ local M = { env = { - py_bin = os.getenv("PY_BIN") or "/usr/bin/python3", + py_bin = vim.env["PY_BIN"] or "/usr/bin/python3", }, plugin = { copilot = { - enable = os.getenv("COPILOT_ENABLE") or false, + enable = vim.env["COPILOT_ENABLE"] == "Y" and true or false, }, }, } diff --git a/lua/kide/core/utils/maven.lua b/lua/kide/core/utils/maven.lua index 1df5a0bb..95bb9cef 100644 --- a/lua/kide/core/utils/maven.lua +++ b/lua/kide/core/utils/maven.lua @@ -2,14 +2,14 @@ local utils = require("kide.core.utils") local M = {} local function maven_settings() - local maven_home = os.getenv("MAVEN_HOME") + local maven_home = vim.env["MAVEN_HOME"] if maven_home then return maven_home .. "/conf/settings.xml" end end M.get_maven_settings = function() - return os.getenv("MAVEN_SETTINGS") or maven_settings() + return vim.env["MAVEN_SETTINGS"] or maven_settings() end local function settings_opt(settings) diff --git a/lua/kide/core/utils/plantuml.lua b/lua/kide/core/utils/plantuml.lua index 4fe9dc87..0cec7a82 100644 --- a/lua/kide/core/utils/plantuml.lua +++ b/lua/kide/core/utils/plantuml.lua @@ -5,7 +5,7 @@ local M = {} M.config = {} local function plantuml_jar(default_jar) - return os.getenv("PLANTUML_JAR") or default_jar + return vim.env["PLANTUML_JAR"] or default_jar end M.config.jar_path = plantuml_jar("/opt/software/puml/plantuml.jar") M.config.cmd = "java" diff --git a/lua/kide/core/vscode/init.lua b/lua/kide/core/vscode/init.lua index 070f74cd..6604f08f 100644 --- a/lua/kide/core/vscode/init.lua +++ b/lua/kide/core/vscode/init.lua @@ -1,7 +1,7 @@ local M = {} local env = { HOME = vim.loop.os_homedir(), - VSCODE_EXTENSIONS = os.getenv("VSCODE_EXTENSIONS"), + VSCODE_EXTENSIONS = vim.env["VSCODE_EXTENSIONS"], } M.get_vscode_extensions = function() return env.VSCODE_EXTENSIONS or "~/.vscode/extensions" diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index be85abab..6fc030e9 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -1,12 +1,12 @@ local M = {} local env = { HOME = vim.loop.os_homedir(), - JAVA_HOME = os.getenv("JAVA_HOME"), - JDTLS_RUN_JAVA = os.getenv("JDTLS_RUN_JAVA"), - JDTLS_HOME = os.getenv("JDTLS_HOME"), - JDTLS_WORKSPACE = os.getenv("JDTLS_WORKSPACE"), - LOMBOK_JAR = os.getenv("LOMBOK_JAR"), - JOL_JAR = os.getenv("JOL_JAR"), + JAVA_HOME = vim.env["JAVA_HOME"], + JDTLS_RUN_JAVA = vim.env["JDTLS_RUN_JAVA"], + JDTLS_HOME = vim.env["JDTLS_HOME"], + JDTLS_WORKSPACE = vim.env["JDTLS_WORKSPACE"], + LOMBOK_JAR = vim.env["LOMBOK_JAR"], + JOL_JAR = vim.env["JOL_JAR"], } local maven = require("kide.core.utils.maven") @@ -18,10 +18,10 @@ local function get_java_home() return or_default(env.JAVA_HOME, "/opt/software/java/zulu17.34.19-ca-jdk17.0.3-macosx_aarch64") end local function get_java_ver_home(v, dv) - return os.getenv("JAVA_" .. v .. "_HOME") or dv + return vim.env["JAVA_" .. v .. "_HOME"] or dv end local function get_java_ver_sources(v, dv) - return os.getenv("JAVA_" .. v .. "_SOURCES") or dv + return vim.env["JAVA_" .. v .. "_SOURCES"] or dv end local function get_jdtls_workspace() diff --git a/lua/kide/lsp/lemminx.lua b/lua/kide/lsp/lemminx.lua index 7ccb45d6..97dc18b8 100644 --- a/lua/kide/lsp/lemminx.lua +++ b/lua/kide/lsp/lemminx.lua @@ -1,5 +1,5 @@ local M = {} -local lemminx_home = os.getenv("LEMMINX_HOME") +local lemminx_home = vim.env["LEMMINX_HOME"] if lemminx_home then M.setup = function(opt) local lspconfig = require("lspconfig") diff --git a/lua/kide/plugins/config/null-ls.lua b/lua/kide/plugins/config/null-ls.lua index 6fbc0d79..fb84773d 100644 --- a/lua/kide/plugins/config/null-ls.lua +++ b/lua/kide/plugins/config/null-ls.lua @@ -111,9 +111,9 @@ local on_attach = function(client, bufnr) end end -if "Y" == os.getenv("SEMGREP_ENABLE") then +if "Y" == vim.env["SEMGREP_ENABLE"] then table.insert(sources, null_ls.builtins.diagnostics.semgrep) -elseif "Y" == os.getenv("PMD_ENABLE") then +elseif "Y" == vim.env["PMD_ENABLE"] then table.insert( sources, null_ls.builtins.diagnostics.pmd.with({ From 3ddc408798c48f6a022631126229247fcdca92f5 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 18 May 2023 00:02:10 +0800 Subject: [PATCH 103/708] python3_host_prog --- lua/kide/core/basic.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index f2e9e10a..b0289782 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -1,3 +1,4 @@ +local config = require('kide.config') vim.g.mapleader = " " vim.opt.title = true @@ -121,7 +122,7 @@ vim.opt.wildmenu = true vim.opt.confirm = true -- vim.g.python_host_prog='/opt/homebrew/bin/python3' --- vim.g.python3_host_prog = "/opt/homebrew/bin/python3" +vim.g.python3_host_prog = config.env.py_bin vim.opt.list = true vim.opt.cul = true -- cursor line From 10936c70c1e4734eb0e98d4826f9fde1c40a4582 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 18 May 2023 13:39:16 +0800 Subject: [PATCH 104/708] =?UTF-8?q?=E5=85=BC=E5=AE=B9=20mason?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/java.lua | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 6fc030e9..4e5ee172 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -101,13 +101,29 @@ local workspace_dir = get_jdtls_workspace() .. project_name local function get_jdtls_path() return or_default(env.JDTLS_HOME, vscode.find_one("/redhat.java-*/server")) end -local jdtls_path = get_jdtls_path() -local jdtls_launcher = vim.fn.glob(jdtls_path .. "/bin/jdtls") +local function jdtls_launcher() + local jdtls_path = get_jdtls_path() + if jdtls_path then + return vim.fn.glob(jdtls_path .. "/bin/jdtls") + end + if require("mason-registry").has_package("jdtls") then + return require("mason-registry").get_package("jdtls"):get_install_path() + end +end local bundles = {} -- This bundles definition is the same as in the previous section (java-debug installation) -local vscode_java_debug_path = vscode.find_one("/vscjava.vscode-java-debug-*/server") + +local vscode_java_debug_path = (function() + local p = vscode.find_one("/vscjava.vscode-java-debug-*/server") + if p then + return p + end + if require("mason-registry").has_package("java-debug-adapter") then + return require("mason-registry").get_package("java-debug-adapter"):get_install_path() .. "/extension/server" + end +end)() if vscode_java_debug_path then vim.list_extend( bundles, @@ -117,7 +133,15 @@ end -- /opt/software/lsp/java/vscode-java-test/server -- vim.list_extend(bundles, vim.split(vim.fn.glob("/opt/software/lsp/java/vscode-java-test/server/*.jar"), "\n")); -local vscode_java_test_path = vscode.find_one("/vscjava.vscode-java-test-*/server") +local vscode_java_test_path = (function() + local p = vscode.find_one("/vscjava.vscode-java-test-*/server") + if p then + return p + end + if require("mason-registry").has_package("java-test") then + return require("mason-registry").get_package("java-test"):get_install_path() .. "/extension/server" + end +end)() if vscode_java_test_path then for _, bundle in ipairs(vim.split(vim.fn.glob(vscode_java_test_path .. "/*.jar"), "\n")) do if not vim.endswith(bundle, "com.microsoft.java.test.runner-jar-with-dependencies.jar") then @@ -153,7 +177,7 @@ local config = { -- The command that starts the language server -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line cmd = { - jdtls_launcher, + jdtls_launcher(), "--jvm-arg=-Dlog.protocol=true", "--jvm-arg=-Dlog.level=ALL", "--jvm-arg=-Dsun.zip.disableMemoryMapping=true", From f9dd4cc43fda4ecd8ab89282059f67913848d3a7 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 18 May 2023 14:49:47 +0800 Subject: [PATCH 105/708] jdtls bin --- lua/kide/lsp/java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 4e5ee172..990caa04 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -108,7 +108,7 @@ local function jdtls_launcher() return vim.fn.glob(jdtls_path .. "/bin/jdtls") end if require("mason-registry").has_package("jdtls") then - return require("mason-registry").get_package("jdtls"):get_install_path() + return require("mason-registry").get_package("jdtls"):get_install_path() .. "/bin/jdtls" end end From 5ae43f3cd49ff93b7f363089869efee21dca0c91 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 18 May 2023 15:00:04 +0800 Subject: [PATCH 106/708] lspconfig ignore jdtls --- lua/kide/lsp/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 3025619d..25430bed 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -65,6 +65,8 @@ require("mason-lspconfig").setup_handlers({ -- Initialize the LSP via rust-tools instead cfg.server = scfg require("rust-tools").setup(cfg) + elseif server_name == "jdtls" then + -- ignore else lspconfig[server_name].setup(scfg) end From 3e6874c2c2038649a5c645a577c4aefa6752fa25 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 18 May 2023 17:08:34 +0800 Subject: [PATCH 107/708] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 04742331..82ac8a78 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,17 @@ cd $env:LOCALAPPDATA git clone https://github.com/JavaHello/nvim.git ``` +## 依赖 + +- [ripgrep](https://github.com/BurntSushi/ripgrep) +- [fd](https://github.com/sharkdp/fd) +- [JDK](https://openjdk.org/) 8/17+ +- [maven](https://maven.apache.org/) +- [nodejs](https://nodejs.org/en) +- [yarn](https://yarnpkg.com/) + +其他依赖可选安装,使用 [mason.nvim](https://github.com/williamboman/mason.nvim) + > 此配置在 Linux, Mac, Windows (推荐使用 [scoop](https://scoop.sh/) 安装依赖) 系统上长期使用 ## 快捷键 From ca952984b227613505e2983f7fb7f85f44f8e999 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 19 May 2023 10:12:55 +0800 Subject: [PATCH 108/708] =?UTF-8?q?lombok=20=E5=8F=AF=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/java.lua | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 990caa04..91218f95 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -29,9 +29,6 @@ local function get_jdtls_workspace() end local vscode = require("kide.core.vscode") -local function get_lombok_jar() - return or_default(env.LOMBOK_JAR, "/opt/software/lsp/lombok.jar") -end local function get_jol_jar() return env.JOL_JAR or "/opt/software/java/jol-cli-0.16-full.jar" @@ -105,11 +102,27 @@ end local function jdtls_launcher() local jdtls_path = get_jdtls_path() if jdtls_path then - return vim.fn.glob(jdtls_path .. "/bin/jdtls") + jdtls_path = vim.fn.glob(jdtls_path .. "/bin/jdtls") + elseif require("mason-registry").has_package("jdtls") then + jdtls_path = require("mason-registry").get_package("jdtls"):get_install_path() .. "/bin/jdtls" + end + if not jdtls_path then + vim.notify("jdtls_path is empty", vim.log.levels.ERROR) + return end - if require("mason-registry").has_package("jdtls") then - return require("mason-registry").get_package("jdtls"):get_install_path() .. "/bin/jdtls" + local cmd = { + jdtls_path, + "--jvm-arg=-Dlog.protocol=true", + "--jvm-arg=-Dlog.level=ALL", + "--jvm-arg=-Dsun.zip.disableMemoryMapping=true", + "--jvm-arg=" .. "-XX:+UseZGC", + "--jvm-arg=" .. "-Xmx1g", + } + if env.LOMBOK_JAR then + table.insert(cmd, "--jvm-arg=-javaagent:" .. env.LOMBOK_JAR) end + table.insert(cmd, "-data=" .. workspace_dir) + return cmd end local bundles = {} @@ -176,16 +189,7 @@ local root_dir = require("jdtls.setup").find_root({ ".git", "mvnw", "gradlew" }) local config = { -- The command that starts the language server -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line - cmd = { - jdtls_launcher(), - "--jvm-arg=-Dlog.protocol=true", - "--jvm-arg=-Dlog.level=ALL", - "--jvm-arg=-Dsun.zip.disableMemoryMapping=true", - "--jvm-arg=" .. "-javaagent:" .. get_lombok_jar(), - "--jvm-arg=" .. "-XX:+UseZGC", - "--jvm-arg=" .. "-Xmx1g", - "-data=" .. workspace_dir, - }, + cmd = jdtls_launcher(), filetypes = { "java" }, root_dir = root_dir, From 77661666b8c94fe5ba0f068f2819a646a757f690 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 20 May 2023 21:26:02 +0800 Subject: [PATCH 109/708] http --- lua/kide/plugins/config/rest-nvim.lua | 10 ---------- lua/kide/plugins/lazy-nvim.lua | 12 ++++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lua/kide/plugins/config/rest-nvim.lua b/lua/kide/plugins/config/rest-nvim.lua index ecbc4ffe..8efe3902 100644 --- a/lua/kide/plugins/config/rest-nvim.lua +++ b/lua/kide/plugins/config/rest-nvim.lua @@ -20,13 +20,3 @@ require("rest-nvim").setup({ custom_dynamic_variables = {}, yank_dry_run = true, }) -local group = vim.api.nvim_create_augroup("kide_jdtls_rest_http", { clear = true }) -vim.api.nvim_create_autocmd({ "FileType" }, { - group = group, - pattern = { "http" }, - callback = function(o) - vim.api.nvim_buf_create_user_command(o.buf, "Http", ":lua require'rest-nvim'.run()", { nargs = 0 }) - vim.api.nvim_buf_create_user_command(o.buf, "HttpCurl", ":lua require'rest-nvim'.run(true)", { nargs = 0 }) - vim.api.nvim_buf_create_user_command(o.buf, "HttpLast", ":lua require'rest-nvim'.last()", { nargs = 0 }) - end, -}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 41e15c8b..8bad50d1 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -573,6 +573,18 @@ require("lazy").setup({ "NTBBloodbath/rest.nvim", lazy = true, ft = "http", + init = function() + local group = vim.api.nvim_create_augroup("kide_jdtls_rest_http", { clear = true }) + vim.api.nvim_create_autocmd({ "FileType" }, { + group = group, + pattern = { "http" }, + callback = function(o) + vim.api.nvim_buf_create_user_command(o.buf, "Http", ":lua require'rest-nvim'.run()", { nargs = 0 }) + vim.api.nvim_buf_create_user_command(o.buf, "HttpCurl", ":lua require'rest-nvim'.run(true)", { nargs = 0 }) + vim.api.nvim_buf_create_user_command(o.buf, "HttpLast", ":lua require'rest-nvim'.last()", { nargs = 0 }) + end, + }) + end, config = function() require("kide.plugins.config.rest-nvim") end, From 0021a59e78ef8418ba6de882bc6e6b03e809c477 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 20 May 2023 22:38:36 +0800 Subject: [PATCH 110/708] gitcommit --- lua/kide/core/basic.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index b0289782..7dfe3f18 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -1,4 +1,4 @@ -local config = require('kide.config') +local config = require("kide.config") vim.g.mapleader = " " vim.opt.title = true @@ -187,7 +187,6 @@ autocmd("FileType", { "tsplayground", "checkhealth", "fugitive", - "gitcommit", "git", "dbui", "dbout", @@ -218,3 +217,9 @@ autocmd("FileType", { vim.keymap.set("n", "tt", ":ToggleTerm", { buffer = event.buf, silent = true }) end, }) + +autocmd("FileType", { + group = augroup("gitcommit"), + pattern = { "gitcommit" }, + command = "setlocal spell", +}) From a0d17c35e4f4dbecc4503c850617ee3257034bfb Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 21 May 2023 09:00:59 +0800 Subject: [PATCH 111/708] =?UTF-8?q?=E6=89=81=E5=B9=B3=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/gruvbox.lua | 25 ++++++++++++++++--------- lua/kide/plugins/config/lualine.lua | 4 ++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index 1fc878b1..ad1fbac0 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -1,3 +1,17 @@ +local transparent_mode = false +local overrides = {} +if transparent_mode then + overrides.Pmenu = { + bg = "none", + } +else + overrides.NormalFloat = { + bg = "#313131", + } + overrides.Pmenu = { + bg = "#2e2e2e", + } +end require("gruvbox").setup({ undercurl = true, underline = true, @@ -16,16 +30,9 @@ require("gruvbox").setup({ inverse = true, -- invert background for search, diffs, statuslines and errors contrast = "", -- can be "hard", "soft" or empty string palette_overrides = {}, - overrides = { - NormalFloat = { - bg = "#313131", - }, - Pmenu = { - bg = "#2e2e2e", - }, - }, + overrides = overrides, dim_inactive = false, - transparent_mode = false, + transparent_mode = transparent_mode, }) vim.opt.background = "dark" vim.cmd([[colorscheme gruvbox]]) diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index d47ff60c..feaab383 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -2,8 +2,8 @@ local config = { options = { icons_enabled = true, theme = "gruvbox", - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, disabled_filetypes = { "alpha", }, From a885f48096edb64dfdd48c9c306357ba2eef0f54 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 21 May 2023 11:29:36 +0800 Subject: [PATCH 112/708] java doc fmt --- lua/kide/lsp/java.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 91218f95..11f2d130 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -372,10 +372,10 @@ local function markdown_format(input) -- input = string.gsub(input, "[\r\n]( +)(%*)", function (i1) -- return i1 .. "-" -- end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s ]*)%]%(file:/[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :]*)%]%(file:/[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s ]*)%]%(jdt://[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :]*)%]%(jdt://[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) end From 7c58207a638529832baceb204294be30ac8fdc3e Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 21 May 2023 12:25:28 +0800 Subject: [PATCH 113/708] =?UTF-8?q?LSP=20=E7=BB=9F=E4=B8=80=E4=B8=A4?= =?UTF-8?q?=E7=A7=8D=E5=90=AF=E5=8A=A8=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/init.lua | 17 +++++++---------- lua/kide/lsp/java.lua | 19 +------------------ lua/kide/lsp/metals.lua | 12 ++++++------ lua/kide/lsp/rust_analyzer.lua | 27 +++++++++++++++++++-------- lua/kide/plugins/lazy-nvim.lua | 34 ---------------------------------- 5 files changed, 33 insertions(+), 76 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 25430bed..dcd5cae8 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -11,7 +11,8 @@ mason_lspconfig.setup({ local server_configs = { -- sumneko_lua -> lua_ls lua_ls = require("kide.lsp.lua_ls"), -- /lua/lsp/lua.lua - -- jdtls = require "lsp.java", -- /lua/lsp/jdtls.lua + jdtls = require("kide.lsp.java"), -- /lua/lsp/jdtls.lua + metals = require("kide.lsp.metals"), -- /lua/lsp/jdtls.lua -- jsonls = require("lsp.jsonls"), clangd = require("kide.lsp.clangd"), tsserver = require("kide.lsp.tsserver"), @@ -42,6 +43,10 @@ require("mason-lspconfig").setup_handlers({ local lspconfig = require("lspconfig") -- tools config local cfg = utils.or_default(server_configs[server_name], {}) + -- 自定义启动方式 + if cfg.setup then + return + end -- lspconfig local scfg = utils.or_default(cfg.server, {}) @@ -61,15 +66,7 @@ require("mason-lspconfig").setup_handlers({ debounce_text_changes = 150, } scfg.capabilities = capabilities - if server_name == "rust_analyzer" then - -- Initialize the LSP via rust-tools instead - cfg.server = scfg - require("rust-tools").setup(cfg) - elseif server_name == "jdtls" then - -- ignore - else - lspconfig[server_name].setup(scfg) - end + lspconfig[server_name].setup(scfg) end, }) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 11f2d130..20023df8 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -479,35 +479,18 @@ M.start = function() end M.setup = function() - vim.g.jdtls_dap_main_class_config_init = true - -- au BufReadCmd jdt://* lua require('jdtls').open_jdt_link(vim.fn.expand('')) - -- command! JdtWipeDataAndRestart lua require('jdtls.setup').wipe_data_and_restart() - -- command! JdtShowLogs lua require('jdtls.setup').show_logs() - vim.api.nvim_create_autocmd({ "BufReadCmd" }, { - pattern = "jdt://*", - callback = function(e) - require("jdtls").open_classfile(e.file) - end, - }) - vim.api.nvim_create_user_command("JdtWipeDataAndRestart", "lua require('jdtls.setup').wipe_data_and_restart()", {}) - vim.api.nvim_create_user_command("JdtShowLogs", "lua require('jdtls.setup').show_logs()", {}) - local group = vim.api.nvim_create_augroup("kide_jdtls_java", { clear = true }) vim.api.nvim_create_autocmd({ "FileType" }, { group = group, pattern = { "java" }, desc = "jdtls", callback = function(e) - -- vim.notify("load: " .. o.buf, vim.log.levels.INFO) - -- print(vim.inspect(e)) - -- 忽略 telescope 预览的情况 if e.file == "java" and vim.bo[e.buf].buftype == "nofile" then -- ignore else - M.start() + require("kide.lsp.java").start() end end, }) - return group end return M diff --git a/lua/kide/lsp/metals.lua b/lua/kide/lsp/metals.lua index be770880..73d42645 100644 --- a/lua/kide/lsp/metals.lua +++ b/lua/kide/lsp/metals.lua @@ -4,11 +4,12 @@ metals_config.settings = { showImplicitArguments = true, } -metals_config.on_attach = function(client, buffer) - require("kide.core.keybindings").maplsp(client, buffer) -end - -M.setup = function() +M.setup = function(opt) + metals_config.on_attach = function(client, buffer) + if opt.on_attach then + opt.on_attach(client, buffer) + end + end local group = vim.api.nvim_create_augroup("kide_metals", { clear = true }) vim.api.nvim_create_autocmd({ "FileType" }, { group = group, @@ -17,7 +18,6 @@ M.setup = function() require("metals").initialize_or_attach(metals_config) end, }) - return group end return M diff --git a/lua/kide/lsp/rust_analyzer.lua b/lua/kide/lsp/rust_analyzer.lua index 5935a275..0b480686 100644 --- a/lua/kide/lsp/rust_analyzer.lua +++ b/lua/kide/lsp/rust_analyzer.lua @@ -1,11 +1,11 @@ +local M = {} local codelldb = require("kide.dap.codelldb") local adapter = function() if codelldb.extension_path then return require("rust-tools.dap").get_codelldb_adapter(codelldb.codelldb_path, codelldb.liblldb_path) end end -local rt = require("rust-tools") -return { +local config = { dap = { adapter = adapter(), }, @@ -16,12 +16,6 @@ return { }, }, server = { - on_attach = function(_, bufnr) - -- Hover actions - vim.keymap.set("n", "ha", rt.hover_actions.hover_actions, { buffer = bufnr }) - -- Code action groups - vim.keymap.set("n", "ca", rt.code_action_group.code_action_group, { buffer = bufnr }) - end, standalone = false, settings = { ["rust-analyzer"] = { @@ -37,3 +31,20 @@ return { }, }, } +M.setup = function(opt) + local rt = require("rust-tools") + local on_attach = opt.on_attach + config.server = vim.tbl_deep_extend("keep", config.server, opt) + config.server.on_attach = function(client, bufnr) + if on_attach then + on_attach(client, bufnr) + end + -- Hover actions + vim.keymap.set("n", "ha", rt.hover_actions.hover_actions, { buffer = bufnr }) + -- Code action groups + vim.keymap.set("n", "ca", rt.code_action_group.code_action_group, { buffer = bufnr }) + end + rt.setup(config) +end + +return M diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 8bad50d1..82f6dee6 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -180,37 +180,6 @@ require("lazy").setup({ "mfussenegger/nvim-jdtls", lazy = true, ft = "java", - init = function() - -- 不加载 nvim-jdtls.vim - vim.g.nvim_jdtls = 1 - vim.api.nvim_create_autocmd({ "BufReadCmd" }, { - pattern = "jdt://*", - callback = function(e) - require("jdtls").open_classfile(e.file) - end, - }) - vim.api.nvim_create_user_command( - "JdtWipeDataAndRestart", - "lua require('jdtls.setup').wipe_data_and_restart()", - {} - ) - vim.api.nvim_create_user_command("JdtShowLogs", "lua require('jdtls.setup').show_logs()", {}) - - local group = vim.api.nvim_create_augroup("kide_jdtls_java", { clear = true }) - vim.api.nvim_create_autocmd({ "FileType" }, { - group = group, - pattern = { "java" }, - desc = "jdtls", - callback = function(e) - if e.file == "java" and vim.bo[e.buf].buftype == "nofile" then - -- ignore - else - require("kide.lsp.java").start() - end - end, - }) - return group - end, }, { "JavaHello/java-deps.nvim", @@ -226,9 +195,6 @@ require("lazy").setup({ lazy = true, ft = "scala", dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - require("kide.lsp.metals").setup() - end, }, -- debug { From a34696dfd45e4eab08926ba97d58f5a19921a59f Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 21 May 2023 12:28:17 +0800 Subject: [PATCH 114/708] M.start --- lua/kide/lsp/java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 20023df8..b293c317 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -488,7 +488,7 @@ M.setup = function() if e.file == "java" and vim.bo[e.buf].buftype == "nofile" then -- ignore else - require("kide.lsp.java").start() + M.start() end end, }) From 9634e10060f8aaa8cac193292756bd11e76de9ab Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 25 May 2023 15:44:03 +0800 Subject: [PATCH 115/708] doc fmt --- lua/kide/lsp/init.lua | 112 +++++++++++++++++++++++++++++++++++++----- lua/kide/lsp/java.lua | 111 +---------------------------------------- 2 files changed, 102 insertions(+), 121 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index dcd5cae8..8d15f605 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -111,14 +111,104 @@ vim.diagnostic.config({ vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lsp_ui.hover_actions) vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp_ui.hover_actions) --- suppress error messages from lang servers --- vim.notify = function(msg, log_level) --- if msg:match "exit code" then --- return --- end --- if log_level == vim.log.levels.ERROR then --- vim.api.nvim_err_writeln(msg) --- else --- vim.api.nvim_echo({ { msg } }, true, {}) --- end --- end +local function markdown_format(input) + if input then + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :-]*)%]%(file:/[^%)]+%)", function(i1) + return "`" .. i1 .. "`" + end) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :-]*)%]%(jdt://[^%)]+%)", function(i1) + return "`" .. i1 .. "`" + end) + end + return input +end + +local function split_lines(value) + value = string.gsub(value, "\r\n?", "\n") + return vim.split(value, "\n", { plain = true }) +end +local function convert_input_to_markdown_lines(input, contents) + contents = contents or {} + -- MarkedString variation 1 + if type(input) == "string" then + input = markdown_format(input) + vim.list_extend(contents, split_lines(input)) + else + assert(type(input) == "table", "Expected a table for Hover.contents") + -- MarkupContent + if input.kind then + -- The kind can be either plaintext or markdown. + -- If it's plaintext, then wrap it in a block + + -- Some servers send input.value as empty, so let's ignore this :( + local value = input.value or "" + + if input.kind == "plaintext" then + -- wrap this in a block so that stylize_markdown + -- can properly process it as plaintext + value = string.format("\n%s\n", value) + end + + -- assert(type(value) == 'string') + vim.list_extend(contents, split_lines(value)) + -- MarkupString variation 2 + elseif input.language then + -- Some servers send input.value as empty, so let's ignore this :( + -- assert(type(input.value) == 'string') + table.insert(contents, "```" .. input.language) + vim.list_extend(contents, split_lines(input.value or "")) + table.insert(contents, "```") + -- By deduction, this must be MarkedString[] + else + -- Use our existing logic to handle MarkedString + for _, marked_string in ipairs(input) do + convert_input_to_markdown_lines(marked_string, contents) + end + end + end + if (contents[1] == "" or contents[1] == nil) and #contents == 1 then + return {} + end + return contents +end + +local function jhover(_, result, ctx, c) + c = c or {} + c.focus_id = ctx.method + c.stylize_markdown = true + if not (result and result.contents) then + vim.notify("No information available") + return + end + local markdown_lines = convert_input_to_markdown_lines(result.contents) + markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines) + if vim.tbl_isempty(markdown_lines) then + vim.notify("No information available") + return + end + local b, w = vim.lsp.util.open_floating_preview(markdown_lines, "markdown", c) + return b, w +end + +vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(jhover, lsp_ui.hover_actions) +local source = require("cmp_nvim_lsp.source") +source.resolve = function(self, completion_item, callback) + -- client is stopped. + if self.client.is_stopped() then + return callback() + end + + -- client has no completion capability. + if not self:_get(self.client.server_capabilities, { "completionProvider", "resolveProvider" }) then + return callback() + end + + self:_request("completionItem/resolve", completion_item, function(_, response) + -- print(vim.inspect(response)) + if response and response.documentation then + response.documentation.value = markdown_format(response.documentation.value) + end + -- print(vim.inspect(response)) + callback(response or completion_item) + end) +end diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index b293c317..fdb33ce3 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -364,116 +364,6 @@ config.handlers["language/status"] = function(_, s) end end -vim.lsp.handlers["$/progress"] = nil -require("fidget").setup({}) - -local function markdown_format(input) - if input then - -- input = string.gsub(input, "[\r\n]( +)(%*)", function (i1) - -- return i1 .. "-" - -- end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :]*)%]%(file:/[^%)]+%)", function(i1) - return "`" .. i1 .. "`" - end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :]*)%]%(jdt://[^%)]+%)", function(i1) - return "`" .. i1 .. "`" - end) - end - return input -end - -local function split_lines(value) - value = string.gsub(value, "\r\n?", "\n") - return vim.split(value, "\n", { plain = true }) -end -function M.convert_input_to_markdown_lines(input, contents) - contents = contents or {} - -- MarkedString variation 1 - if type(input) == "string" then - input = markdown_format(input) - vim.list_extend(contents, split_lines(input)) - else - assert(type(input) == "table", "Expected a table for Hover.contents") - -- MarkupContent - if input.kind then - -- The kind can be either plaintext or markdown. - -- If it's plaintext, then wrap it in a block - - -- Some servers send input.value as empty, so let's ignore this :( - local value = input.value or "" - - if input.kind == "plaintext" then - -- wrap this in a block so that stylize_markdown - -- can properly process it as plaintext - value = string.format("\n%s\n", value) - end - - -- assert(type(value) == 'string') - vim.list_extend(contents, split_lines(value)) - -- MarkupString variation 2 - elseif input.language then - -- Some servers send input.value as empty, so let's ignore this :( - -- assert(type(input.value) == 'string') - table.insert(contents, "```" .. input.language) - vim.list_extend(contents, split_lines(input.value or "")) - table.insert(contents, "```") - -- By deduction, this must be MarkedString[] - else - -- Use our existing logic to handle MarkedString - for _, marked_string in ipairs(input) do - M.convert_input_to_markdown_lines(marked_string, contents) - end - end - end - if (contents[1] == "" or contents[1] == nil) and #contents == 1 then - return {} - end - return contents -end - -local function jhover(_, result, ctx, c) - c = c or {} - c.focus_id = ctx.method - c.stylize_markdown = true - if not (result and result.contents) then - vim.notify("No information available") - return - end - local markdown_lines = M.convert_input_to_markdown_lines(result.contents) - markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines) - if vim.tbl_isempty(markdown_lines) then - vim.notify("No information available") - return - end - local b, w = vim.lsp.util.open_floating_preview(markdown_lines, "markdown", c) - -- vim.api.nvim_win_set_option(w, "winblend", 10) - return b, w -end - -local lsp_ui = require("kide.lsp.lsp_ui") -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(jhover, lsp_ui.hover_actions) -local source = require("cmp_nvim_lsp.source") -source.resolve = function(self, completion_item, callback) - -- client is stopped. - if self.client.is_stopped() then - return callback() - end - - -- client has no completion capability. - if not self:_get(self.client.server_capabilities, { "completionProvider", "resolveProvider" }) then - return callback() - end - - self:_request("completionItem/resolve", completion_item, function(_, response) - -- print(vim.inspect(response)) - if response and response.documentation then - response.documentation.value = markdown_format(response.documentation.value) - end - -- print(vim.inspect(response)) - callback(response or completion_item) - end) -end - M.start = function() jdtls.start_or_attach(config) end @@ -493,4 +383,5 @@ M.setup = function() end, }) end + return M From e39fa141bfadbb4d6cd37f647a1291befae567b7 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 30 May 2023 16:06:35 +0800 Subject: [PATCH 116/708] codelldb --- lua/kide/dap/codelldb.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/kide/dap/codelldb.lua b/lua/kide/dap/codelldb.lua index ad8f25c8..62c6f8c9 100644 --- a/lua/kide/dap/codelldb.lua +++ b/lua/kide/dap/codelldb.lua @@ -2,7 +2,14 @@ local M = {} local vscode = require("kide.core.vscode") local utils = require("kide.core.utils") -- Update this path -M.extension_path = vscode.find_one("/vadimcn.vscode-lldb-*") +M.extension_path = (function() + local epath = vscode.find_one("/vadimcn.vscode-lldb-*") + if epath then + return epath + elseif require("mason-registry").has_package("codelldb") then + return require("mason-registry").get_package("codelldb"):get_install_path() + end +end)() M.codelldb_path = (function() if M.extension_path then if utils.is_win then From 9ff89ca89cb2c98d6e24857c580a9b743d3044ce Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 30 May 2023 16:11:37 +0800 Subject: [PATCH 117/708] extension --- lua/kide/dap/codelldb.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/dap/codelldb.lua b/lua/kide/dap/codelldb.lua index 62c6f8c9..79e40af3 100644 --- a/lua/kide/dap/codelldb.lua +++ b/lua/kide/dap/codelldb.lua @@ -7,7 +7,7 @@ M.extension_path = (function() if epath then return epath elseif require("mason-registry").has_package("codelldb") then - return require("mason-registry").get_package("codelldb"):get_install_path() + return require("mason-registry").get_package("codelldb"):get_install_path() .. "/extension" end end)() M.codelldb_path = (function() From 521916e6415bd2066d5376ae9b2731455c569b6b Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 30 May 2023 21:55:49 +0800 Subject: [PATCH 118/708] clangd utf-16 --- lua/kide/lsp/init.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 8d15f605..41955347 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -65,7 +65,12 @@ require("mason-lspconfig").setup_handlers({ scfg.flags = { debounce_text_changes = 150, } - scfg.capabilities = capabilities + if server_name == "clangd" then + scfg.capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + scfg.capabilities.offsetEncoding = { "utf-16" } + else + scfg.capabilities = capabilities + end lspconfig[server_name].setup(scfg) end, }) From ab6fc22bde5652aa1a5933930a8e953bb73543a7 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 30 May 2023 22:10:55 +0800 Subject: [PATCH 119/708] config lsp, nvim-web-devicons --- lua/kide/lsp/init.lua | 8 ++------ lua/kide/plugins/lazy-nvim.lua | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 41955347..e68cabc2 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -27,8 +27,6 @@ local server_configs = { gdscript = require("kide.lsp.gdscript"), } --- Setup lspconfig. -local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) -- 没有确定使用效果参数 -- capabilities.textDocument.completion.completionItem.snippetSupport = true local utils = require("kide.core.utils") @@ -65,11 +63,9 @@ require("mason-lspconfig").setup_handlers({ scfg.flags = { debounce_text_changes = 150, } + scfg.capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) if server_name == "clangd" then - scfg.capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) scfg.capabilities.offsetEncoding = { "utf-16" } - else - scfg.capabilities = capabilities end lspconfig[server_name].setup(scfg) end, @@ -81,7 +77,7 @@ for _, value in pairs(server_configs) do flags = { debounce_text_changes = 150, }, - capabilities = capabilities, + capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), on_attach = function(client, buffer) -- 绑定快捷键 require("kide.core.keybindings").maplsp(client, buffer) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 82f6dee6..f18f8f1c 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -8,10 +8,7 @@ require("lazy").setup({ }, { - "kyazdani42/nvim-web-devicons", - config = function() - require("nvim-web-devicons").setup({}) - end, + "nvim-tree/nvim-web-devicons", lazy = true, }, { From 97e26f895c2fd9490a66251b93f7e2b038b2169b Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 31 May 2023 09:51:08 +0800 Subject: [PATCH 120/708] telescope jdt --- lua/kide/plugins/config/telescope.lua | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index 99bd5aea..aad67349 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -6,21 +6,8 @@ local telescope = require("telescope") local form_entry = require("telescope.from_entry") local f_path = form_entry.path form_entry.path = function(entry, validate, escape) - escape = vim.F.if_nil(escape, true) - local path - if escape then - path = entry.path and vim.fn.fnameescape(entry.path) or nil - else - path = entry.path - end - if path == nil then - path = entry.filename - end - if path == nil then - path = entry.value - end - if vim.startswith(path, "jdt://") then - return path + if entry.filename and vim.startswith(entry.filename, "jdt://") then + return entry.filename end return f_path(entry, validate, escape) end @@ -82,6 +69,7 @@ telescope.setup({ filetype_hook = function(filepath, bufnr, opts) if vim.startswith(filepath, "jdt://") then require("kide.lsp.utils.jdtls").open_classfile(filepath, bufnr, opts.preview.timeout) + return false; end return true end, From 0d8331c692bf7f2b4770337fd24c768520d48127 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 31 May 2023 09:53:45 +0800 Subject: [PATCH 121/708] vim.lsp.buf.definition --- lua/kide/core/keybindings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 031bb753..51ba027c 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -148,7 +148,7 @@ M.maplsp = function(client, buffer) -- mapbuf('n', 'gd', 'lua vim.lsp.buf.definition()', opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gD", "lua vim.lsp.buf.declaration()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gt", "lua vim.lsp.buf.type_definition()", opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "Telescope lsp_definitions", opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "lua vim.lsp.buf.definition()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gh", "lua vim.lsp.buf.hover()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gs", "lua vim.lsp.buf.signature_help()", opt) -- mapbuf('n', 'gD', 'lua vim.lsp.buf.declaration()', opt) From 0db2502980784d5b15825f66cb33a6c56ee31eb9 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 31 May 2023 10:08:00 +0800 Subject: [PATCH 122/708] =?UTF-8?q?jdk://=20=20file://=20=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index e68cabc2..aeb60bbb 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -114,10 +114,11 @@ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.s local function markdown_format(input) if input then - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :-]*)%]%(file:/[^%)]+%)", function(i1) + print(input) + input = string.gsub(input, "%[([^%]]*)%]%(file:/[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :-]*)%]%(jdt://[^%)]+%)", function(i1) + input = string.gsub(input, "%[([^%]]*)%]%(jdt://[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) end From 032af0087fcdbd71566af8b87dd3ca040e197d15 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 31 May 2023 10:34:03 +0800 Subject: [PATCH 123/708] support lsp --- lua/kide/core/keybindings.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 51ba027c..c67db85f 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -148,7 +148,12 @@ M.maplsp = function(client, buffer) -- mapbuf('n', 'gd', 'lua vim.lsp.buf.definition()', opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gD", "lua vim.lsp.buf.declaration()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gt", "lua vim.lsp.buf.type_definition()", opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "lua vim.lsp.buf.definition()", opt) + + if client.server_capabilities.definitionProvider then + vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "Telescope lsp_definitions", opt) + else + vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "lua vim.lsp.buf.definition()", opt) + end vim.api.nvim_buf_set_keymap(buffer, "n", "gh", "lua vim.lsp.buf.hover()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gs", "lua vim.lsp.buf.signature_help()", opt) -- mapbuf('n', 'gD', 'lua vim.lsp.buf.declaration()', opt) From d7411e1f3c4c98dc2be4dbf9b4d16d7f52f7d601 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 31 May 2023 14:19:43 +0800 Subject: [PATCH 124/708] update --- lua/kide/lsp/init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index aeb60bbb..ddb9683d 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -114,11 +114,10 @@ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.s local function markdown_format(input) if input then - print(input) - input = string.gsub(input, "%[([^%]]*)%]%(file:/[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@]*)%]%(file:/[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%[([^%]]*)%]%(jdt://[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@]*)%]%(jdt://[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) end From c4e23d289e6163d352b49f7cf0f08346561f4c57 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 31 May 2023 17:38:36 +0800 Subject: [PATCH 125/708] =?UTF-8?q?=E6=89=93=E5=BC=80=20jdt://=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/telescope.lua | 58 ++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index aad67349..3515c24f 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -12,6 +12,62 @@ form_entry.path = function(entry, validate, escape) return f_path(entry, validate, escape) end +local utils = require("telescope.utils") +local set = require("telescope.actions.set") +local action_state = require("telescope.actions.state") +local l_edit = set.edit +set.edit = function(prompt_bufnr, command) + local entry = action_state.get_selected_entry() + + if not entry then + utils.notify("actions.set.edit", { + msg = "Nothing currently selected", + level = "WARN", + }) + return + end + + local filename, row, col + + filename = entry.path or entry.filename + if not vim.startswith(filename, "jdt://") then + l_edit(prompt_bufnr, command) + return + end + + row = entry.row or entry.lnum + col = vim.F.if_nil(entry.col, 1) + + local picker = action_state.get_current_picker(prompt_bufnr) + require("telescope.pickers").on_close_prompt(prompt_bufnr) + pcall(vim.api.nvim_set_current_win, picker.original_win_id) + local win_id = picker.get_selection_window(picker, entry) + + if picker.push_cursor_on_edit then + vim.cmd("normal! m'") + end + + if picker.push_tagstack_on_edit then + local from = { vim.fn.bufnr("%"), vim.fn.line("."), vim.fn.col("."), 0 } + local items = { { tagname = vim.fn.expand(""), from = from } } + vim.fn.settagstack(vim.fn.win_getid(), { items = items }, "t") + end + + if win_id ~= 0 and a.nvim_get_current_win() ~= win_id then + vim.api.nvim_set_current_win(win_id) + end + + if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then + local bufnr = vim.uri_to_bufnr(filename) + vim.bo[bufnr].buflisted = true + vim.api.nvim_win_set_buf(win_id, bufnr) + end + + if row and col then + pcall(vim.api.nvim_win_set_cursor, 0, { row, col }) + end +end + telescope.setup({ defaults = { vimgrep_arguments = { @@ -69,7 +125,7 @@ telescope.setup({ filetype_hook = function(filepath, bufnr, opts) if vim.startswith(filepath, "jdt://") then require("kide.lsp.utils.jdtls").open_classfile(filepath, bufnr, opts.preview.timeout) - return false; + return false end return true end, From a56b01161d91a3804a250b153beba8f724d2bccb Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 1 Jun 2023 11:21:46 +0800 Subject: [PATCH 126/708] client.supports_method --- lua/kide/core/keybindings.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index c67db85f..53f6c4b6 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -132,9 +132,6 @@ M.setup = function() end -- lsp 回调函数快捷键设置 M.maplsp = function(client, buffer) - vim.api.nvim_buf_set_option(buffer, "omnifunc", "v:lua.vim.lsp.omnifunc") - vim.api.nvim_buf_set_option(buffer, "formatexpr", "v:lua.vim.lsp.formatexpr()") - local bufopts = { noremap = true, silent = true, buffer = buffer } vim.api.nvim_buf_set_keymap(buffer, "n", "K", "lua vim.lsp.buf.hover()", opt) -- rename @@ -149,7 +146,7 @@ M.maplsp = function(client, buffer) vim.api.nvim_buf_set_keymap(buffer, "n", "gD", "lua vim.lsp.buf.declaration()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gt", "lua vim.lsp.buf.type_definition()", opt) - if client.server_capabilities.definitionProvider then + if client.supports_method("textDocument/definition") then vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "Telescope lsp_definitions", opt) else vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "lua vim.lsp.buf.definition()", opt) @@ -221,13 +218,12 @@ M.maplsp = function(client, buffer) opt ) -- >= 0.8.x - if client.server_capabilities.documentHighlightProvider then + if client.supports_method("textDocument/documentHighlightProvider") then vim.cmd(string.format("au CursorHold lua vim.lsp.buf.document_highlight()", buffer)) vim.cmd(string.format("au CursorHoldI lua vim.lsp.buf.document_highlight()", buffer)) vim.cmd(string.format("au CursorMoved lua vim.lsp.buf.clear_references()", buffer)) end - local codeLensProvider = client.server_capabilities.codeLensProvider - if codeLensProvider then + if client.supports_method("codeLens/resolve") then vim.api.nvim_buf_set_keymap(buffer, "n", "cr", "lua vim.lsp.codelens.refresh()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "ce", "lua vim.lsp.codelens.run()", opt) end From d97f3dea0e3585ef211f27c54f5a4e13560a17de Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 1 Jun 2023 11:43:50 +0800 Subject: [PATCH 127/708] cmp sorting --- lua/kide/plugins/config/nvim-cmp.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 1f714a5e..707ad218 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -1,6 +1,32 @@ local lspkind = require("lspkind") local cmp = require("cmp") +local config = require("kide.config") + +local function sorting() + local comparators = { + -- Below is the default comparitor list and order for nvim-cmp + cmp.config.compare.offset, + -- cmp.config.compare.scopes, --this is commented in nvim-cmp too + cmp.config.compare.exact, + cmp.config.compare.score, + cmp.config.compare.recently_used, + cmp.config.compare.locality, + cmp.config.compare.kind, + cmp.config.compare.sort_text, + cmp.config.compare.length, + cmp.config.compare.order, + } + if config.plugin.copilot then + table.insert(comparators, 1, require("copilot_cmp.comparators").prioritize) + end + return { + priority_weight = 2, + comparators = comparators, + } +end + cmp.setup({ + sorting = sorting(), -- 指定 snippet 引擎 snippet = { expand = function(args) From 0dadc532a52e17dc7c67fbc175b25dfd83e2c2e2 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 1 Jun 2023 11:44:36 +0800 Subject: [PATCH 128/708] update --- lua/kide/plugins/config/nvim-cmp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 707ad218..649edf59 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -16,7 +16,7 @@ local function sorting() cmp.config.compare.length, cmp.config.compare.order, } - if config.plugin.copilot then + if config.plugin.copilot.enable then table.insert(comparators, 1, require("copilot_cmp.comparators").prioritize) end return { From e56c5dc842aa4c6fe997440a35d4d9e9b830105e Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 1 Jun 2023 11:54:39 +0800 Subject: [PATCH 129/708] doc --- lua/kide/lsp/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index ddb9683d..69fc020e 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -114,10 +114,10 @@ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.s local function markdown_format(input) if input then - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@]*)%]%(file:/[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@\"]*)%]%(file:/[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@]*)%]%(jdt://[^%)]+%)", function(i1) + input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@\"]*)%]%(jdt://[^%)]+%)", function(i1) return "`" .. i1 .. "`" end) end From 8d7c0fa6e2bddd74ab3f9dff7e8a2039299c38a4 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 2 Jun 2023 09:56:26 +0800 Subject: [PATCH 130/708] assertj --- lua/kide/lsp/java.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index fdb33ce3..c9fa4e71 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -250,10 +250,11 @@ local config = { completion = { favoriteStaticMembers = { "org.junit.Assert.*", - "org.hamcrest.MatcherAssert.assertThat", - "org.hamcrest.Matchers.*", - "org.hamcrest.CoreMatchers.*", - "org.junit.jupiter.api.Assertions.*", + "org.assertj.core.api.Assertions.*", + -- "org.hamcrest.MatcherAssert.assertThat", + -- "org.hamcrest.Matchers.*", + -- "org.hamcrest.CoreMatchers.*", + -- "org.junit.jupiter.api.Assertions.*", "java.util.Objects.requireNonNull", "java.util.Objects.requireNonNullElse", "org.mockito.Mockito.*", From 573377359b54bde6c4fb3d74558a163c583e776a Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 2 Jun 2023 10:39:43 +0800 Subject: [PATCH 131/708] definitionProvider --- lua/kide/lsp/java.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index c9fa4e71..b550d4ab 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -318,6 +318,8 @@ config["on_attach"] = function(client, buffer) -- Remove the option if you do not want that. require("jdtls").setup_dap({ hotcodereplace = "auto" }) require("jdtls.setup").add_commands() + -- TODO: 不知道为什么这个值一会有一会没有 + client.server_capabilities["definitionProvider"] = true require("kide.core.keybindings").maplsp(client, buffer) -- require('jdtls.dap').setup_dap_main_class_configs({ verbose = true }) local opts = { silent = true, buffer = buffer } From d897574f2219c949fd1680cee55a9227f26992cf Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 2 Jun 2023 10:48:21 +0800 Subject: [PATCH 132/708] nvim_buf_is_valid --- lua/kide/lsp/utils/jdtls.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/kide/lsp/utils/jdtls.lua b/lua/kide/lsp/utils/jdtls.lua index 11ed90aa..f9f618c4 100644 --- a/lua/kide/lsp/utils/jdtls.lua +++ b/lua/kide/lsp/utils/jdtls.lua @@ -78,9 +78,11 @@ function M.open_classfile(fname, buf, timeout_ms) local content local function handler(err, result) assert(not err, vim.inspect(err)) - content = result - api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(result, "\n", { plain = true })) - vim.bo[buf].modifiable = false + if api.nvim_buf_is_valid(buf) then + content = result + api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(result, "\n", { plain = true })) + vim.bo[buf].modifiable = false + end end if use_cmd then From e051ba9b53795f90f50739085170db4b97ee27f1 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 2 Jun 2023 12:45:22 +0800 Subject: [PATCH 133/708] nvim_buf_is_valid --- lua/kide/lsp/utils/jdtls.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/kide/lsp/utils/jdtls.lua b/lua/kide/lsp/utils/jdtls.lua index f9f618c4..6f9d2fd7 100644 --- a/lua/kide/lsp/utils/jdtls.lua +++ b/lua/kide/lsp/utils/jdtls.lua @@ -85,6 +85,10 @@ function M.open_classfile(fname, buf, timeout_ms) end end + if not api.nvim_buf_is_valid(buf) then + return + end + if use_cmd then local command = { command = "java.decompile", From b5ea1e33374aa8d58b6240091048868e3b0ec909 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 11 Jun 2023 11:01:52 +0800 Subject: [PATCH 134/708] =?UTF-8?q?null-ls=20=E5=BF=AB=E6=8D=B7=E9=94=AE?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/keybindings.lua | 61 +++++++++++++---------------- lua/kide/lsp/init.lua | 4 +- lua/kide/plugins/config/null-ls.lua | 2 +- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 53f6c4b6..bce397c4 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -131,7 +131,7 @@ M.setup = function() end, { desc = "Previous todo comment" }) end -- lsp 回调函数快捷键设置 -M.maplsp = function(client, buffer) +M.maplsp = function(client, buffer, null_ls) local bufopts = { noremap = true, silent = true, buffer = buffer } vim.api.nvim_buf_set_keymap(buffer, "n", "K", "lua vim.lsp.buf.hover()", opt) -- rename @@ -141,38 +141,6 @@ M.maplsp = function(client, buffer) vim.api.nvim_buf_set_keymap(buffer, "n", "ca", "lua vim.lsp.buf.code_action()", opt) vim.api.nvim_buf_set_keymap(buffer, "v", "ca", "lua vim.lsp.buf.code_action()", opt) -- mapbuf('n', 'ca', 'lua require("lspsaga.codeaction").code_action()', opt) - -- go xx - -- mapbuf('n', 'gd', 'lua vim.lsp.buf.definition()', opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "gD", "lua vim.lsp.buf.declaration()", opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "gt", "lua vim.lsp.buf.type_definition()", opt) - - if client.supports_method("textDocument/definition") then - vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "Telescope lsp_definitions", opt) - else - vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "lua vim.lsp.buf.definition()", opt) - end - vim.api.nvim_buf_set_keymap(buffer, "n", "gh", "lua vim.lsp.buf.hover()", opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "gs", "lua vim.lsp.buf.signature_help()", opt) - -- mapbuf('n', 'gD', 'lua vim.lsp.buf.declaration()', opt) - -- mapbuf('n', 'gD', 'lua vim.lsp.buf.type_definition()', opt) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "Trouble lsp_type_definitions", opt) - -- mapbuf('n', 'gi', 'lua vim.lsp.buf.implementation()', opt) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "Trouble lsp_implementations", opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "gi", "Telescope lsp_implementations", opt) - -- mapbuf('n', 'gr', 'lua vim.lsp.buf.references()', opt) - -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "Trouble lsp_references", opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "gr", "Telescope lsp_references", opt) - -- mapbuf('n', 'gr', 'lua require"lspsaga.provider".lsp_finder()', opt) - -- mapbuf('n', 's', 'lua vim.lsp.buf.workspace_symbol()', opt) - -- mapbuf('n', 's', 'lua require"telescope.builtin".lsp_workspace_symbols({ query = vim.fn.input("Query> ") })', opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "fs", "Telescope lsp_dynamic_workspace_symbols", opt) - keymap("v", "fs", function() - local tb = require("telescope.builtin") - local text = require("kide.core.utils").get_visual_selection() - tb.lsp_workspace_symbols({ default_text = text, query = text }) - end, opt) - - vim.api.nvim_buf_set_keymap(buffer, "n", "fo", "Telescope lsp_document_symbols", opt) -- diagnostic vim.api.nvim_buf_set_keymap(buffer, "n", "go", "lua vim.diagnostic.open_float()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "[g", "lua vim.diagnostic.goto_prev()", opt) @@ -217,6 +185,33 @@ M.maplsp = function(client, buffer) "lua require('telescope.builtin').diagnostics({ severity = vim.diagnostic.severity.ERROR })", opt ) + + -- -------- null_ls 不支持快捷键不绑定 ------------------------------- + if null_ls then + return + end + -- go xx + -- mapbuf('n', 'gd', 'lua vim.lsp.buf.definition()', opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "gD", "lua vim.lsp.buf.declaration()", opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "gt", "lua vim.lsp.buf.type_definition()", opt) + + if client.supports_method("textDocument/definition") then + vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "Telescope lsp_definitions", opt) + else + vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "lua vim.lsp.buf.definition()", opt) + end + vim.api.nvim_buf_set_keymap(buffer, "n", "gh", "lua vim.lsp.buf.hover()", opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "gs", "lua vim.lsp.buf.signature_help()", opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "gi", "Telescope lsp_implementations", opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "gr", "Telescope lsp_references", opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "fs", "Telescope lsp_dynamic_workspace_symbols", opt) + keymap("v", "fs", function() + local tb = require("telescope.builtin") + local text = require("kide.core.utils").get_visual_selection() + tb.lsp_workspace_symbols({ default_text = text, query = text }) + end, opt) + + vim.api.nvim_buf_set_keymap(buffer, "n", "fo", "Telescope lsp_document_symbols", opt) -- >= 0.8.x if client.supports_method("textDocument/documentHighlightProvider") then vim.cmd(string.format("au CursorHold lua vim.lsp.buf.document_highlight()", buffer)) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 69fc020e..6321a360 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -114,10 +114,10 @@ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.s local function markdown_format(input) if input then - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@\"]*)%]%(file:/[^%)]+%)", function(i1) + input = string.gsub(input, '%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@"]*)%]%(file:/[^%)]+%)', function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, "%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@\"]*)%]%(jdt://[^%)]+%)", function(i1) + input = string.gsub(input, '%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@"]*)%]%(jdt://[^%)]+%)', function(i1) return "`" .. i1 .. "`" end) end diff --git a/lua/kide/plugins/config/null-ls.lua b/lua/kide/plugins/config/null-ls.lua index fb84773d..02699582 100644 --- a/lua/kide/plugins/config/null-ls.lua +++ b/lua/kide/plugins/config/null-ls.lua @@ -129,7 +129,7 @@ end null_ls.setup({ sources = sources, on_attach = function(client, bufnr) - require("kide.core.keybindings").maplsp(client, bufnr) + require("kide.core.keybindings").maplsp(client, bufnr, true) -- on_attach(client, bufnr) end, -- debug = true, From 7805fae510f15c5954d35164c3633b236d005e5d Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 12 Jun 2023 09:42:03 +0800 Subject: [PATCH 135/708] fidget --- lua/kide/lsp/init.lua | 1 - lua/kide/plugins/lazy-nvim.lua | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 6321a360..8738ce96 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -32,7 +32,6 @@ local server_configs = { local utils = require("kide.core.utils") -- LSP 进度UI -require("fidget") require("mason-lspconfig").setup_handlers({ -- The first entry (without a key) will be the default handler -- and will be called for each installed server that doesn't have diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index f18f8f1c..b9ee66bb 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -580,6 +580,8 @@ require("lazy").setup({ { "j-hui/fidget.nvim", lazy = true, + tag = "legacy", + event = "VeryLazy", config = function() require("fidget").setup({ text = { From 326a6dfb8593be0cd98685965ee6f96eebe4edb0 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 17 Jun 2023 22:29:57 +0800 Subject: [PATCH 136/708] vim.uv --- lua/lazy_bootstrap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazy_bootstrap.lua b/lua/lazy_bootstrap.lua index d14f916e..83b6b8e5 100644 --- a/lua/lazy_bootstrap.lua +++ b/lua/lazy_bootstrap.lua @@ -1,5 +1,5 @@ local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then +if not vim.uv.fs_stat(lazypath) then vim.fn.system({ "git", "clone", From c1d90b6766f059f31b0a877e28c21c67746ca728 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 17 Jun 2023 22:33:32 +0800 Subject: [PATCH 137/708] vim.uv --- lua/kide/core/utils/plantuml.lua | 2 +- lua/kide/core/vscode/init.lua | 2 +- lua/kide/dap/codelldb.lua | 8 ++++---- lua/kide/lsp/java.lua | 2 +- lua/kide/plugins/config/pandoc.lua | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lua/kide/core/utils/plantuml.lua b/lua/kide/core/utils/plantuml.lua index 0cec7a82..c1fd2bbf 100644 --- a/lua/kide/core/utils/plantuml.lua +++ b/lua/kide/core/utils/plantuml.lua @@ -1,4 +1,4 @@ -local uv = vim.loop +local uv = vim.uv local utils = require("kide.core.utils") local plantuml_args_complete = utils.command_args_complete local M = {} diff --git a/lua/kide/core/vscode/init.lua b/lua/kide/core/vscode/init.lua index 6604f08f..4a30e561 100644 --- a/lua/kide/core/vscode/init.lua +++ b/lua/kide/core/vscode/init.lua @@ -1,6 +1,6 @@ local M = {} local env = { - HOME = vim.loop.os_homedir(), + HOME = vim.uv.os_homedir(), VSCODE_EXTENSIONS = vim.env["VSCODE_EXTENSIONS"], } M.get_vscode_extensions = function() diff --git a/lua/kide/dap/codelldb.lua b/lua/kide/dap/codelldb.lua index 79e40af3..c60a8af3 100644 --- a/lua/kide/dap/codelldb.lua +++ b/lua/kide/dap/codelldb.lua @@ -46,22 +46,22 @@ M.setup = function(config) local dap = require("dap") dap.adapters.codelldb = function(on_adapter) -- This asks the system for a free port - local tcp = vim.loop.new_tcp() + local tcp = vim.uv.new_tcp() tcp:bind("127.0.0.1", 0) local port = tcp:getsockname().port tcp:shutdown() tcp:close() -- Start codelldb with the port - local stdout = vim.loop.new_pipe(false) - local stderr = vim.loop.new_pipe(false) + local stdout = vim.uv.new_pipe(false) + local stderr = vim.uv.new_pipe(false) local opts = { stdio = { nil, stdout, stderr }, args = { "--liblldb", M.liblldb_path, "--port", tostring(port) }, } local handle local pid_or_err - handle, pid_or_err = vim.loop.spawn(M.config.codelldb_path, opts, function(code) + handle, pid_or_err = vim.uv.spawn(M.config.codelldb_path, opts, function(code) stdout:close() stderr:close() handle:close() diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index b550d4ab..2458a520 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -1,6 +1,6 @@ local M = {} local env = { - HOME = vim.loop.os_homedir(), + HOME = vim.uv.os_homedir(), JAVA_HOME = vim.env["JAVA_HOME"], JDTLS_RUN_JAVA = vim.env["JDTLS_RUN_JAVA"], JDTLS_HOME = vim.env["JDTLS_HOME"], diff --git a/lua/kide/plugins/config/pandoc.lua b/lua/kide/plugins/config/pandoc.lua index e22bbfca..3de0341e 100644 --- a/lua/kide/plugins/config/pandoc.lua +++ b/lua/kide/plugins/config/pandoc.lua @@ -5,7 +5,7 @@ require("pandoc").setup({ }, }) -local uv = vim.loop +local uv = vim.uv require("pandoc.process").spawn = function(bin, args, callback) local stdout = uv.new_pipe(false) local stderr = uv.new_pipe(false) From bdc902a5e7bc60f0d36f4119c62bacb0d2714aea Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 17 Jun 2023 22:36:24 +0800 Subject: [PATCH 138/708] del --- lua/kide/core/vscode/init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/kide/core/vscode/init.lua b/lua/kide/core/vscode/init.lua index 4a30e561..e3d71896 100644 --- a/lua/kide/core/vscode/init.lua +++ b/lua/kide/core/vscode/init.lua @@ -1,6 +1,5 @@ local M = {} local env = { - HOME = vim.uv.os_homedir(), VSCODE_EXTENSIONS = vim.env["VSCODE_EXTENSIONS"], } M.get_vscode_extensions = function() From 6824317f1204d22eb2cf0b653d0adb486e5710c2 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 23 Jun 2023 21:39:03 +0800 Subject: [PATCH 139/708] cmp-dap --- lua/kide/plugins/config/nvim-cmp.lua | 9 +++++++++ lua/kide/plugins/lazy-nvim.lua | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 649edf59..74c0bbb5 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -26,6 +26,9 @@ local function sorting() end cmp.setup({ + enabled = function() + return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" or require("cmp_dap").is_dap_buffer() + end, sorting = sorting(), -- 指定 snippet 引擎 snippet = { @@ -100,3 +103,9 @@ cmp.setup.cmdline(":", { { name = "cmdline" }, }), }) + +cmp.setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, { + sources = { + { name = "dap" }, + }, +}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index b9ee66bb..fd6021b6 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -78,6 +78,7 @@ require("lazy").setup({ "hrsh7th/cmp-cmdline", "saadparwaiz1/cmp_luasnip", "onsails/lspkind-nvim", + "rcarriga/cmp-dap", }, lazy = true, config = function() @@ -100,7 +101,10 @@ require("lazy").setup({ "hrsh7th/cmp-path", lazy = true, }, - + { + "rcarriga/cmp-dap", + lazy = true, + }, { "jose-elias-alvarez/null-ls.nvim", lazy = true, From 3e91e48fd74cfddffe0a04f388f51c5f83f3f4f6 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 23 Jun 2023 22:17:22 +0800 Subject: [PATCH 140/708] codelldb --- lua/kide/dap/codelldb.lua | 75 +++++++-------------------------------- lua/kide/dap/init.lua | 7 +--- 2 files changed, 14 insertions(+), 68 deletions(-) diff --git a/lua/kide/dap/codelldb.lua b/lua/kide/dap/codelldb.lua index c60a8af3..48493449 100644 --- a/lua/kide/dap/codelldb.lua +++ b/lua/kide/dap/codelldb.lua @@ -31,71 +31,22 @@ M.liblldb_path = (function() end end)() -M.config = {} - -M.setup = function(config) +M.setup = function() if not M.extension_path then vim.notify("codelldb not found", vim.log.levels.WARN) return false end - M.config.codelldb_path = M.codelldb_path - -- M.config.liblldb_path = extension_path .. "/lldb/lib/liblldb.dylib" - if config then - M.config = vim.tbl_deep_extend("force", M.config, config) - end local dap = require("dap") - dap.adapters.codelldb = function(on_adapter) - -- This asks the system for a free port - local tcp = vim.uv.new_tcp() - tcp:bind("127.0.0.1", 0) - local port = tcp:getsockname().port - tcp:shutdown() - tcp:close() - - -- Start codelldb with the port - local stdout = vim.uv.new_pipe(false) - local stderr = vim.uv.new_pipe(false) - local opts = { - stdio = { nil, stdout, stderr }, - args = { "--liblldb", M.liblldb_path, "--port", tostring(port) }, - } - local handle - local pid_or_err - handle, pid_or_err = vim.uv.spawn(M.config.codelldb_path, opts, function(code) - stdout:close() - stderr:close() - handle:close() - if code ~= 0 then - print("codelldb exited with code", code) - end - end) - if not handle then - vim.notify("Error running codelldb: " .. tostring(pid_or_err), vim.log.levels.ERROR) - stdout:close() - stderr:close() - return - end - vim.notify("codelldb started. pid=" .. pid_or_err) - stderr:read_start(function(err, chunk) - assert(not err, err) - if chunk then - vim.schedule(function() - require("dap.repl").append(chunk) - end) - end - end) - local adapter = { - type = "server", - host = "127.0.0.1", - port = port, - } - -- 💀 - -- Wait for codelldb to get ready and start listening before telling nvim-dap to connect - -- If you get connect errors, try to increase 500 to a higher value, or check the stderr (Open the REPL) - vim.defer_fn(function() - on_adapter(adapter) - end, 500) - end + dap.adapters.codelldb = { + type = "server", + port = "${port}", + executable = { + command = M.codelldb_path, + args = { "--liblldb", M.liblldb_path, "--port", "${port}" }, + -- On windows you may have to uncomment this: + -- detached = false, + }, + } dap.configurations.cpp = { { @@ -106,11 +57,11 @@ M.setup = function(config) return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") end, cwd = "${workspaceFolder}", - stopOnEntry = true, + stopOnEntry = false, }, } dap.configurations.c = dap.configurations.cpp - dap.configurations.rust = dap.configurations.cpp + -- dap.configurations.rust = dap.configurations.cpp return true end return M diff --git a/lua/kide/dap/init.lua b/lua/kide/dap/init.lua index 180f9ee1..610267e0 100644 --- a/lua/kide/dap/init.lua +++ b/lua/kide/dap/init.lua @@ -1,9 +1,4 @@ -vim.api.nvim_create_user_command("CodelldbLoad", function() - if not vim.g.codelldb_load then - vim.g.codelldb_load = require("kide.dap.codelldb").setup() - end -end, {}) - +require("kide.dap.codelldb").setup() vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "Debug", linehl = "", numhl = "" }) -- vim.fn.sign_define('DapBreakpoint', { text = '🔴', texthl = '', linehl = '', numhl = '' }) -- vim.fn.sign_define("DapBreakpointCondition", { text = "C", texthl = "", linehl = "", numhl = "" }) From 56bec6cda9425d470cd6b0d2023f645cd420d684 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 23 Jun 2023 23:07:52 +0800 Subject: [PATCH 141/708] nvim-gdb --- lua/kide/plugins/lazy-nvim.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index fd6021b6..c2ae4653 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -235,6 +235,24 @@ require("lazy").setup({ require("dap-python").setup(config.env.py_bin) end, }, + { + "sakhnik/nvim-gdb", + lazy = true, + cmd = { + "GdbStart", + "GdbStartLLDB", + "GdbStartPDB", + "GdbStartBashDB", + "GdbStartRR", + }, + init = function() + vim.g.nvimgdb_disable_start_keymaps = 1 + vim.g.nvimgdb_use_find_executables = 0 + vim.g.nvimgdb_use_cmake_to_find_executables = 0 + end, + config = function() end, + build = ":!./install.sh", + }, -- 搜索插件 { From c3a48deebdc3913a6ac03733ac7296f5041da307 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 25 Jun 2023 12:01:33 +0800 Subject: [PATCH 142/708] del tt --- lua/kide/core/basic.lua | 11 ----------- lua/kide/core/keybindings.lua | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 7dfe3f18..5eb814e3 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -206,17 +206,6 @@ autocmd({ "BufReadCmd" }, { end, }) --- toggle_term -autocmd("FileType", { - group = augroup("toggle_term"), - pattern = { - "toggleterm", - }, - callback = function(event) - vim.bo[event.buf].buflisted = false - vim.keymap.set("n", "tt", ":ToggleTerm", { buffer = event.buf, silent = true }) - end, -}) autocmd("FileType", { group = augroup("gitcommit"), diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index bce397c4..45536d2c 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -47,7 +47,7 @@ M.setup = function() map("t", "", ":ToggleTerm", opt) map("n", "tt", ":ToggleTerm", opt) map("v", "tt", ":ToggleTermSendVisualSelection", opt) - map("t", "tt", ":ToggleTerm", opt) + -- map("t", "tt", ":ToggleTerm", opt) -- symbols-outline.nvim map("n", "o", ":SymbolsOutline", opt) From 896dd9ee1a74868b1433d46eff46bb7315da84ce Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 25 Jun 2023 21:48:48 +0800 Subject: [PATCH 143/708] junit --- lua/kide/lsp/java.lua | 2 + lua/kide/lsp/utils/jdtls.lua | 77 ++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 2458a520..cc3044e8 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -371,7 +371,9 @@ M.start = function() jdtls.start_or_attach(config) end + M.setup = function() + require('kide.lsp.utils.jdtls').customize_jdtls() local group = vim.api.nvim_create_augroup("kide_jdtls_java", { clear = true }) vim.api.nvim_create_autocmd({ "FileType" }, { group = group, diff --git a/lua/kide/lsp/utils/jdtls.lua b/lua/kide/lsp/utils/jdtls.lua index 6f9d2fd7..d3e8ecb4 100644 --- a/lua/kide/lsp/utils/jdtls.lua +++ b/lua/kide/lsp/utils/jdtls.lua @@ -107,4 +107,81 @@ function M.open_classfile(fname, buf, timeout_ms) return content ~= nil end) end + +M.customize_jdtls = function() + local function mk_buf_loop(sock, handle_buffer) + local buffer = "" + return function(err, chunk) + assert(not err, err) + if chunk then + buffer = buffer .. chunk + else + sock:close() + handle_buffer(buffer) + end + end + end + + -- 零时修改等上游修复后删除 + -- @see https://github.com/mfussenegger/nvim-jdtls/blob/master/lua/jdtls/junit.lua + local junit = require("jdtls.junit") + junit.mk_test_results = function(bufnr) + local tests = {} + local handle_buffer = function(buf) + junit.__parse(buf, tests) + end + return { + show = function() + local items = {} + local repl = require("dap.repl") + local num_failures = 0 + for _, test in ipairs(tests) do + if test.failed then + num_failures = num_failures + 1 + if test.method then + repl.append(" " .. test.method, "$") + end + for _, msg in ipairs(test.traces) do + local match = msg:match(string.format("at %s.%s", test.fq_class, test.method) .. "%(([%a%p]*:%d+)%)") + if match then + local lnum = vim.split(match, ":")[2] + local trace = table.concat(test.traces, "\n") + if #trace > 140 then + trace = trace:sub(1, 140) .. "..." + end + table.insert(items, { + bufnr = bufnr, + lnum = lnum, + text = test.method .. " " .. trace, + }) + end + repl.append(msg, "$") + end + else + repl.append(" " .. test.method, "$") + end + end + + if num_failures > 0 then + vim.fn.setqflist({}, "r", { + title = "jdtls-tests", + items = items, + }) + print( + "Tests finished. Results printed to dap-repl.", + #items > 0 and "Errors added to quickfix list" or "", + string.format("( %d / %d)", num_failures, #tests) + ) + else + print("Tests finished. Results printed to dap-repl. All", #tests, "succeeded") + end + return items + end, + mk_reader = function(sock) + return vim.schedule_wrap(mk_buf_loop(sock, handle_buffer)) + end, + } + end +end + return M From 25aa42dd43de1dd5e47b55117612533c0523588c Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 28 Jun 2023 11:16:09 +0800 Subject: [PATCH 144/708] inlayhints --- lua/kide/lsp/init.lua | 2 ++ lua/kide/lsp/java.lua | 16 +++++++++++----- lua/kide/lsp/rust_analyzer.lua | 1 + lua/kide/plugins/lazy-nvim.lua | 9 +++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 8738ce96..8a0f8f21 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -52,6 +52,7 @@ require("mason-lspconfig").setup_handlers({ scfg.on_attach = function(client, buffer) -- 绑定快捷键 require("kide.core.keybindings").maplsp(client, buffer) + require("lsp-inlayhints").on_attach(client, buffer) if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, buffer) end @@ -80,6 +81,7 @@ for _, value in pairs(server_configs) do on_attach = function(client, buffer) -- 绑定快捷键 require("kide.core.keybindings").maplsp(client, buffer) + require("lsp-inlayhints").on_attach(client, buffer) if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, buffer) end diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index cc3044e8..a3ed10e4 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -216,6 +216,9 @@ local config = { "**/.git/**", }, }, + inlayhints = { + parameterNames = { enabled = true }, + }, autobuild = { enabled = true }, referenceCodeLens = { enabled = true }, implementationsCodeLens = { enabled = true }, @@ -340,6 +343,7 @@ config["on_attach"] = function(client, buffer) -- end require("nvim-navic").attach(client, buffer) + require("lsp-inlayhints").on_attach(client, buffer) require("java-deps").attach(client, buffer, root_dir) create_command(buffer, "JavaProjects", require("java-deps").toggle_outline, { nargs = 0, @@ -358,6 +362,9 @@ local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protoc -- } config.capabilities = capabilities +config.flags = { + debounce_text_changes = 150, +} config.handlers = {} config.handlers["language/status"] = function(_, s) -- 使用 progress 查看状态 @@ -367,13 +374,12 @@ config.handlers["language/status"] = function(_, s) end end -M.start = function() +M.start = function(_opts) jdtls.start_or_attach(config) end - -M.setup = function() - require('kide.lsp.utils.jdtls').customize_jdtls() +M.setup = function(opts) + require("kide.lsp.utils.jdtls").customize_jdtls() local group = vim.api.nvim_create_augroup("kide_jdtls_java", { clear = true }) vim.api.nvim_create_autocmd({ "FileType" }, { group = group, @@ -383,7 +389,7 @@ M.setup = function() if e.file == "java" and vim.bo[e.buf].buftype == "nofile" then -- ignore else - M.start() + M.start(opts) end end, }) diff --git a/lua/kide/lsp/rust_analyzer.lua b/lua/kide/lsp/rust_analyzer.lua index 0b480686..1c5ac30d 100644 --- a/lua/kide/lsp/rust_analyzer.lua +++ b/lua/kide/lsp/rust_analyzer.lua @@ -11,6 +11,7 @@ local config = { }, tools = { inlay_hints = { + auto = false, parameter_hints_prefix = " ", other_hints_prefix = " ", }, diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index c2ae4653..889ef8da 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -706,6 +706,15 @@ require("lazy").setup({ end, }, + -- lsp-inlayhints + { + "lvimuser/lsp-inlayhints.nvim", + lazy = true, + config = function() + require("lsp-inlayhints").setup() + end, + }, + -- 笔记 { "mickael-menu/zk-nvim", From 08676f22f1d7251ca6f6ce13b664468a775b4834 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 28 Jun 2023 12:30:37 +0800 Subject: [PATCH 145/708] TODO --- lua/kide/plugins/lazy-nvim.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 889ef8da..f996ce01 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -707,6 +707,7 @@ require("lazy").setup({ }, -- lsp-inlayhints + -- TODO: 等待内置,然后删除 { "lvimuser/lsp-inlayhints.nvim", lazy = true, From 44e0fb6d449e708f1f0b316b46779c21730f65d7 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 28 Jun 2023 12:43:45 +0800 Subject: [PATCH 146/708] =?UTF-8?q?LspAttach=20=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/init.lua | 40 ++++++++++++++++++++++++++++++++-------- lua/kide/lsp/java.lua | 2 -- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 8a0f8f21..e4ac5890 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -52,10 +52,6 @@ require("mason-lspconfig").setup_handlers({ scfg.on_attach = function(client, buffer) -- 绑定快捷键 require("kide.core.keybindings").maplsp(client, buffer) - require("lsp-inlayhints").on_attach(client, buffer) - if client.server_capabilities.documentSymbolProvider then - require("nvim-navic").attach(client, buffer) - end if on_attach then on_attach(client, buffer) end @@ -81,10 +77,6 @@ for _, value in pairs(server_configs) do on_attach = function(client, buffer) -- 绑定快捷键 require("kide.core.keybindings").maplsp(client, buffer) - require("lsp-inlayhints").on_attach(client, buffer) - if client.server_capabilities.documentSymbolProvider then - require("nvim-navic").attach(client, buffer) - end end, }) end @@ -113,6 +105,38 @@ vim.diagnostic.config({ vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lsp_ui.hover_actions) vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp_ui.hover_actions) +-- LspAttach 事件 +vim.api.nvim_create_augroup("LspAttach_inlayhints", {}) +vim.api.nvim_create_autocmd("LspAttach", { + group = "LspAttach_inlayhints", + callback = function(args) + if not (args.data and args.data.client_id) then + return + end + + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + require("lsp-inlayhints").on_attach(client, bufnr) + end, +}) + +vim.api.nvim_create_augroup("LspAttach_navic", {}) +vim.api.nvim_create_autocmd("LspAttach", { + group = "LspAttach_navic", + callback = function(args) + if not (args.data and args.data.client_id) then + return + end + + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client.server_capabilities.documentSymbolProvider then + require("nvim-navic").attach(client, bufnr) + end + end, +}) + +-- 文档格式化 local function markdown_format(input) if input then input = string.gsub(input, '%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@"]*)%]%(file:/[^%)]+%)', function(i1) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index a3ed10e4..8d16bc71 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -342,8 +342,6 @@ config["on_attach"] = function(client, buffer) -- vim.g.jdtls_dap_main_class_config_init = false -- end - require("nvim-navic").attach(client, buffer) - require("lsp-inlayhints").on_attach(client, buffer) require("java-deps").attach(client, buffer, root_dir) create_command(buffer, "JavaProjects", require("java-deps").toggle_outline, { nargs = 0, From d940af54273a511849c5b5655e108b1dda742875 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 28 Jun 2023 12:49:57 +0800 Subject: [PATCH 147/708] =?UTF-8?q?anticonceal=20=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/lazy-nvim.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index f996ce01..ea2fff40 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -711,6 +711,7 @@ require("lazy").setup({ { "lvimuser/lsp-inlayhints.nvim", lazy = true, + branch = "anticonceal", config = function() require("lsp-inlayhints").setup() end, From 1929e57b4af8a9fb1d37837ad30165a63b9f5222 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 28 Jun 2023 12:54:09 +0800 Subject: [PATCH 148/708] lua hint --- lua/kide/lsp/lua_ls.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/kide/lsp/lua_ls.lua b/lua/kide/lsp/lua_ls.lua index 0402e67b..5524b980 100644 --- a/lua/kide/lsp/lua_ls.lua +++ b/lua/kide/lsp/lua_ls.lua @@ -11,6 +11,9 @@ return { -- Setup your lua path -- path = runtime_path, }, + hint = { + enable = true, + }, diagnostics = { -- Get the language server to recognize the `vim` global globals = { "vim" }, From 4b5d33a3dffaf94227c5a5e7ad53e1b92dfd6236 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 28 Jun 2023 13:02:28 +0800 Subject: [PATCH 149/708] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20Native=20LSP=20Inl?= =?UTF-8?q?ay=20Hint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/init.lua | 17 +++++------------ lua/kide/plugins/lazy-nvim.lua | 11 ----------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index e4ac5890..33ac0089 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -106,18 +106,11 @@ vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, ls vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp_ui.hover_actions) -- LspAttach 事件 -vim.api.nvim_create_augroup("LspAttach_inlayhints", {}) -vim.api.nvim_create_autocmd("LspAttach", { - group = "LspAttach_inlayhints", - callback = function(args) - if not (args.data and args.data.client_id) then - return - end - - local bufnr = args.buf - local client = vim.lsp.get_client_by_id(args.data.client_id) - require("lsp-inlayhints").on_attach(client, bufnr) - end, +vim.api.nvim_create_autocmd({ 'InsertEnter' }, { + callback = function () vim.lsp.buf.inlay_hint(0, true) end, +}) +vim.api.nvim_create_autocmd({ 'InsertLeave' }, { + callback = function () vim.lsp.buf.inlay_hint(0, false) end, }) vim.api.nvim_create_augroup("LspAttach_navic", {}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index ea2fff40..c2ae4653 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -706,17 +706,6 @@ require("lazy").setup({ end, }, - -- lsp-inlayhints - -- TODO: 等待内置,然后删除 - { - "lvimuser/lsp-inlayhints.nvim", - lazy = true, - branch = "anticonceal", - config = function() - require("lsp-inlayhints").setup() - end, - }, - -- 笔记 { "mickael-menu/zk-nvim", From 33c29def1ea68ed62c5bb09a579fbdc90e092c1d Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 28 Jun 2023 15:12:51 +0800 Subject: [PATCH 150/708] InlayHint --- lua/kide/core/keybindings.lua | 8 +++---- lua/kide/lsp/init.lua | 40 +++++++++++++++++------------------ lua/kide/lsp/java.lua | 11 +++++----- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 45536d2c..49b513e4 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -213,15 +213,13 @@ M.maplsp = function(client, buffer, null_ls) vim.api.nvim_buf_set_keymap(buffer, "n", "fo", "Telescope lsp_document_symbols", opt) -- >= 0.8.x - if client.supports_method("textDocument/documentHighlightProvider") then + if client.server_capabilities.documentHighlightProvider then vim.cmd(string.format("au CursorHold lua vim.lsp.buf.document_highlight()", buffer)) vim.cmd(string.format("au CursorHoldI lua vim.lsp.buf.document_highlight()", buffer)) vim.cmd(string.format("au CursorMoved lua vim.lsp.buf.clear_references()", buffer)) end - if client.supports_method("codeLens/resolve") then - vim.api.nvim_buf_set_keymap(buffer, "n", "cr", "lua vim.lsp.codelens.refresh()", opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "ce", "lua vim.lsp.codelens.run()", opt) - end + vim.api.nvim_buf_set_keymap(buffer, "n", "cr", "lua vim.lsp.codelens.refresh()", opt) + vim.api.nvim_buf_set_keymap(buffer, "n", "ce", "lua vim.lsp.codelens.run()", opt) end -- nvim-cmp 自动补全 diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 33ac0089..7ac9fc40 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -5,15 +5,11 @@ mason_lspconfig.setup({ }, }) --- 安装列表 --- https://github.com/williamboman/nvim-lsp-installer#available-lsps -- { key: 语言 value: 配置文件 } local server_configs = { - -- sumneko_lua -> lua_ls - lua_ls = require("kide.lsp.lua_ls"), -- /lua/lsp/lua.lua - jdtls = require("kide.lsp.java"), -- /lua/lsp/jdtls.lua - metals = require("kide.lsp.metals"), -- /lua/lsp/jdtls.lua - -- jsonls = require("lsp.jsonls"), + lua_ls = require("kide.lsp.lua_ls"), + jdtls = require("kide.lsp.java"), + metals = require("kide.lsp.metals"), clangd = require("kide.lsp.clangd"), tsserver = require("kide.lsp.tsserver"), html = require("kide.lsp.html"), @@ -27,16 +23,10 @@ local server_configs = { gdscript = require("kide.lsp.gdscript"), } --- 没有确定使用效果参数 --- capabilities.textDocument.completion.completionItem.snippetSupport = true local utils = require("kide.core.utils") --- LSP 进度UI require("mason-lspconfig").setup_handlers({ - -- The first entry (without a key) will be the default handler - -- and will be called for each installed server that doesn't have - -- a dedicated handler. - function(server_name) -- default handler (optional) + function(server_name) local lspconfig = require("lspconfig") -- tools config local cfg = utils.or_default(server_configs[server_name], {}) @@ -47,7 +37,6 @@ require("mason-lspconfig").setup_handlers({ -- lspconfig local scfg = utils.or_default(cfg.server, {}) - -- scfg = vim.tbl_deep_extend("force", server:get_default_options(), scfg) local on_attach = scfg.on_attach scfg.on_attach = function(client, buffer) -- 绑定快捷键 @@ -67,6 +56,7 @@ require("mason-lspconfig").setup_handlers({ end, }) +-- 自定义 LSP 启动方式 for _, value in pairs(server_configs) do if value.setup then value.setup({ @@ -106,11 +96,21 @@ vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, ls vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp_ui.hover_actions) -- LspAttach 事件 -vim.api.nvim_create_autocmd({ 'InsertEnter' }, { - callback = function () vim.lsp.buf.inlay_hint(0, true) end, -}) -vim.api.nvim_create_autocmd({ 'InsertLeave' }, { - callback = function () vim.lsp.buf.inlay_hint(0, false) end, + +vim.api.nvim_create_augroup("LspAttach_inlay_hint", {}) +vim.api.nvim_create_autocmd("LspAttach", { + group = "LspAttach_inlay_hint", + callback = function(args) + if not (args.data and args.data.client_id) then + return + end + + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client.server_capabilities.inlayHintProvider then + vim.lsp.buf.inlay_hint(bufnr, true) + end + end, }) vim.api.nvim_create_augroup("LspAttach_navic", {}) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 8d16bc71..6239e75f 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -335,12 +335,11 @@ config["on_attach"] = function(client, buffer) create_command(buffer, "OR", require("jdtls").organize_imports, { nargs = 0, }) - -- if vim.g.jdtls_dap_main_class_config_init then - -- vim.defer_fn(function() - -- require("jdtls.dap").setup_dap_main_class_configs({ verbose = true }) - -- end, 3000) - -- vim.g.jdtls_dap_main_class_config_init = false - -- end + create_command(buffer, "InlayHint", function() + vim.lsp.buf.inlay_hint(0) + end, { + nargs = 0, + }) require("java-deps").attach(client, buffer, root_dir) create_command(buffer, "JavaProjects", require("java-deps").toggle_outline, { From a416a32e00b74860b33b4d6791fb81d97d44cfc6 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 29 Jun 2023 15:31:44 +0800 Subject: [PATCH 151/708] Flutter --- lua/kide/plugins/config/lualine.lua | 13 +++++++++++++ lua/kide/plugins/lazy-nvim.lua | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index feaab383..aca8c8e3 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -132,4 +132,17 @@ java_projects.filetypes = { "JavaProjects", } table.insert(config.extensions, java_projects) + +-- Flutter +local flutter = {} +flutter.sections = { + lualine_a = { + { "filename", file_status = false }, + }, +} +flutter.filetypes = { + "flutterToolsOutline", +} +table.insert(config.extensions, flutter) + require("lualine").setup(config) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index c2ae4653..e93f711d 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -734,6 +734,17 @@ require("lazy").setup({ end, }, + { + "akinsho/flutter-tools.nvim", + lazy = false, + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + require("flutter-tools").setup({}) -- use defaults + end, + }, + -- ui { "MunifTanjim/nui.nvim", From b1afd809d3a202429d6eb0ed0b0986a2ecdc7480 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 29 Jun 2023 15:33:19 +0800 Subject: [PATCH 152/708] lazy --- lua/kide/plugins/lazy-nvim.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index e93f711d..aa8aecf3 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -736,7 +736,8 @@ require("lazy").setup({ { "akinsho/flutter-tools.nvim", - lazy = false, + lazy = true, + ft = { "dart" }, dependencies = { "nvim-lua/plenary.nvim", }, From 508227b3684c4a02a347ae458c95816cdac2b24f Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 29 Jun 2023 15:46:59 +0800 Subject: [PATCH 153/708] LspAttach_keymap --- lua/kide/lsp/init.lua | 29 +++++++++++++++++------------ lua/kide/lsp/java.lua | 1 - lua/kide/plugins/config/null-ls.lua | 5 ----- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 7ac9fc40..072dd69f 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -37,14 +37,6 @@ require("mason-lspconfig").setup_handlers({ -- lspconfig local scfg = utils.or_default(cfg.server, {}) - local on_attach = scfg.on_attach - scfg.on_attach = function(client, buffer) - -- 绑定快捷键 - require("kide.core.keybindings").maplsp(client, buffer) - if on_attach then - on_attach(client, buffer) - end - end scfg.flags = { debounce_text_changes = 150, } @@ -64,10 +56,6 @@ for _, value in pairs(server_configs) do debounce_text_changes = 150, }, capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), - on_attach = function(client, buffer) - -- 绑定快捷键 - require("kide.core.keybindings").maplsp(client, buffer) - end, }) end end @@ -96,6 +84,23 @@ vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, ls vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp_ui.hover_actions) -- LspAttach 事件 +vim.api.nvim_create_augroup("LspAttach_keymap", {}) +vim.api.nvim_create_autocmd("LspAttach", { + group = "LspAttach_keymap", + callback = function(args) + if not (args.data and args.data.client_id) then + return + end + + local bufnr = args.buf + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client.name == "copilot" then + return + end + -- 绑定快捷键 + require("kide.core.keybindings").maplsp(client, bufnr, client.name == "null-ls") + end, +}) vim.api.nvim_create_augroup("LspAttach_inlay_hint", {}) vim.api.nvim_create_autocmd("LspAttach", { diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 6239e75f..784251b4 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -323,7 +323,6 @@ config["on_attach"] = function(client, buffer) require("jdtls.setup").add_commands() -- TODO: 不知道为什么这个值一会有一会没有 client.server_capabilities["definitionProvider"] = true - require("kide.core.keybindings").maplsp(client, buffer) -- require('jdtls.dap').setup_dap_main_class_configs({ verbose = true }) local opts = { silent = true, buffer = buffer } vim.keymap.set("n", "dc", jdtls.test_class, opts) diff --git a/lua/kide/plugins/config/null-ls.lua b/lua/kide/plugins/config/null-ls.lua index 02699582..aaf89820 100644 --- a/lua/kide/plugins/config/null-ls.lua +++ b/lua/kide/plugins/config/null-ls.lua @@ -128,9 +128,4 @@ end null_ls.setup({ sources = sources, - on_attach = function(client, bufnr) - require("kide.core.keybindings").maplsp(client, bufnr, true) - -- on_attach(client, bufnr) - end, - -- debug = true, }) From fa6c3e3742318bc007d3a4db65ae9e6025fb0ab7 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 29 Jun 2023 16:29:26 +0800 Subject: [PATCH 154/708] InlayHint --- lua/kide/lsp/init.lua | 6 ++++++ lua/kide/lsp/java.lua | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 072dd69f..50612e58 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -112,6 +112,12 @@ vim.api.nvim_create_autocmd("LspAttach", { local bufnr = args.buf local client = vim.lsp.get_client_by_id(args.data.client_id) + + vim.api.nvim_buf_create_user_command(bufnr, "InlayHint", function() + vim.lsp.buf.inlay_hint(0) + end, { + nargs = 0, + }) if client.server_capabilities.inlayHintProvider then vim.lsp.buf.inlay_hint(bufnr, true) end diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 784251b4..f27e8304 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -334,11 +334,6 @@ config["on_attach"] = function(client, buffer) create_command(buffer, "OR", require("jdtls").organize_imports, { nargs = 0, }) - create_command(buffer, "InlayHint", function() - vim.lsp.buf.inlay_hint(0) - end, { - nargs = 0, - }) require("java-deps").attach(client, buffer, root_dir) create_command(buffer, "JavaProjects", require("java-deps").toggle_outline, { From 568568fb8f418dac7ecaa9f534fd585e799b40d1 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 29 Jun 2023 22:51:18 +0800 Subject: [PATCH 155/708] flutter-tools config --- lua/kide/config.lua | 1 + lua/kide/plugins/config/flutter-tools.lua | 31 +++++++++++++++++++++++ lua/kide/plugins/lazy-nvim.lua | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 lua/kide/plugins/config/flutter-tools.lua diff --git a/lua/kide/config.lua b/lua/kide/config.lua index 1203525e..1d66a9ab 100644 --- a/lua/kide/config.lua +++ b/lua/kide/config.lua @@ -1,6 +1,7 @@ local M = { env = { py_bin = vim.env["PY_BIN"] or "/usr/bin/python3", + flutter_home = vim.env["FLUTTER_HOME"] or "/opt/software/flutter", }, plugin = { copilot = { diff --git a/lua/kide/plugins/config/flutter-tools.lua b/lua/kide/plugins/config/flutter-tools.lua new file mode 100644 index 00000000..c05bcfad --- /dev/null +++ b/lua/kide/plugins/config/flutter-tools.lua @@ -0,0 +1,31 @@ +local config = require("kide.config") + +require("flutter-tools").setup({ + lsp = { + color = { -- show the derived colours for dart variables + enabled = true, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10 + background = false, -- highlight the background + background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},) + foreground = false, -- highlight the foreground + virtual_text = true, -- show the highlight using virtual text + virtual_text_str = "■", -- the virtual text character to highlight + }, + flags = { + debounce_text_changes = 150, + }, + capabilities = function(c) + require("cmp_nvim_lsp").default_capabilities(c) + return c + end, + -- see the link below for details on each option: + -- https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/tool/lsp_spec/README.md#client-workspace-configuration + settings = { + showTodos = true, + completeFunctionCalls = true, + renameFilesWithClasses = "prompt", -- "always" + enableSnippets = true, + updateImportsOnRename = true, -- Whether to update imports and other directives when files are renamed. Required for `FlutterRename` command. + }, + }, +}) +require("telescope").load_extension("flutter") diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index aa8aecf3..92425e3a 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -742,7 +742,7 @@ require("lazy").setup({ "nvim-lua/plenary.nvim", }, config = function() - require("flutter-tools").setup({}) -- use defaults + require("kide.plugins.config.flutter-tools") end, }, From 7adedebdede52e0fb08127f99578b0447ad2a0b4 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 29 Jun 2023 23:25:54 +0800 Subject: [PATCH 156/708] flutter lsp config --- lua/kide/config.lua | 1 - lua/kide/core/keybindings.lua | 2 +- lua/kide/lsp/utils/init.lua | 3 +++ lua/kide/plugins/config/bufferline.lua | 7 +++++++ lua/kide/plugins/config/flutter-tools.lua | 2 -- lua/kide/plugins/config/indent-blankline.lua | 1 + lua/kide/plugins/lazy-nvim.lua | 16 ++++++++++++++++ 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lua/kide/config.lua b/lua/kide/config.lua index 1d66a9ab..1203525e 100644 --- a/lua/kide/config.lua +++ b/lua/kide/config.lua @@ -1,7 +1,6 @@ local M = { env = { py_bin = vim.env["PY_BIN"] or "/usr/bin/python3", - flutter_home = vim.env["FLUTTER_HOME"] or "/opt/software/flutter", }, plugin = { copilot = { diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 49b513e4..feb8ce77 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -50,7 +50,7 @@ M.setup = function() -- map("t", "tt", ":ToggleTerm", opt) -- symbols-outline.nvim - map("n", "o", ":SymbolsOutline", opt) + map("n", "o", ":SymbolsOutline", opt) -- Telescope map("n", "ff", "Telescope find_files", opt) diff --git a/lua/kide/lsp/utils/init.lua b/lua/kide/lsp/utils/init.lua index cfcf6832..ed72127e 100644 --- a/lua/kide/lsp/utils/init.lua +++ b/lua/kide/lsp/utils/init.lua @@ -78,6 +78,9 @@ format_lsp_mapping["python"] = "null-ls" M.filter_format_lsp_client = function(client, bufnr) local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") local cn = format_lsp_mapping[filetype] + if cn == nil then + return true + end return client.name == cn end diff --git a/lua/kide/plugins/config/bufferline.lua b/lua/kide/plugins/config/bufferline.lua index ef1c4fc6..afcdcbd5 100644 --- a/lua/kide/plugins/config/bufferline.lua +++ b/lua/kide/plugins/config/bufferline.lua @@ -50,6 +50,13 @@ require("bufferline").setup({ highlight = "Directory", text_align = "left", }, + { + filetype = "flutterToolsOutline", + text = " Outline", + padding = 1, + highlight = "Directory", + text_align = "left", + }, { filetype = "dapui_watches", text = "Debug", diff --git a/lua/kide/plugins/config/flutter-tools.lua b/lua/kide/plugins/config/flutter-tools.lua index c05bcfad..404f2d2c 100644 --- a/lua/kide/plugins/config/flutter-tools.lua +++ b/lua/kide/plugins/config/flutter-tools.lua @@ -1,5 +1,3 @@ -local config = require("kide.config") - require("flutter-tools").setup({ lsp = { color = { -- show the derived colours for dart variables diff --git a/lua/kide/plugins/config/indent-blankline.lua b/lua/kide/plugins/config/indent-blankline.lua index 10edd347..3bd06dad 100644 --- a/lua/kide/plugins/config/indent-blankline.lua +++ b/lua/kide/plugins/config/indent-blankline.lua @@ -20,6 +20,7 @@ require("indent_blankline").setup({ "dashboard", "alpha", "Outline", + "flutterToolsOutline", "TelescopePrompt", "TelescopeResults", "NeogitStatus", diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 92425e3a..3b5df294 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -738,6 +738,22 @@ require("lazy").setup({ "akinsho/flutter-tools.nvim", lazy = true, ft = { "dart" }, + init = function() + vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("kide_FlutterOutlineToggle", { clear = true }), + pattern = "dart", + callback = function(event) + vim.keymap.set("n", "o", "FlutterOutlineToggle", { buffer = event.buf, silent = true }) + end, + }) + vim.api.nvim_create_autocmd("BufNewFile", { + group = vim.api.nvim_create_augroup("kide__FlutterOutlineToggle", { clear = true }), + pattern = "Flutter Outline", + callback = function(event) + vim.keymap.set("n", "o", "FlutterOutlineToggle", { buffer = event.buf, silent = true }) + end, + }) + end, dependencies = { "nvim-lua/plenary.nvim", }, From a7b1a9f0bf4dff3777b36e58217b8bb35cf63ac1 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 30 Jun 2023 09:32:11 +0800 Subject: [PATCH 157/708] =?UTF-8?q?=E6=8C=89=E9=9C=80=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/nvim-treesitter.lua | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lua/kide/plugins/config/nvim-treesitter.lua b/lua/kide/plugins/config/nvim-treesitter.lua index d11d7285..96153326 100644 --- a/lua/kide/plugins/config/nvim-treesitter.lua +++ b/lua/kide/plugins/config/nvim-treesitter.lua @@ -1,17 +1,8 @@ require("nvim-treesitter.configs").setup({ -- One of "all", "maintained" (parsers with maintainers), or a list of languages ensure_installed = { - "lua", - "java", - "javascript", - "typescript", "html", "css", - "c", - "cpp", - "go", - "rust", - "python", "vim", "yaml", "http", @@ -19,8 +10,6 @@ require("nvim-treesitter.configs").setup({ "markdown", "org", "norg", - "kotlin", - "vue", }, -- Install languages synchronously (only applied to `ensure_installed`) From cfc99613ddb8ea2f66847024009047b37a3f69f2 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 30 Jun 2023 10:26:34 +0800 Subject: [PATCH 158/708] dart --- lua/kide/core/basic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 5eb814e3..62512cd0 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -70,6 +70,7 @@ autocmd("FileType", { "markdown", "lisp", "sh", + "dart", }, callback = function() vim.opt_local.tabstop = 2 @@ -206,7 +207,6 @@ autocmd({ "BufReadCmd" }, { end, }) - autocmd("FileType", { group = augroup("gitcommit"), pattern = { "gitcommit" }, From 8bbc0547632000ddf5f31ebe93d7f2cafae24984 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 2 Jul 2023 12:46:37 +0800 Subject: [PATCH 159/708] LOMBOK_JAR --- lua/kide/lsp/java.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index f27e8304..a6a55c0d 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -110,6 +110,12 @@ local function jdtls_launcher() vim.notify("jdtls_path is empty", vim.log.levels.ERROR) return end + + local lombok_jar = env.LOMBOK_JAR + if not lombok_jar and require("mason-registry").has_package("jdtls") then + lombok_jar = require("mason-registry").get_package("jdtls"):get_install_path() .. "/lombok.jar" + end + local cmd = { jdtls_path, "--jvm-arg=-Dlog.protocol=true", @@ -118,8 +124,8 @@ local function jdtls_launcher() "--jvm-arg=" .. "-XX:+UseZGC", "--jvm-arg=" .. "-Xmx1g", } - if env.LOMBOK_JAR then - table.insert(cmd, "--jvm-arg=-javaagent:" .. env.LOMBOK_JAR) + if lombok_jar then + table.insert(cmd, "--jvm-arg=-javaagent:" .. lombok_jar) end table.insert(cmd, "-data=" .. workspace_dir) return cmd From 90279a873a74fe9b30fdd3d92744e6f77a2819db Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 2 Jul 2023 18:58:16 +0800 Subject: [PATCH 160/708] neovim-nightly --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82ac8a78..6ade1277 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 可配置 `Java`, `Rust`, `C/C++`, `JavaScript` 等编程语言开发环境。 极速启动 (`startuptime` 20 ~ 70 ms)。 -使用 `neovim v0.9.0`+ 版本。 +使用 `neovim-nightly` 版本。 ## 安装 From 1aff02fb612fb6365d39affd04148ae643a9566b Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 2 Jul 2023 19:12:26 +0800 Subject: [PATCH 161/708] =?UTF-8?q?lombok=20jar=20=E6=97=A0=E9=A1=BB?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/java.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index a6a55c0d..9b58ea95 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -5,7 +5,7 @@ local env = { JDTLS_RUN_JAVA = vim.env["JDTLS_RUN_JAVA"], JDTLS_HOME = vim.env["JDTLS_HOME"], JDTLS_WORKSPACE = vim.env["JDTLS_WORKSPACE"], - LOMBOK_JAR = vim.env["LOMBOK_JAR"], + LOMBOK_ENABLE = vim.env["LOMBOK_ENABLE"] or "Y", JOL_JAR = vim.env["JOL_JAR"], } local maven = require("kide.core.utils.maven") @@ -111,9 +111,12 @@ local function jdtls_launcher() return end - local lombok_jar = env.LOMBOK_JAR - if not lombok_jar and require("mason-registry").has_package("jdtls") then - lombok_jar = require("mason-registry").get_package("jdtls"):get_install_path() .. "/lombok.jar" + local lombok_jar = nil + if env.LOMBOK_ENABLE == "Y" then + lombok_jar = vscode.find_one("/redhat.java-*/lombok/lombok-*.jar") + if lombok_jar == nil and require("mason-registry").has_package("jdtls") then + lombok_jar = require("mason-registry").get_package("jdtls"):get_install_path() .. "/lombok.jar" + end end local cmd = { @@ -124,7 +127,7 @@ local function jdtls_launcher() "--jvm-arg=" .. "-XX:+UseZGC", "--jvm-arg=" .. "-Xmx1g", } - if lombok_jar then + if lombok_jar ~= nil then table.insert(cmd, "--jvm-arg=-javaagent:" .. lombok_jar) end table.insert(cmd, "-data=" .. workspace_dir) From 208b18faa9ca39d3a0b176ad911e8e47ac941f25 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 3 Jul 2023 09:27:58 +0800 Subject: [PATCH 162/708] inlay_hint --- lua/kide/lsp/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 50612e58..93c15c15 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -114,12 +114,12 @@ vim.api.nvim_create_autocmd("LspAttach", { local client = vim.lsp.get_client_by_id(args.data.client_id) vim.api.nvim_buf_create_user_command(bufnr, "InlayHint", function() - vim.lsp.buf.inlay_hint(0) + vim.lsp.inlay_hint(0) end, { nargs = 0, }) if client.server_capabilities.inlayHintProvider then - vim.lsp.buf.inlay_hint(bufnr, true) + vim.lsp.inlay_hint(bufnr, true) end end, }) From e548ee0f799175b4060d6babe8c7b6f1b7a24606 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 3 Jul 2023 09:29:45 +0800 Subject: [PATCH 163/708] neogit --- lua/kide/plugins/lazy-nvim.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 3b5df294..c90ef25b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -314,7 +314,7 @@ require("lazy").setup({ end, }, { - "TimUntersberger/neogit", + "NeogitOrg/neogit", layz = true, cmd = "Neogit", dependencies = { "sindrets/diffview.nvim" }, From 7f9dce2ade38ce51daea381db20e27f58a602808 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 4 Jul 2023 23:00:46 +0800 Subject: [PATCH 164/708] jdt:// buffer_previewer --- lua/kide/plugins/config/telescope.lua | 3 + .../config/telescope/buffer_previewer.lua | 1197 +++++++++++++++++ lua/kide/plugins/lazy-nvim.lua | 1 - 3 files changed, 1200 insertions(+), 1 deletion(-) create mode 100644 lua/kide/plugins/config/telescope/buffer_previewer.lua diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index 3515c24f..ad399dba 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -68,6 +68,9 @@ set.edit = function(prompt_bufnr, command) end end +local previewers = require("telescope.previewers") +previewers.buffer_previewer_maker = require("kide.plugins.config.telescope.buffer_previewer").file_maker + telescope.setup({ defaults = { vimgrep_arguments = { diff --git a/lua/kide/plugins/config/telescope/buffer_previewer.lua b/lua/kide/plugins/config/telescope/buffer_previewer.lua new file mode 100644 index 00000000..3775404f --- /dev/null +++ b/lua/kide/plugins/config/telescope/buffer_previewer.lua @@ -0,0 +1,1197 @@ +local from_entry = require "telescope.from_entry" +local Path = require "plenary.path" +local utils = require "telescope.utils" +local putils = require "telescope.previewers.utils" +local Previewer = require "telescope.previewers.previewer" +local conf = require("telescope.config").values + +local pscan = require "plenary.scandir" + +local buf_delete = utils.buf_delete + +local previewers = {} + +local ns_previewer = vim.api.nvim_create_namespace "telescope.previewers" + +local has_file = 1 == vim.fn.executable "file" + +-- TODO(fdschmidt93) switch to Job once file_maker callbacks get cleaned up with plenary async +-- avoids SIGABRT from utils.get_os_command_output due to vim.time in fs_stat cb +local function capture(cmd, raw) + local f = assert(io.popen(cmd, "r")) + local s = assert(f:read "*a") + f:close() + if raw then + return s + end + s = string.gsub(s, "^%s+", "") + s = string.gsub(s, "%s+$", "") + s = string.gsub(s, "[\n\r]+", " ") + return s +end + +local function defaulter(f, default_opts) + default_opts = default_opts or {} + return { + new = function(opts) + if conf.preview == false and not opts.preview then + return false + end + opts.preview = type(opts.preview) ~= "table" and {} or opts.preview + if type(conf.preview) == "table" then + for k, v in pairs(conf.preview) do + opts.preview[k] = vim.F.if_nil(opts.preview[k], v) + end + end + return f(opts) + end, + __call = function() + local ok, err = pcall(f(default_opts)) + if not ok then + error(debug.traceback(err)) + end + end, + } +end + +-- modified vim.split to incorporate a timer +local function split(s, sep, plain, opts) + opts = opts or {} + local t = {} + for c in vim.gsplit(s, sep, plain) do + local line = opts.file_encoding and vim.iconv(c, opts.file_encoding, "utf8") or c + table.insert(t, line) + if opts.preview.timeout then + local diff_time = (vim.loop.hrtime() - opts.start_time) / 1e6 + if diff_time > opts.preview.timeout then + return + end + end + end + return t +end +local bytes_to_megabytes = math.pow(1024, 2) + +local color_hash = { + ["p"] = "TelescopePreviewPipe", + ["c"] = "TelescopePreviewCharDev", + ["d"] = "TelescopePreviewDirectory", + ["b"] = "TelescopePreviewBlock", + ["l"] = "TelescopePreviewLink", + ["s"] = "TelescopePreviewSocket", + ["."] = "TelescopePreviewNormal", + ["r"] = "TelescopePreviewRead", + ["w"] = "TelescopePreviewWrite", + ["x"] = "TelescopePreviewExecute", + ["-"] = "TelescopePreviewHyphen", + ["T"] = "TelescopePreviewSticky", + ["S"] = "TelescopePreviewSticky", + [2] = "TelescopePreviewSize", + [3] = "TelescopePreviewUser", + [4] = "TelescopePreviewGroup", + [5] = "TelescopePreviewDate", +} +color_hash[6] = function(line) + return color_hash[line:sub(1, 1)] +end + +local colorize_ls_long = function(bufnr, data, sections) + local windows_add = Path.path.sep == "\\" and 2 or 0 + for lnum, line in ipairs(data) do + local section = sections[lnum] + for i = 1, section[1].end_index - 1 do -- Highlight permissions + local c = line:sub(i, i) + vim.api.nvim_buf_add_highlight(bufnr, ns_previewer, color_hash[c], lnum - 1, i - 1, i) + end + for i = 2, #section do -- highlights size, (user, group), date and name + local hl_group = color_hash[i + (i ~= 2 and windows_add or 0)] + vim.api.nvim_buf_add_highlight( + bufnr, + ns_previewer, + type(hl_group) == "function" and hl_group(line) or hl_group, + lnum - 1, + section[i].start_index - 1, + section[i].end_index - 1 + ) + end + end +end + +local handle_directory_preview = function(filepath, bufnr, opts) + opts.preview.ls_short = vim.F.if_nil(opts.preview.ls_short, false) + + local set_colorize_lines + if opts.preview.ls_short then + set_colorize_lines = function(data, sections) + local PATH_SECTION = Path.path.sep == "\\" and 4 or 6 + local paths = {} + for i, line in ipairs(data) do + local section = sections[i][PATH_SECTION] + local path = line:sub(section.start_index, section.end_index) + table.insert(paths, path) + end + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, paths) + for i, path in ipairs(paths) do + local hl = color_hash[6](data[i]) + vim.api.nvim_buf_add_highlight(bufnr, ns_previewer, hl, i - 1, 0, #path) + end + end + else + set_colorize_lines = function(data, sections) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, data) + colorize_ls_long(bufnr, data, sections) + end + end + + pscan.ls_async(filepath, { + hidden = true, + group_directories_first = true, + on_exit = vim.schedule_wrap(function(data, sections) + set_colorize_lines(data, sections) + if opts.callback then + opts.callback(bufnr) + end + end), + }) +end + +local handle_file_preview = function(filepath, bufnr, stat, opts) + vim.schedule(function() + opts.ft = opts.use_ft_detect and putils.filetype_detect(filepath) + local possible_binary = false + if type(opts.preview.filetype_hook) == "function" and opts.ft ~= nil and opts.ft ~= "" then + if not opts.preview.filetype_hook(filepath, bufnr, opts) then + return + end + end + if opts.preview.check_mime_type == true and has_file and (opts.ft == nil or opts.ft == "") then + -- avoid SIGABRT in buffer previewer happening with utils.get_os_command_output + local output = capture(string.format([[file --mime-type -b "%s"]], filepath)) + local mime_type = vim.split(output, "/") + if mime_type[1] ~= "text" and mime_type[1] ~= "inode" and mime_type[2] ~= "json" then + if type(opts.preview.mime_hook) == "function" then + opts.preview.mime_hook(filepath, bufnr, opts) + return + else + possible_binary = true + end + end + if mime_type[2] == "json" then + opts.ft = "json" + end + end + + if opts.preview.filesize_limit then + local mb_filesize = math.floor(stat.size / bytes_to_megabytes) + if mb_filesize > opts.preview.filesize_limit then + if type(opts.preview.filesize_hook) == "function" then + opts.preview.filesize_hook(filepath, bufnr, opts) + else + putils.set_preview_message(bufnr, opts.winid, "File exceeds preview size limit", opts.preview.msg_bg_fillchar) + end + return + end + end + + opts.start_time = vim.loop.hrtime() + Path:new(filepath):_read_async(vim.schedule_wrap(function(data) + if not vim.api.nvim_buf_is_valid(bufnr) then + return + end + local processed_data = split(data, "[\r]?\n", nil, opts) + + if processed_data then + local ok = pcall(vim.api.nvim_buf_set_lines, bufnr, 0, -1, false, processed_data) + if not ok then + return + end + -- last resort, if ft is still empty at this point in time, + -- we need to determine the filetype using the buffer contents + if opts.ft == nil or opts.ft == "" then + opts.ft = vim.filetype.match { filename = filepath, buf = bufnr } + end + -- we need to attempt to call filetype hook at this point "again" + -- previously only if we had a valid filetype, now every time + -- also if there will never be a filetype + if type(opts.preview.filetype_hook) == "function" then + if not opts.preview.filetype_hook(filepath, bufnr, opts) then + return + end + end + -- if we still dont have a ft we need to display the binary message + if (opts.ft == nil or opts.ft == "") and possible_binary then + putils.set_preview_message(bufnr, opts.winid, "Binary cannot be previewed", opts.preview.msg_bg_fillchar) + return + end + + if opts.callback then + opts.callback(bufnr) + end + putils.highlighter(bufnr, opts.ft, opts) + else + if type(opts.preview.timeout_hook) == "function" then + opts.preview.timeout_hook(filepath, bufnr, opts) + else + putils.set_preview_message(bufnr, opts.winid, "Previewer timed out", opts.preview.msg_bg_fillchar) + end + return + end + end)) + end) +end + +local PREVIEW_TIMEOUT_MS = 250 +local PREVIEW_FILESIZE_MB = 25 + +previewers.file_maker = function(filepath, bufnr, opts) + opts = vim.F.if_nil(opts, {}) + opts.preview = vim.F.if_nil(opts.preview, {}) + opts.preview.timeout = vim.F.if_nil(opts.preview.timeout, PREVIEW_TIMEOUT_MS) + opts.preview.filesize_limit = vim.F.if_nil(opts.preview.filesize_limit, PREVIEW_FILESIZE_MB) + opts.preview.msg_bg_fillchar = vim.F.if_nil(opts.preview.msg_bg_fillchar, "╱") + opts.preview.treesitter = vim.F.if_nil(opts.preview.treesitter, true) + if opts.use_ft_detect == nil then + opts.use_ft_detect = true + end + if opts.bufname ~= filepath then + if not vim.in_fast_event() then + filepath = vim.fn.expand(filepath) + end + -- jdt:// path is a special case, we need to call the filetype hook + if vim.startswith(filepath, "jdt://") and type(opts.preview.filetype_hook) == "function" then + if not opts.preview.filetype_hook(filepath, bufnr, opts) then + return + end + end + + vim.uv.fs_stat(filepath, function(_, stat) + if not stat then + return + end + if stat.type == "directory" then + handle_directory_preview(filepath, bufnr, opts) + else + handle_file_preview(filepath, bufnr, stat, opts) + end + end) + else + if opts.callback then + if vim.in_fast_event() then + vim.schedule(function() + opts.callback(bufnr) + end) + else + opts.callback(bufnr) + end + end + end +end + +local search_cb_jump = function(self, bufnr, query) + if not query then + return + end + vim.api.nvim_buf_call(bufnr, function() + pcall(vim.fn.matchdelete, self.state.hl_id, self.state.winid) + vim.cmd "norm! gg" + vim.fn.search(query, "W") + vim.cmd "norm! zz" + + self.state.hl_id = vim.fn.matchadd("TelescopePreviewMatch", query) + end) +end + +local search_teardown = function(self) + if self.state and self.state.hl_id then + pcall(vim.fn.matchdelete, self.state.hl_id, self.state.hl_win) + self.state.hl_id = nil + end +end + +local scroll_fn = function(self, direction) + if not self.state then + return + end + + local input = direction > 0 and [[]] or [[]] + local count = math.abs(direction) + + vim.api.nvim_win_call(self.state.winid, function() + vim.cmd([[normal! ]] .. count .. input) + end) +end + +local scroll_horizontal_fn = function(self, direction) + if not self.state then + return + end + + local input = direction > 0 and [[zl]] or [[zh]] + local count = math.abs(direction) + + vim.api.nvim_win_call(self.state.winid, function() + vim.cmd([[normal! ]] .. count .. input) + end) +end + +previewers.new_buffer_previewer = function(opts) + opts = opts or {} + + assert(opts.define_preview, "define_preview is a required function") + assert(not opts.preview_fn, "preview_fn not allowed") + + local opt_setup = opts.setup + local opt_teardown = opts.teardown + + local old_bufs = {} + local bufname_table = {} + + local global_state = require "telescope.state" + local preview_window_id + + local function get_bufnr(self) + if not self.state then + return nil + end + return self.state.bufnr + end + + local function set_bufnr(self, value) + if self.state then + self.state.bufnr = value + table.insert(old_bufs, value) + end + end + + local function get_bufnr_by_bufname(self, value) + if not self.state then + return nil + end + return bufname_table[value] + end + + local function set_bufname(self, value) + if self.state then + self.state.bufname = value + if value then + bufname_table[value] = get_bufnr(self) + end + end + end + + function opts.setup(self) + local state = {} + if opt_setup then + vim.tbl_deep_extend("force", state, opt_setup(self)) + end + return state + end + + function opts.teardown(self) + if opt_teardown then + opt_teardown(self) + end + + local last_nr + if opts.keep_last_buf then + last_nr = global_state.get_global_key "last_preview_bufnr" + -- Push in another buffer so the last one will not be cleaned up + if preview_window_id then + local bufnr = vim.api.nvim_create_buf(false, true) + utils.win_set_buf_noautocmd(preview_window_id, bufnr) + end + end + + set_bufnr(self, nil) + set_bufname(self, nil) + + for _, bufnr in ipairs(old_bufs) do + if bufnr ~= last_nr then + buf_delete(bufnr) + end + end + -- enable resuming picker with existing previewer to avoid lookup of deleted bufs + bufname_table = {} + end + + function opts.preview_fn(self, entry, status) + if get_bufnr(self) == nil then + set_bufnr(self, vim.api.nvim_win_get_buf(status.preview_win)) + preview_window_id = status.preview_win + end + + if opts.get_buffer_by_name and get_bufnr_by_bufname(self, opts.get_buffer_by_name(self, entry)) then + self.state.bufname = opts.get_buffer_by_name(self, entry) + self.state.bufnr = get_bufnr_by_bufname(self, self.state.bufname) + utils.win_set_buf_noautocmd(status.preview_win, self.state.bufnr) + else + local bufnr = vim.api.nvim_create_buf(false, true) + set_bufnr(self, bufnr) + + vim.schedule(function() + if vim.api.nvim_buf_is_valid(bufnr) then + utils.win_set_buf_noautocmd(status.preview_win, bufnr) + end + end) + + vim.api.nvim_win_set_option(status.preview_win, "winhl", "Normal:TelescopePreviewNormal") + vim.api.nvim_win_set_option(status.preview_win, "signcolumn", "no") + vim.api.nvim_win_set_option(status.preview_win, "foldlevel", 100) + vim.api.nvim_win_set_option(status.preview_win, "wrap", false) + vim.api.nvim_win_set_option(status.preview_win, "scrollbind", false) + + self.state.winid = status.preview_win + self.state.bufname = nil + end + + if opts.keep_last_buf then + global_state.set_global_key("last_preview_bufnr", self.state.bufnr) + end + + opts.define_preview(self, entry, status) + + vim.schedule(function() + if not self or not self.state or not self.state.bufnr then + return + end + + if vim.api.nvim_buf_is_valid(self.state.bufnr) then + vim.api.nvim_buf_call(self.state.bufnr, function() + vim.api.nvim_exec_autocmds("User", { + pattern = "TelescopePreviewerLoaded", + data = { + title = entry.preview_title, + bufname = self.state.bufname, + filetype = putils.filetype_detect(self.state.bufname or ""), + }, + }) + end) + end + end) + + if opts.get_buffer_by_name then + set_bufname(self, opts.get_buffer_by_name(self, entry)) + end + end + + if not opts.scroll_fn then + opts.scroll_fn = scroll_fn + end + + if not opts.scroll_horizontal_fn then + opts.scroll_horizontal_fn = scroll_horizontal_fn + end + + return Previewer:new(opts) +end + +previewers.cat = defaulter(function(opts) + opts = opts or {} + local cwd = opts.cwd or vim.loop.cwd() + return previewers.new_buffer_previewer { + title = "File Preview", + dyn_title = function(_, entry) + return Path:new(from_entry.path(entry, false, false)):normalize(cwd) + end, + + get_buffer_by_name = function(_, entry) + return from_entry.path(entry, false) + end, + + define_preview = function(self, entry) + local p = from_entry.path(entry, true) + if p == nil or p == "" then + return + end + conf.buffer_previewer_maker(p, self.state.bufnr, { + bufname = self.state.bufname, + winid = self.state.winid, + preview = opts.preview, + file_encoding = opts.file_encoding, + }) + end, + } +end, {}) + +previewers.vimgrep = defaulter(function(opts) + opts = opts or {} + local cwd = opts.cwd or vim.loop.cwd() + + local jump_to_line = function(self, bufnr, lnum) + pcall(vim.api.nvim_buf_clear_namespace, bufnr, ns_previewer, 0, -1) + if lnum and lnum > 0 then + pcall(vim.api.nvim_buf_add_highlight, bufnr, ns_previewer, "TelescopePreviewLine", lnum - 1, 0, -1) + pcall(vim.api.nvim_win_set_cursor, self.state.winid, { lnum, 0 }) + vim.api.nvim_buf_call(bufnr, function() + vim.cmd "norm! zz" + end) + end + end + + return previewers.new_buffer_previewer { + title = "Grep Preview", + dyn_title = function(_, entry) + return Path:new(from_entry.path(entry, false, false)):normalize(cwd) + end, + + get_buffer_by_name = function(_, entry) + return from_entry.path(entry, false) + end, + + define_preview = function(self, entry) + -- builtin.buffers: bypass path validation for terminal buffers that don't have appropriate path + local has_buftype = entry.bufnr and vim.api.nvim_buf_get_option(entry.bufnr, "buftype") ~= "" or false + local p + if not has_buftype then + p = from_entry.path(entry, true) + if p == nil or p == "" then + return + end + end + + -- Workaround for unnamed buffer when using builtin.buffer + if entry.bufnr and (p == "[No Name]" or has_buftype) then + local lines = vim.api.nvim_buf_get_lines(entry.bufnr, 0, -1, false) + vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines) + jump_to_line(self, self.state.bufnr, entry.lnum) + else + conf.buffer_previewer_maker(p, self.state.bufnr, { + bufname = self.state.bufname, + winid = self.state.winid, + preview = opts.preview, + callback = function(bufnr) + jump_to_line(self, bufnr, entry.lnum) + end, + file_encoding = opts.file_encoding, + }) + end + end, + } +end, {}) + +previewers.qflist = previewers.vimgrep + +previewers.ctags = defaulter(function(_) + local determine_jump = function(entry) + if entry.scode then + return function(self) + -- un-escape / then escape required + -- special chars for vim.fn.search() + -- ] ~ * + local scode = entry.scode:gsub([[\/]], "/"):gsub("[%]~*]", function(x) + return "\\" .. x + end) + + pcall(vim.fn.matchdelete, self.state.hl_id, self.state.winid) + vim.cmd "norm! gg" + vim.fn.search(scode, "W") + vim.cmd "norm! zz" + + self.state.hl_id = vim.fn.matchadd("TelescopePreviewMatch", scode) + end + else + return function(self, bufnr) + if self.state.last_set_bufnr then + pcall(vim.api.nvim_buf_clear_namespace, self.state.last_set_bufnr, ns_previewer, 0, -1) + end + pcall(vim.api.nvim_buf_add_highlight, bufnr, ns_previewer, "TelescopePreviewMatch", entry.lnum - 1, 0, -1) + pcall(vim.api.nvim_win_set_cursor, self.state.winid, { entry.lnum, 0 }) + self.state.last_set_bufnr = bufnr + end + end + end + + return previewers.new_buffer_previewer { + title = "Tags Preview", + teardown = function(self) + if self.state and self.state.hl_id then + pcall(vim.fn.matchdelete, self.state.hl_id, self.state.hl_win) + self.state.hl_id = nil + elseif self.state and self.state.last_set_bufnr and vim.api.nvim_buf_is_valid(self.state.last_set_bufnr) then + vim.api.nvim_buf_clear_namespace(self.state.last_set_bufnr, ns_previewer, 0, -1) + end + end, + + get_buffer_by_name = function(_, entry) + return entry.filename + end, + + define_preview = function(self, entry) + conf.buffer_previewer_maker(entry.filename, self.state.bufnr, { + bufname = self.state.bufname, + winid = self.state.winid, + callback = function(bufnr) + pcall(vim.api.nvim_buf_call, bufnr, function() + determine_jump(entry)(self, bufnr) + end) + end, + }) + end, + } +end, {}) + +previewers.builtin = defaulter(function(_) + return previewers.new_buffer_previewer { + title = "Grep Preview", + teardown = search_teardown, + + get_buffer_by_name = function(_, entry) + return entry.filename + end, + + define_preview = function(self, entry) + local module_name = vim.fn.fnamemodify(vim.fn.fnamemodify(entry.filename, ":h"), ":t") + local text + if entry.text:sub(1, #module_name) ~= module_name then + text = module_name .. "." .. entry.text + else + text = entry.text:gsub("_", ".", 1) + end + + conf.buffer_previewer_maker(entry.filename, self.state.bufnr, { + bufname = self.state.bufname, + winid = self.state.winid, + callback = function(bufnr) + search_cb_jump(self, bufnr, text) + end, + }) + end, + } +end, {}) + +previewers.help = defaulter(function(_) + return previewers.new_buffer_previewer { + title = "Help Preview", + teardown = search_teardown, + + get_buffer_by_name = function(_, entry) + return entry.filename + end, + + define_preview = function(self, entry) + local query = entry.cmd + query = query:sub(2) + query = [[\V]] .. query + + conf.buffer_previewer_maker(entry.filename, self.state.bufnr, { + bufname = self.state.bufname, + winid = self.state.winid, + callback = function(bufnr) + putils.regex_highlighter(bufnr, "help") + search_cb_jump(self, bufnr, query) + end, + }) + end, + } +end, {}) + +previewers.man = defaulter(function(opts) + local pager = utils.get_lazy_default(opts.PAGER, function() + return vim.fn.executable "col" == 1 and { "col", "-bx" } or { "cat" } + end) + return previewers.new_buffer_previewer { + title = "Man Preview", + get_buffer_by_name = function(_, entry) + return entry.value .. "/" .. entry.section + end, + + define_preview = function(self, entry) + local win_width = vim.api.nvim_win_get_width(self.state.winid) + putils.job_maker(vim.deepcopy(pager), self.state.bufnr, { + writer = { "man", entry.section, entry.value }, + env = { ["MANWIDTH"] = win_width, PATH = vim.env.PATH, MANPATH = vim.env.MANPATH }, + value = entry.value .. "/" .. entry.section, + bufname = self.state.bufname, + }) + putils.regex_highlighter(self.state.bufnr, "man") + end, + } +end) + +previewers.git_branch_log = defaulter(function(opts) + local highlight_buffer = function(bufnr, content) + for i = 1, #content do + local line = content[i] + local _, hstart = line:find "[%*%s|]*" + if hstart then + local hend = hstart + 7 + if hend < #line then + pcall( + vim.api.nvim_buf_add_highlight, + bufnr, + ns_previewer, + "TelescopeResultsIdentifier", + i - 1, + hstart - 1, + hend + ) + end + end + local _, cstart = line:find "- %(" + if cstart then + local cend = string.find(line, "%) ") + if cend then + pcall( + vim.api.nvim_buf_add_highlight, + bufnr, + ns_previewer, + "TelescopeResultsConstant", + i - 1, + cstart - 1, + cend + ) + end + end + local dstart, _ = line:find " %(%d" + if dstart then + pcall( + vim.api.nvim_buf_add_highlight, + bufnr, + ns_previewer, + "TelescopeResultsSpecialComment", + i - 1, + dstart, + #line + ) + end + end + end + + return previewers.new_buffer_previewer { + title = "Git Branch Preview", + get_buffer_by_name = function(_, entry) + return entry.value + end, + + define_preview = function(self, entry) + local cmd = { + "git", + "--no-pager", + "log", + "--graph", + "--pretty=format:%h -%d %s (%cr)", + "--abbrev-commit", + "--date=relative", + entry.value, + } + + putils.job_maker(cmd, self.state.bufnr, { + value = entry.value, + bufname = self.state.bufname, + cwd = opts.cwd, + callback = function(bufnr, content) + if not content then + return + end + highlight_buffer(bufnr, content) + end, + }) + end, + } +end, {}) + +previewers.git_stash_diff = defaulter(function(opts) + return previewers.new_buffer_previewer { + title = "Git Stash Preview", + get_buffer_by_name = function(_, entry) + return entry.value + end, + + define_preview = function(self, entry, _) + putils.job_maker({ "git", "--no-pager", "stash", "show", "-p", entry.value }, self.state.bufnr, { + value = entry.value, + bufname = self.state.bufname, + cwd = opts.cwd, + callback = function(bufnr) + if vim.api.nvim_buf_is_valid(bufnr) then + putils.regex_highlighter(bufnr, "diff") + end + end, + }) + end, + } +end, {}) + +previewers.git_commit_diff_to_parent = defaulter(function(opts) + return previewers.new_buffer_previewer { + title = "Git Diff to Parent Preview", + teardown = search_teardown, + get_buffer_by_name = function(_, entry) + return entry.value + end, + + define_preview = function(self, entry) + local cmd = { "git", "--no-pager", "diff", entry.value .. "^!" } + if opts.current_file then + table.insert(cmd, "--") + table.insert(cmd, opts.current_file) + end + + putils.job_maker(cmd, self.state.bufnr, { + value = entry.value, + bufname = self.state.bufname, + cwd = opts.cwd, + callback = function(bufnr) + if vim.api.nvim_buf_is_valid(bufnr) then + search_cb_jump(self, bufnr, opts.current_line) + putils.regex_highlighter(bufnr, "diff") + end + end, + }) + end, + } +end, {}) + +previewers.git_commit_diff_to_head = defaulter(function(opts) + return previewers.new_buffer_previewer { + title = "Git Diff to Head Preview", + teardown = search_teardown, + + get_buffer_by_name = function(_, entry) + return entry.value + end, + + define_preview = function(self, entry) + local cmd = { "git", "--no-pager", "diff", "--cached", entry.value } + if opts.current_file then + table.insert(cmd, "--") + table.insert(cmd, opts.current_file) + end + + putils.job_maker(cmd, self.state.bufnr, { + value = entry.value, + bufname = self.state.bufname, + cwd = opts.cwd, + callback = function(bufnr) + if vim.api.nvim_buf_is_valid(bufnr) then + search_cb_jump(self, bufnr, opts.current_line) + putils.regex_highlighter(bufnr, "diff") + end + end, + }) + end, + } +end, {}) + +previewers.git_commit_diff_as_was = defaulter(function(opts) + return previewers.new_buffer_previewer { + title = "Git Show Preview", + teardown = search_teardown, + + get_buffer_by_name = function(_, entry) + return entry.value + end, + + define_preview = function(self, entry) + local cmd = { "git", "--no-pager", "show" } + local cf = opts.current_file and Path:new(opts.current_file):make_relative(opts.cwd) + local value = cf and (entry.value .. ":" .. cf) or entry.value + local ft = cf and putils.filetype_detect(value) or "diff" + table.insert(cmd, value) + + putils.job_maker(cmd, self.state.bufnr, { + value = entry.value, + bufname = self.state.bufname, + cwd = opts.cwd, + callback = function(bufnr) + if vim.api.nvim_buf_is_valid(bufnr) then + search_cb_jump(self, bufnr, opts.current_line) + putils.regex_highlighter(bufnr, ft) + end + end, + }) + end, + } +end, {}) + +previewers.git_commit_message = defaulter(function(opts) + local hl_map = { + "TelescopeResultsIdentifier", + "TelescopePreviewUser", + "TelescopePreviewDate", + } + return previewers.new_buffer_previewer { + title = "Git Message", + get_buffer_by_name = function(_, entry) + return entry.value + end, + + define_preview = function(self, entry) + local cmd = { "git", "--no-pager", "log", "-n 1", entry.value } + + putils.job_maker(cmd, self.state.bufnr, { + value = entry.value, + bufname = self.state.bufname, + cwd = opts.cwd, + callback = function(bufnr, content) + if not content then + return + end + for k, v in ipairs(hl_map) do + local _, s = content[k]:find "%s" + if s then + vim.api.nvim_buf_add_highlight(bufnr, ns_previewer, v, k - 1, s, #content[k]) + end + end + end, + }) + end, + } +end, {}) + +previewers.git_file_diff = defaulter(function(opts) + return previewers.new_buffer_previewer { + title = "Git File Diff Preview", + get_buffer_by_name = function(_, entry) + return entry.value + end, + + define_preview = function(self, entry) + if entry.status and (entry.status == "??" or entry.status == "A ") then + local p = from_entry.path(entry, true) + if p == nil or p == "" then + return + end + conf.buffer_previewer_maker(p, self.state.bufnr, { + bufname = self.state.bufname, + winid = self.state.winid, + }) + else + putils.job_maker({ "git", "--no-pager", "diff", "HEAD", "--", entry.value }, self.state.bufnr, { + value = entry.value, + bufname = self.state.bufname, + cwd = opts.cwd, + callback = function(bufnr) + if vim.api.nvim_buf_is_valid(bufnr) then + putils.regex_highlighter(bufnr, "diff") + end + end, + }) + end + end, + } +end, {}) + +previewers.autocommands = defaulter(function(_) + return previewers.new_buffer_previewer { + title = "Autocommands Preview", + teardown = function(self) + if self.state and self.state.last_set_bufnr and vim.api.nvim_buf_is_valid(self.state.last_set_bufnr) then + pcall(vim.api.nvim_buf_clear_namespace, self.state.last_set_bufnr, ns_previewer, 0, -1) + end + end, + + get_buffer_by_name = function(_, entry) + return entry.value.group_name + end, + + define_preview = function(self, entry, status) + local results = vim.tbl_filter(function(x) + return x.value.group_name == entry.value.group_name + end, status.picker.finder.results) + + if self.state.last_set_bufnr then + pcall(vim.api.nvim_buf_clear_namespace, self.state.last_set_bufnr, ns_previewer, 0, -1) + end + + local selected_row = 0 + if self.state.bufname ~= entry.value.group_name then + local display = {} + table.insert(display, string.format(" augroup: %s - [ %d entries ]", entry.value.group_name, #results)) + -- TODO: calculate banner width/string in setup() + -- TODO: get column characters to be the same HL group as border + table.insert(display, string.rep("─", vim.fn.getwininfo(status.preview_win)[1].width)) + + for idx, item in ipairs(results) do + if item == entry then + selected_row = idx + end + table.insert( + display, + string.format(" %-14s▏%-08s %s", item.value.event, item.value.pattern, item.value.command) + ) + end + + vim.api.nvim_buf_set_option(self.state.bufnr, "filetype", "vim") + vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, display) + vim.api.nvim_buf_add_highlight(self.state.bufnr, 0, "TelescopeBorder", 1, 0, -1) + else + for idx, item in ipairs(results) do + if item == entry then + selected_row = idx + break + end + end + end + + vim.api.nvim_buf_add_highlight(self.state.bufnr, ns_previewer, "TelescopePreviewLine", selected_row + 1, 0, -1) + -- set the cursor position after self.state.bufnr is connected to the + -- preview window (which is scheduled in new_buffer_previewer) + vim.schedule(function() + pcall(vim.api.nvim_win_set_cursor, status.preview_win, { selected_row, 0 }) + end) + + self.state.last_set_bufnr = self.state.bufnr + end, + } +end, {}) + +previewers.highlights = defaulter(function(_) + return previewers.new_buffer_previewer { + title = "Highlights Preview", + teardown = function(self) + if self.state and self.state.last_set_bufnr and vim.api.nvim_buf_is_valid(self.state.last_set_bufnr) then + vim.api.nvim_buf_clear_namespace(self.state.last_set_bufnr, ns_previewer, 0, -1) + end + end, + + get_buffer_by_name = function() + return "highlights" + end, + + define_preview = function(self, entry) + if not self.state.bufname then + local output = vim.split(vim.fn.execute "highlight", "\n") + local hl_groups = {} + for _, v in ipairs(output) do + if v ~= "" then + if v:sub(1, 1) == " " then + local part_of_old = v:match "%s+(.*)" + hl_groups[#hl_groups] = hl_groups[#hl_groups] .. part_of_old + else + table.insert(hl_groups, v) + end + end + end + + vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, hl_groups) + for k, v in ipairs(hl_groups) do + local startPos = string.find(v, "xxx", 1, true) - 1 + local endPos = startPos + 3 + local hlgroup = string.match(v, "([^ ]*)%s+.*") + pcall(vim.api.nvim_buf_add_highlight, self.state.bufnr, 0, hlgroup, k - 1, startPos, endPos) + end + end + + vim.schedule(function() + vim.api.nvim_buf_call(self.state.bufnr, function() + vim.cmd "norm! gg" + vim.fn.search(entry.value .. " ") + local lnum = vim.api.nvim_win_get_cursor(self.state.winid)[1] + -- That one is actually a match but its better to use it like that then matchadd + pcall(vim.api.nvim_buf_clear_namespace, self.state.bufnr, ns_previewer, 0, -1) + vim.api.nvim_buf_add_highlight( + self.state.bufnr, + ns_previewer, + "TelescopePreviewMatch", + lnum - 1, + 0, + #entry.value + ) + -- we need to zz after the highlighting otherwise highlighting doesnt work + vim.cmd "norm! zz" + end) + end) + end, + } +end, {}) + +previewers.pickers = defaulter(function(_) + local ns_telescope_multiselection = vim.api.nvim_create_namespace "telescope_mulitselection" + local get_row = function(picker, preview_height, index) + if picker.sorting_strategy == "ascending" then + return index - 1 + else + return preview_height - index + end + end + return previewers.new_buffer_previewer { + + dyn_title = function(_, entry) + if entry.value.default_text and entry.value.default_text ~= "" then + return string.format("%s ─ %s", entry.value.prompt_title, entry.value.default_text) + end + return entry.value.prompt_title + end, + + get_buffer_by_name = function(_, entry) + return tostring(entry.value.prompt_bufnr) + end, + + teardown = function(self) + if self.state and self.state.last_set_bufnr and vim.api.nvim_buf_is_valid(self.state.last_set_bufnr) then + vim.api.nvim_buf_clear_namespace(self.state.last_set_bufnr, ns_telescope_multiselection, 0, -1) + end + end, + + define_preview = function(self, entry) + vim.api.nvim_buf_call(self.state.bufnr, function() + local ns_telescope_entry = vim.api.nvim_create_namespace "telescope_entry" + local preview_height = vim.api.nvim_win_get_height(self.state.winid) + + if self.state.bufname then + return + end + + local picker = entry.value + -- prefill buffer to be able to set lines individually + local placeholder = utils.repeated_table(preview_height, "") + vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, placeholder) + + for index = 1, math.min(preview_height, picker.manager:num_results()) do + local row = get_row(picker, preview_height, index) + local e = picker.manager:get_entry(index) + + local display, display_highlight + -- if-clause as otherwise function return values improperly unpacked + if type(e.display) == "function" then + display, display_highlight = e:display() + else + display = e.display + end + + vim.api.nvim_buf_set_lines(self.state.bufnr, row, row + 1, false, { display }) + + if display_highlight ~= nil then + for _, hl_block in ipairs(display_highlight) do + vim.api.nvim_buf_add_highlight( + self.state.bufnr, + ns_telescope_entry, + hl_block[2], + row, + hl_block[1][1], + hl_block[1][2] + ) + end + end + if picker._multi:is_selected(e) then + vim.api.nvim_buf_add_highlight( + self.state.bufnr, + ns_telescope_multiselection, + "TelescopeMultiSelection", + row, + 0, + -1 + ) + end + end + end) + end, + } +end, {}) + +previewers.display_content = defaulter(function(_) + return previewers.new_buffer_previewer { + define_preview = function(self, entry) + assert( + type(entry.preview_command) == "function", + "entry must provide a preview_command function which will put the content into the buffer" + ) + vim.api.nvim_buf_call(self.state.bufnr, function() + entry.preview_command(entry, self.state.bufnr) + end) + end, + } +end, {}) + +return previewers diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index c90ef25b..65f20ee3 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -261,7 +261,6 @@ require("lazy").setup({ event = { "VeryLazy" }, cmd = { "Telescope" }, keys = { "" }, - tag = "0.1.1", config = function() require("kide.plugins.config.telescope") end, From aa6f712c80c4a287c201471d7d509b9f73cc543d Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 4 Jul 2023 23:12:09 +0800 Subject: [PATCH 165/708] lsp_references --- lua/kide/core/keybindings.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index feb8ce77..22f63284 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -200,10 +200,17 @@ M.maplsp = function(client, buffer, null_ls) else vim.api.nvim_buf_set_keymap(buffer, "n", "gd", "lua vim.lsp.buf.definition()", opt) end + vim.api.nvim_buf_set_keymap(buffer, "n", "gh", "lua vim.lsp.buf.hover()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gs", "lua vim.lsp.buf.signature_help()", opt) vim.api.nvim_buf_set_keymap(buffer, "n", "gi", "Telescope lsp_implementations", opt) - vim.api.nvim_buf_set_keymap(buffer, "n", "gr", "Telescope lsp_references", opt) + vim.api.nvim_buf_set_keymap( + buffer, + "n", + "gr", + "lua require('telescope.builtin').lsp_references({jump_type='never'})", + opt + ) vim.api.nvim_buf_set_keymap(buffer, "n", "fs", "Telescope lsp_dynamic_workspace_symbols", opt) keymap("v", "fs", function() local tb = require("telescope.builtin") From 4287808d2236195f614af8b0e3f3eaeebc7b3d39 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 4 Jul 2023 23:22:17 +0800 Subject: [PATCH 166/708] edit --- lua/kide/plugins/config/telescope.lua | 55 +-- .../plugins/config/telescope/actions/set.lua | 313 ++++++++++++++++++ 2 files changed, 314 insertions(+), 54 deletions(-) create mode 100644 lua/kide/plugins/config/telescope/actions/set.lua diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index ad399dba..c82a465c 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -12,61 +12,8 @@ form_entry.path = function(entry, validate, escape) return f_path(entry, validate, escape) end -local utils = require("telescope.utils") local set = require("telescope.actions.set") -local action_state = require("telescope.actions.state") -local l_edit = set.edit -set.edit = function(prompt_bufnr, command) - local entry = action_state.get_selected_entry() - - if not entry then - utils.notify("actions.set.edit", { - msg = "Nothing currently selected", - level = "WARN", - }) - return - end - - local filename, row, col - - filename = entry.path or entry.filename - if not vim.startswith(filename, "jdt://") then - l_edit(prompt_bufnr, command) - return - end - - row = entry.row or entry.lnum - col = vim.F.if_nil(entry.col, 1) - - local picker = action_state.get_current_picker(prompt_bufnr) - require("telescope.pickers").on_close_prompt(prompt_bufnr) - pcall(vim.api.nvim_set_current_win, picker.original_win_id) - local win_id = picker.get_selection_window(picker, entry) - - if picker.push_cursor_on_edit then - vim.cmd("normal! m'") - end - - if picker.push_tagstack_on_edit then - local from = { vim.fn.bufnr("%"), vim.fn.line("."), vim.fn.col("."), 0 } - local items = { { tagname = vim.fn.expand(""), from = from } } - vim.fn.settagstack(vim.fn.win_getid(), { items = items }, "t") - end - - if win_id ~= 0 and a.nvim_get_current_win() ~= win_id then - vim.api.nvim_set_current_win(win_id) - end - - if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then - local bufnr = vim.uri_to_bufnr(filename) - vim.bo[bufnr].buflisted = true - vim.api.nvim_win_set_buf(win_id, bufnr) - end - - if row and col then - pcall(vim.api.nvim_win_set_cursor, 0, { row, col }) - end -end +set.edit = require("kide.plugins.config.telescope.actions.set").edit local previewers = require("telescope.previewers") previewers.buffer_previewer_maker = require("kide.plugins.config.telescope.buffer_previewer").file_maker diff --git a/lua/kide/plugins/config/telescope/actions/set.lua b/lua/kide/plugins/config/telescope/actions/set.lua new file mode 100644 index 00000000..b9f78b2f --- /dev/null +++ b/lua/kide/plugins/config/telescope/actions/set.lua @@ -0,0 +1,313 @@ +---@tag telescope.actions.set +---@config { ["module"] = "telescope.actions.set", ["name"] = "ACTIONS_SET" } + +---@brief [[ +--- Telescope action sets are used to provide an interface for managing +--- actions that all primarily do the same thing, but with slight tweaks. +--- +--- For example, when editing files you may want it in the current split, +--- a vertical split, etc. Instead of making users have to overwrite EACH +--- of those every time they want to change this behavior, they can instead +--- replace the `set` itself and then it will work great and they're done. +---@brief ]] + +local a = vim.api + +local log = require "telescope.log" +local Path = require "plenary.path" +local state = require "telescope.state" +local utils = require "telescope.utils" + +local action_state = require "telescope.actions.state" + +local transform_mod = require("telescope.actions.mt").transform_mod + +local action_set = setmetatable({}, { + __index = function(_, k) + error("'telescope.actions.set' does not have a value: " .. tostring(k)) + end, +}) + +--- Move the current selection of a picker {change} rows. +--- Handles not overflowing / underflowing the list. +---@param prompt_bufnr number: The prompt bufnr +---@param change number: The amount to shift the selection by +action_set.shift_selection = function(prompt_bufnr, change) + local count = vim.v.count + count = count == 0 and 1 or count + count = a.nvim_get_mode().mode == "n" and count or 1 + action_state.get_current_picker(prompt_bufnr):move_selection(change * count) +end + +--- Select the current entry. This is the action set to overwrite common +--- actions by the user. +--- +--- By default maps to editing a file. +---@param prompt_bufnr number: The prompt bufnr +---@param type string: The type of selection to make +-- Valid types include: "default", "horizontal", "vertical", "tabedit" +action_set.select = function(prompt_bufnr, type) + return action_set.edit(prompt_bufnr, action_state.select_key_to_edit_key(type)) +end + +-- goal: currently we have a workaround in actions/init.lua where we do this for all files +-- action_set.select = { +-- -- Will not be called if `select_default` is replaced rather than `action_set.select` because we never get here +-- pre = function(prompt_bufnr) +-- action_state.get_current_history():append( +-- action_state.get_current_line(), +-- action_state.get_current_picker(prompt_bufnr) +-- ) +-- end, +-- action = function(prompt_bufnr, type) +-- return action_set.edit(prompt_bufnr, action_state.select_key_to_edit_key(type)) +-- end +-- } + +local edit_buffer +do + local map = { + drop = "drop", + ["tab drop"] = "tab drop", + edit = "buffer", + new = "sbuffer", + vnew = "vert sbuffer", + ["leftabove new"] = "leftabove sbuffer", + ["leftabove vnew"] = "leftabove vert sbuffer", + ["rightbelow new"] = "rightbelow sbuffer", + ["rightbelow vnew"] = "rightbelow vert sbuffer", + ["topleft new"] = "topleft sbuffer", + ["topleft vnew"] = "topleft vert sbuffer", + ["botright new"] = "botright sbuffer", + ["botright vnew"] = "botright vert sbuffer", + tabedit = "tab sb", + } + + edit_buffer = function(command, bufnr) + local buf_command = map[command] + if buf_command == nil then + local valid_commands = vim.tbl_map(function(cmd) + return string.format("%q", cmd) + end, vim.tbl_keys(map)) + table.sort(valid_commands) + error( + string.format( + "There was no associated buffer command for %q.\nValid commands are: %s.", + command, + table.concat(valid_commands, ", ") + ) + ) + end + if buf_command ~= "drop" and buf_command ~= "tab drop" then + vim.cmd(string.format("%s %d", buf_command, bufnr)) + else + vim.cmd(string.format("%s %s", buf_command, vim.fn.fnameescape(vim.api.nvim_buf_get_name(bufnr)))) + end + end +end + +--- Edit a file based on the current selection. +---@param prompt_bufnr number: The prompt bufnr +---@param command string: The command to use to open the file. +-- Valid commands are: +-- - "edit" +-- - "new" +-- - "vedit" +-- - "tabedit" +-- - "drop" +-- - "tab drop" +-- - "leftabove new" +-- - "leftabove vnew" +-- - "rightbelow new" +-- - "rightbelow vnew" +-- - "topleft new" +-- - "topleft vnew" +-- - "botright new" +-- - "botright vnew" +action_set.edit = function(prompt_bufnr, command) + local entry = action_state.get_selected_entry() + + if not entry then + utils.notify("actions.set.edit", { + msg = "Nothing currently selected", + level = "WARN", + }) + return + end + + local filename, row, col + + if entry.path or entry.filename then + filename = entry.path or entry.filename + + -- TODO: Check for off-by-one + row = entry.row or entry.lnum + col = entry.col + elseif not entry.bufnr then + -- TODO: Might want to remove this and force people + -- to put stuff into `filename` + local value = entry.value + if not value then + utils.notify("actions.set.edit", { + msg = "Could not do anything with blank line...", + level = "WARN", + }) + return + end + + if type(value) == "table" then + value = entry.display + end + + local sections = vim.split(value, ":") + + filename = sections[1] + row = tonumber(sections[2]) + col = tonumber(sections[3]) + end + + local entry_bufnr = entry.bufnr + + local picker = action_state.get_current_picker(prompt_bufnr) + require("telescope.pickers").on_close_prompt(prompt_bufnr) + pcall(vim.api.nvim_set_current_win, picker.original_win_id) + local win_id = picker.get_selection_window(picker, entry) + + if picker.push_cursor_on_edit then + vim.cmd "normal! m'" + end + + if picker.push_tagstack_on_edit then + local from = { vim.fn.bufnr "%", vim.fn.line ".", vim.fn.col ".", 0 } + local items = { { tagname = vim.fn.expand "", from = from } } + vim.fn.settagstack(vim.fn.win_getid(), { items = items }, "t") + end + + if win_id ~= 0 and a.nvim_get_current_win() ~= win_id then + vim.api.nvim_set_current_win(win_id) + end + + if entry_bufnr then + if not vim.api.nvim_buf_get_option(entry_bufnr, "buflisted") then + vim.api.nvim_buf_set_option(entry_bufnr, "buflisted", true) + end + edit_buffer(command, entry_bufnr) + else + -- check if we didn't pick a different buffer + -- prevents restarting lsp server + if vim.api.nvim_buf_get_name(0) ~= filename or command ~= "edit" then + if vim.startswith(filename, "jdt://") then + local bufnr = vim.uri_to_bufnr(filename) + vim.bo[bufnr].buflisted = true + vim.api.nvim_win_set_buf(win_id, bufnr) + else + filename = Path:new(filename):normalize(vim.uv.cwd()) + pcall(vim.cmd, string.format("%s %s", command, vim.fn.fnameescape(filename))) + end + end + end + + local pos = vim.api.nvim_win_get_cursor(0) + if col == nil then + if row == pos[1] then + col = pos[2] + 1 + elseif row == nil then + row, col = pos[1], pos[2] + 1 + else + col = 1 + end + end + + if row and col then + local ok, err_msg = pcall(a.nvim_win_set_cursor, 0, { row, col }) + if not ok then + log.debug("Failed to move to cursor:", err_msg, row, col) + end + end +end + +--- Scrolls the previewer up or down. +--- Defaults to a half page scroll, but can be overridden using the `scroll_speed` +--- option in `layout_config`. See |telescope.layout| for more details. +---@param prompt_bufnr number: The prompt bufnr +---@param direction number: The direction of the scrolling +-- Valid directions include: "1", "-1" +action_set.scroll_previewer = function(prompt_bufnr, direction) + local previewer = action_state.get_current_picker(prompt_bufnr).previewer + local status = state.get_status(prompt_bufnr) + + -- Check if we actually have a previewer and a preview window + if type(previewer) ~= "table" or previewer.scroll_fn == nil or status.preview_win == nil then + return + end + + local default_speed = vim.api.nvim_win_get_height(status.preview_win) / 2 + local speed = status.picker.layout_config.scroll_speed or default_speed + + previewer:scroll_fn(math.floor(speed * direction)) +end + +--- Scrolls the previewer to the left or right. +--- Defaults to a half page scroll, but can be overridden using the `scroll_speed` +--- option in `layout_config`. See |telescope.layout| for more details. +---@param prompt_bufnr number: The prompt bufnr +---@param direction number: The direction of the scrolling +-- Valid directions include: "1", "-1" +action_set.scroll_horizontal_previewer = function(prompt_bufnr, direction) + local previewer = action_state.get_current_picker(prompt_bufnr).previewer + local status = state.get_status(prompt_bufnr) + + -- Check if we actually have a previewer and a preview window + if type(previewer) ~= "table" or previewer.scroll_horizontal_fn == nil or status.preview_win == nil then + return + end + + local default_speed = vim.api.nvim_win_get_height(status.preview_win) / 2 + local speed = status.picker.layout_config.scroll_speed or default_speed + + previewer:scroll_horizontal_fn(math.floor(speed * direction)) +end + +--- Scrolls the results up or down. +--- Defaults to a half page scroll, but can be overridden using the `scroll_speed` +--- option in `layout_config`. See |telescope.layout| for more details. +---@param prompt_bufnr number: The prompt bufnr +---@param direction number: The direction of the scrolling +-- Valid directions include: "1", "-1" +action_set.scroll_results = function(prompt_bufnr, direction) + local status = state.get_status(prompt_bufnr) + local default_speed = vim.api.nvim_win_get_height(status.results_win) / 2 + local speed = status.picker.layout_config.scroll_speed or default_speed + + local input = direction > 0 and [[]] or [[]] + + vim.api.nvim_win_call(status.results_win, function() + vim.cmd([[normal! ]] .. math.floor(speed) .. input) + end) + + action_set.shift_selection(prompt_bufnr, math.floor(speed) * direction) +end + +--- Scrolls the results to the left or right. +--- Defaults to a half page scroll, but can be overridden using the `scroll_speed` +--- option in `layout_config`. See |telescope.layout| for more details. +---@param prompt_bufnr number: The prompt bufnr +---@param direction number: The direction of the scrolling +-- Valid directions include: "1", "-1" +action_set.scroll_horizontal_results = function(prompt_bufnr, direction) + local status = state.get_status(prompt_bufnr) + local default_speed = vim.api.nvim_win_get_height(status.results_win) / 2 + local speed = status.picker.layout_config.scroll_speed or default_speed + + local input = direction > 0 and [[zl]] or [[zh]] + + vim.api.nvim_win_call(status.results_win, function() + vim.cmd([[normal! ]] .. math.floor(speed) .. input) + end) +end + +-- ================================================== +-- Transforms modules and sets the corect metatables. +-- ================================================== +action_set = transform_mod(action_set) +return action_set From 66dd61a398c51928ee27f24279a39aba01e7ced7 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 09:16:41 +0800 Subject: [PATCH 167/708] rime_ls --- lua/kide/config.lua | 1 + lua/kide/lsp/init.lua | 1 + lua/kide/lsp/rime_ls.lua | 95 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 lua/kide/lsp/rime_ls.lua diff --git a/lua/kide/config.lua b/lua/kide/config.lua index 1203525e..c4da878d 100644 --- a/lua/kide/config.lua +++ b/lua/kide/config.lua @@ -1,6 +1,7 @@ local M = { env = { py_bin = vim.env["PY_BIN"] or "/usr/bin/python3", + rime_ls_bin = vim.env["RIME_LS_BIN"], }, plugin = { copilot = { diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 93c15c15..4b4cad4b 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -21,6 +21,7 @@ local server_configs = { vuels = {}, lemminx = require("kide.lsp.lemminx"), gdscript = require("kide.lsp.gdscript"), + rime_ls = require("kide.lsp.rime_ls"), } local utils = require("kide.core.utils") diff --git a/lua/kide/lsp/rime_ls.lua b/lua/kide/lsp/rime_ls.lua new file mode 100644 index 00000000..d3a92ca7 --- /dev/null +++ b/lua/kide/lsp/rime_ls.lua @@ -0,0 +1,95 @@ +local config = require("kide.config") +local utils = require("kide.core.utils") + +local M = {} + +function M.setup(opts) + if not config.env.rime_ls_bin then + return + end + -- global status + vim.g.rime_enabled = false + + -- update lualine + local function rime_status() + if vim.g.rime_enabled then + return "ㄓ" + else + return "" + end + end + + require("lualine").setup({ + sections = { + lualine_x = { rime_status, "encoding", "fileformat", "filetype" }, + }, + }) + + -- add rime-ls to lspconfig as a custom server + -- see `:h lspconfig-new` + local lspconfig = require("lspconfig") + local configs = require("lspconfig.configs") + if not configs.rime_ls then + configs.rime_ls = { + default_config = { + name = "rime_ls", + cmd = { config.env.rime_ls_bin }, + -- cmd = vim.lsp.rpc.connect('127.0.0.1', 9257), + filetypes = { "*" }, + single_file_support = true, + }, + settings = {}, + docs = { + description = [[ +https://www.github.com/wlh320/rime-ls + +A language server for librime +]], + }, + } + end + + local rime_on_attach = function(client, _) + local toggle_rime = function() + client.request("workspace/executeCommand", { command = "rime-ls.toggle-rime" }, function(_, result, ctx, _) + if ctx.client_id == client.id then + vim.g.rime_enabled = result + end + end) + end + -- keymaps for executing command + vim.keymap.set("n", "", function() + toggle_rime() + end) + vim.keymap.set("i", "", function() + toggle_rime() + end) + vim.keymap.set("n", "rs", function() + vim.lsp.buf.execute_command({ command = "rime-ls.sync-user-data" }) + end) + end + + local shared_data_dir = nil + if utils.is_mac then + shared_data_dir = "/Library/Input Methods/Squirrel.app/Contents/SharedSupport" + else + shared_data_dir = "/usr/share/rime-data" + end + + lspconfig.rime_ls.setup({ + init_options = { + enabled = vim.g.rime_enabled, + shared_data_dir = shared_data_dir, + user_data_dir = "~/.local/share/rime-ls", + log_dir = "~/.local/share/rime-ls", + max_candidates = 9, + trigger_characters = {}, + schema_trigger_character = "&", -- [since v0.2.0] 当输入此字符串时请求补全会触发 “方案选单” + }, + on_attach = rime_on_attach, + flags = opts.flags, + capabilities = opts.capabilities, + }) +end + +return M From 1fa18785f3a8cf73dd810315e4b3a6390d677314 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 09:47:22 +0800 Subject: [PATCH 168/708] cmp sort --- lua/kide/plugins/config/nvim-cmp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 74c0bbb5..123ea215 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -4,6 +4,7 @@ local config = require("kide.config") local function sorting() local comparators = { + cmp.config.compare.sort_text, -- Below is the default comparitor list and order for nvim-cmp cmp.config.compare.offset, -- cmp.config.compare.scopes, --this is commented in nvim-cmp too @@ -12,7 +13,6 @@ local function sorting() cmp.config.compare.recently_used, cmp.config.compare.locality, cmp.config.compare.kind, - cmp.config.compare.sort_text, cmp.config.compare.length, cmp.config.compare.order, } From 0918d17ec71af9dee2d6053dd1b623428be9e834 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 21:33:59 +0800 Subject: [PATCH 169/708] nvim-cmp --- lua/kide/lsp/init.lua | 29 +++++++++++++++----------- lua/kide/plugins/config/nvim-cmp.lua | 31 +++++++++++++++++++--------- lua/kide/plugins/lazy-nvim.lua | 5 +++++ 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 4b4cad4b..f9ceb1ff 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -81,7 +81,6 @@ vim.diagnostic.config({ severity_sort = false, }) -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lsp_ui.hover_actions) vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp_ui.hover_actions) -- LspAttach 事件 @@ -203,25 +202,31 @@ local function convert_input_to_markdown_lines(input, contents) return contents end -local function jhover(_, result, ctx, c) - c = c or {} - c.focus_id = ctx.method - c.stylize_markdown = true +local function jhover(_, result, ctx, config) + config = config or {} + config.focus_id = ctx.method + if vim.api.nvim_get_current_buf() ~= ctx.bufnr then + -- Ignore result since buffer changed. This happens for slow language servers. + return + end if not (result and result.contents) then - vim.notify("No information available") + if config.silent ~= true then + vim.notify("No information available") + end return end local markdown_lines = convert_input_to_markdown_lines(result.contents) markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines) if vim.tbl_isempty(markdown_lines) then - vim.notify("No information available") + if config.silent ~= true then + vim.notify("No information available") + end return end - local b, w = vim.lsp.util.open_floating_preview(markdown_lines, "markdown", c) - return b, w + return vim.lsp.util.open_floating_preview(markdown_lines, "markdown", config) end - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(jhover, lsp_ui.hover_actions) + local source = require("cmp_nvim_lsp.source") source.resolve = function(self, completion_item, callback) -- client is stopped. @@ -235,8 +240,8 @@ source.resolve = function(self, completion_item, callback) end self:_request("completionItem/resolve", completion_item, function(_, response) - -- print(vim.inspect(response)) - if response and response.documentation then + -- jdtls 文档格式化 + if self.client.name == "jdtls" and response and response.documentation then response.documentation.value = markdown_format(response.documentation.value) end -- print(vim.inspect(response)) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 123ea215..a231f3cd 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -25,6 +25,13 @@ local function sorting() } end +local menu = { + nvim_lsp = "[LSP]", + luasnip = "[Lsnip]", + path = "[Path]", + copilot = "[Copilot]", + -- buffer = "[Buffer]", +} cmp.setup({ enabled = function() return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" or require("cmp_dap").is_dap_buffer() @@ -69,25 +76,29 @@ cmp.setup({ formatting = { format = lspkind.cmp_format({ with_text = true, -- do not show text alongside icons - maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + maxwidth = 50, before = function(entry, vim_item) -- Source 显示提示来源 - vim_item.menu = "[" .. string.upper(entry.source.name) .. "]" + vim_item.kind = lspkind.symbolic(vim_item.kind, {}) + local m = vim_item.kind and vim_item.kind .. " " or "" + local ms = menu[entry.source.name] and m .. menu[entry.source.name] or m + vim_item.kind = ms return vim_item end, - menu = { - nvim_lsp = "[LSP]", - luasnip = "[Lsnip]", - path = "[Path]", - copilot = "[Copilot]", - -- buffer = "[Buffer]", - }, }), }, }) -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). -cmp.setup.cmdline({ "/", "?" }, { +cmp.setup.cmdline({ "/" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "nvim_lsp_document_symbol" }, + }, { + { name = "buffer" }, + }), +}) +cmp.setup.cmdline({ "?" }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = "buffer" }, diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 65f20ee3..f73c178f 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -79,6 +79,7 @@ require("lazy").setup({ "saadparwaiz1/cmp_luasnip", "onsails/lspkind-nvim", "rcarriga/cmp-dap", + "hrsh7th/cmp-nvim-lsp-document-symbol", }, lazy = true, config = function() @@ -105,6 +106,10 @@ require("lazy").setup({ "rcarriga/cmp-dap", lazy = true, }, + { + "hrsh7th/cmp-nvim-lsp-document-symbol", + lazy = true, + }, { "jose-elias-alvarez/null-ls.nvim", lazy = true, From 9c3af3e6c72c1be06d5e8d1236963ae88ab32122 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 22:03:45 +0800 Subject: [PATCH 170/708] cmp fmt --- lua/kide/plugins/config/nvim-cmp.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index a231f3cd..011f3368 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -79,10 +79,10 @@ cmp.setup({ maxwidth = 50, before = function(entry, vim_item) -- Source 显示提示来源 - vim_item.kind = lspkind.symbolic(vim_item.kind, {}) - local m = vim_item.kind and vim_item.kind .. " " or "" - local ms = menu[entry.source.name] and m .. menu[entry.source.name] or m - vim_item.kind = ms + vim_item.menu = lspkind.symbolic(vim_item.menu, {}) + local m = vim_item.menu and vim_item.menu .. " " or "" + local ms = menu[entry.source.name] and menu[entry.source.name] .. m or m + vim_item.menu = ms return vim_item end, }), From 7dfa09cda5af3e3d058fcab232d3b0e5370fbd07 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 22:09:10 +0800 Subject: [PATCH 171/708] pumheight --- lua/kide/core/basic.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 62512cd0..293817e3 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -49,7 +49,8 @@ vim.opt.fileencoding = "UTF-8" -- jk移动时光标下上方保留8行 vim.opt.scrolloff = 3 vim.opt.sidescrolloff = 3 - +vim.opt.signcolumn = "auto" +vim.opt.pumheight = 20 -- 缩进配置 vim.opt.tabstop = 4 vim.opt.softtabstop = 4 From 6df0676ff59cb2a654d8546e05046de108e369f3 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 22:33:00 +0800 Subject: [PATCH 172/708] assertj --- lua/kide/lsp/java.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index 9b58ea95..ca0d67d2 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -261,12 +261,10 @@ local config = { contentProvider = { preferred = "fernflower" }, completion = { favoriteStaticMembers = { - "org.junit.Assert.*", - "org.assertj.core.api.Assertions.*", - -- "org.hamcrest.MatcherAssert.assertThat", - -- "org.hamcrest.Matchers.*", - -- "org.hamcrest.CoreMatchers.*", - -- "org.junit.jupiter.api.Assertions.*", + "org.assertj.core.api.Assertions.assertThat", + "org.assertj.core.api.Assertions.assertThatThrownBy", + "org.assertj.core.api.Assertions.assertThatExceptionOfType", + "org.assertj.core.api.Assertions.catchThrowable", "java.util.Objects.requireNonNull", "java.util.Objects.requireNonNullElse", "org.mockito.Mockito.*", From a8ab690788c257219bb02fc2228379b6d2eac177 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 23:03:53 +0800 Subject: [PATCH 173/708] rime --- lua/kide/plugins/config/nvim-cmp.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 011f3368..ff30e474 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -80,8 +80,18 @@ cmp.setup({ before = function(entry, vim_item) -- Source 显示提示来源 vim_item.menu = lspkind.symbolic(vim_item.menu, {}) - local m = vim_item.menu and vim_item.menu .. " " or "" - local ms = menu[entry.source.name] and menu[entry.source.name] .. m or m + local m = vim_item.menu and vim_item.menu or "" + + local ms + if entry.source.source.client then + if entry.source.source.client.name == "rime_ls" then + ms = "[rime]" + else + ms = menu[entry.source.name] and menu[entry.source.name] .. m or m + end + else + ms = m + end vim_item.menu = ms return vim_item end, From 304c6696008ef045304e0ff5b9d2062a0934e1fd Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 23:17:53 +0800 Subject: [PATCH 174/708] cmp fmt --- lua/kide/plugins/config/nvim-cmp.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index ff30e474..f23440dd 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -83,14 +83,10 @@ cmp.setup({ local m = vim_item.menu and vim_item.menu or "" local ms - if entry.source.source.client then - if entry.source.source.client.name == "rime_ls" then - ms = "[rime]" - else - ms = menu[entry.source.name] and menu[entry.source.name] .. m or m - end + if entry.source.source.client and entry.source.source.client.name == "rime_ls" then + ms = "[rime]" else - ms = m + ms = menu[entry.source.name] and menu[entry.source.name] .. m or m end vim_item.menu = ms return vim_item From df361ed74f89d4378b0cda6296dcc7943f5e6b3d Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 5 Jul 2023 23:21:45 +0800 Subject: [PATCH 175/708] =?UTF-8?q?copilot=20=E6=8E=92=E9=99=A4=20java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/lazy-nvim.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index f73c178f..88962859 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -801,6 +801,9 @@ require("lazy").setup({ cmd = "Copilot", config = function() require("copilot").setup({ + filetypes = { + java = false, + }, suggestion = { enabled = false }, panel = { enabled = false }, }) From ed886f59a0ce07bc919a7856a13cff737b236d71 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 6 Jul 2023 10:42:52 +0800 Subject: [PATCH 176/708] =?UTF-8?q?=E7=BB=9F=E4=B8=80=20lsp=20ui=20?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/init.lua | 9 ++++++- lua/kide/lsp/lsp_ui.lua | 35 +++++++++++++++++++--------- lua/kide/plugins/config/gruvbox.lua | 12 +++++----- lua/kide/plugins/config/nvim-cmp.lua | 11 +++++++++ 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index f9ceb1ff..b4d31b5d 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -223,9 +223,16 @@ local function jhover(_, result, ctx, config) end return end - return vim.lsp.util.open_floating_preview(markdown_lines, "markdown", config) + local bufnr, winnr = vim.lsp.util.open_floating_preview(markdown_lines, "markdown", config) + vim.api.nvim_win_set_option(winnr, "winhighlight", lsp_ui.window.winhighlight) + return bufnr, winnr end vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(jhover, lsp_ui.hover_actions) +vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(function(a, result, ctx, b) + local bufnr, winnr = vim.lsp.handlers.signature_help(a, result, ctx, b) + vim.api.nvim_win_set_option(winnr, "winhighlight", lsp_ui.window.winhighlight) + return bufnr, winnr +end, lsp_ui.hover_actions) local source = require("cmp_nvim_lsp.source") source.resolve = function(self, completion_item, callback) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 7787134c..4142cccd 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -42,18 +42,31 @@ M.symbol_map = { Fragment = { icon = "", hl = "@constant" }, } +M.window = { + winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", +} + M.hover_actions = { - width = 120, - -- border = { - -- { "╭", "FloatBorder" }, - -- { "─", "FloatBorder" }, - -- { "╮", "FloatBorder" }, - -- { "│", "FloatBorder" }, - -- { "╯", "FloatBorder" }, - -- { "─", "FloatBorder" }, - -- { "╰", "FloatBorder" }, - -- { "│", "FloatBorder" }, - -- }, + border = { + { "╭", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╮", "FloatBorder" }, + { "│", "FloatBorder" }, + { "╯", "FloatBorder" }, + { "─", "FloatBorder" }, + { "╰", "FloatBorder" }, + { "│", "FloatBorder" }, + }, + style = "fillchars", + -- Maximal width of the hover window. Nil means no max. + max_width = nil, + + -- Maximal height of the hover window. Nil means no max. + max_height = nil, + + -- whether the hover action window gets automatically focused + -- default: false + auto_focus = false, } M.signs = { diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index ad1fbac0..e2fd69f5 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -5,12 +5,12 @@ if transparent_mode then bg = "none", } else - overrides.NormalFloat = { - bg = "#313131", - } - overrides.Pmenu = { - bg = "#2e2e2e", - } + -- overrides.NormalFloat = { + -- bg = "#313131", + -- } + -- overrides.Pmenu = { + -- bg = "#2e2e2e", + -- } end require("gruvbox").setup({ undercurl = true, diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index f23440dd..22c25353 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -32,10 +32,21 @@ local menu = { copilot = "[Copilot]", -- buffer = "[Buffer]", } +local lsp_ui = require("kide.lsp.lsp_ui") cmp.setup({ enabled = function() return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" or require("cmp_dap").is_dap_buffer() end, + window = { + completion = cmp.config.window.bordered({ + border = lsp_ui.hover_actions.border, + winhighlight = lsp_ui.window.highlight, + }), + documentation = cmp.config.window.bordered({ + border = lsp_ui.hover_actions.border, + winhighlight = lsp_ui.window.highlight, + }), + }, sorting = sorting(), -- 指定 snippet 引擎 snippet = { From a3a237f7edf01d2c0405ac9c154705e2f7a6416a Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 6 Jul 2023 22:41:14 +0800 Subject: [PATCH 177/708] LineNr --- lua/kide/lsp/lsp_ui.lua | 2 +- lua/kide/plugins/config/nvim-cmp.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 4142cccd..0b3fa0e8 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -43,7 +43,7 @@ M.symbol_map = { } M.window = { - winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", + winhighlight = "Normal:Normal,FloatBorder:LineNr,CursorLine:Visual,Search:None", } M.hover_actions = { diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index 22c25353..a94806f7 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -40,11 +40,11 @@ cmp.setup({ window = { completion = cmp.config.window.bordered({ border = lsp_ui.hover_actions.border, - winhighlight = lsp_ui.window.highlight, + winhighlight = lsp_ui.window.winhighlight, }), documentation = cmp.config.window.bordered({ border = lsp_ui.hover_actions.border, - winhighlight = lsp_ui.window.highlight, + winhighlight = lsp_ui.window.winhighlight, }), }, sorting = sorting(), From f3f349fd8aa28542fafbc7850496f1b7dba3b72a Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 6 Jul 2023 22:55:30 +0800 Subject: [PATCH 178/708] FloatBorder --- lua/kide/lsp/lsp_ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 0b3fa0e8..b9f35f12 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -43,7 +43,7 @@ M.symbol_map = { } M.window = { - winhighlight = "Normal:Normal,FloatBorder:LineNr,CursorLine:Visual,Search:None", + winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None", } M.hover_actions = { From 9361e490e40230b495a7b154c31b4e0a83f2b56b Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 6 Jul 2023 23:08:33 +0800 Subject: [PATCH 179/708] FloatBorder --- lua/kide/plugins/config/gruvbox.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index e2fd69f5..a9212974 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -11,6 +11,9 @@ else -- overrides.Pmenu = { -- bg = "#2e2e2e", -- } + overrides.FloatBorder = { + fg = "#a89984", + } end require("gruvbox").setup({ undercurl = true, From 1735a10bf9cbdfd0376c4fde3a84bb7cb856824a Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 7 Jul 2023 23:32:10 +0800 Subject: [PATCH 180/708] nvim-colorizer --- lua/kide/plugins/config/nvim-colorizer.lua | 49 ++++++++++++---------- lua/kide/plugins/lazy-nvim.lua | 2 +- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lua/kide/plugins/config/nvim-colorizer.lua b/lua/kide/plugins/config/nvim-colorizer.lua index 31326e84..326e542c 100644 --- a/lua/kide/plugins/config/nvim-colorizer.lua +++ b/lua/kide/plugins/config/nvim-colorizer.lua @@ -1,22 +1,27 @@ -local present, colorizer = pcall(require, "colorizer") -if present then - local default = { - filetypes = { - "*", - }, - user_default_options = { - RGB = true, -- #RGB hex codes - RRGGBB = true, -- #RRGGBB hex codes - names = false, -- "Name" codes like Blue - RRGGBBAA = false, -- #RRGGBBAA hex codes - rgb_fn = false, -- CSS rgb() and rgba() functions - hsl_fn = false, -- CSS hsl() and hsla() functions - css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB - css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn - - -- Available modes: foreground, background - mode = "background", -- Set the display mode. - }, - } - colorizer.setup(default["filetypes"], default["user_default_options"]) -end +require("colorizer").setup({ + filetypes = { "*" }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = true, -- "Name" codes like Blue or blue + RRGGBBAA = false, -- #RRGGBBAA hex codes + AARRGGBB = false, -- 0xAARRGGBB hex codes + rgb_fn = false, -- CSS rgb() and rgba() functions + hsl_fn = false, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes for `mode`: foreground, background, virtualtext + mode = "background", -- Set the display mode. + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal + tailwind = false, -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = false, parsers = { "css" } }, -- Enable sass colors + virtualtext = "■", + -- update color values even if buffer is not focused + -- example use: cmp_menu, cmp_docs + always_update = false, + }, + -- all the sub-options of filetypes apply to buftypes + buftypes = {}, +}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 88962859..2b94da83 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -427,7 +427,7 @@ require("lazy").setup({ -- 颜色显示 { - "norcalli/nvim-colorizer.lua", + "NvChad/nvim-colorizer.lua", event = { "BufReadPost", "InsertEnter", "VeryLazy" }, config = function() require("kide.plugins.config.nvim-colorizer") From f8c935838974d17b19c5d3f8ddce786d18e38733 Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 7 Jul 2023 23:45:11 +0800 Subject: [PATCH 181/708] fix: lazy config --- lua/kide/plugins/lazy-nvim.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 2b94da83..f6608382 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -160,7 +160,7 @@ require("lazy").setup({ { "akinsho/bufferline.nvim", version = "*", - requires = "kyazdani42/nvim-web-devicons", + dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() require("kide.plugins.config.bufferline") end, @@ -298,7 +298,7 @@ require("lazy").setup({ -- git { "tpope/vim-fugitive", - layz = true, + lazy = true, cmd = { "Git" }, }, { @@ -319,8 +319,8 @@ require("lazy").setup({ }, { "NeogitOrg/neogit", - layz = true, - cmd = "Neogit", + lazy = true, + cmd = { "Neogit" }, dependencies = { "sindrets/diffview.nvim" }, config = function() require("kide.plugins.config.neogit") @@ -330,7 +330,7 @@ require("lazy").setup({ -- git edit 状态显示插件 { "lewis6991/gitsigns.nvim", - layz = true, + lazy = true, event = { "VeryLazy", "BufReadPost" }, config = function() require("kide.plugins.config.gitsigns-nvim") From 65109d0c67442f550bafa9d9c55e4dd52eac5a57 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 8 Jul 2023 09:43:13 +0800 Subject: [PATCH 182/708] which-key color --- lua/kide/plugins/config/which-key.lua | 2 ++ lua/kide/theme/gruvbox.lua | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lua/kide/plugins/config/which-key.lua b/lua/kide/plugins/config/which-key.lua index 7379abbe..990049e5 100644 --- a/lua/kide/plugins/config/which-key.lua +++ b/lua/kide/plugins/config/which-key.lua @@ -6,3 +6,5 @@ which_key.setup({ group = "+", -- symbol prepended to a group }, }) + +require("kide.theme.gruvbox").load_which_key_highlights() diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index e0e3ef92..602fd42d 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -78,4 +78,10 @@ M.load_highlights = function(hl_groups) end end +M.load_which_key_highlights = function() + M.load_highlights({ + WhichKeyFloat = { bg = colors.black3 }, + }) +end + return M From 8f1d7ba4267c31ca19c4c8a3f9983f5828317b51 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 8 Jul 2023 09:50:34 +0800 Subject: [PATCH 183/708] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/keybindings.lua | 6 ------ lua/kide/plugins/lazy-nvim.lua | 3 --- 2 files changed, 9 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 22f63284..d063f6e8 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -290,10 +290,4 @@ M.ufo_mapkey = function() vim.keymap.set("n", "zM", require("ufo").closeAllFolds) end -M.easy_align = function() - -- vim-easy-align - keymap("n", "ga", "(EasyAlign)") - keymap("x", "ga", "(EasyAlign)") -end - return M diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index f6608382..3dd1fac9 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -522,9 +522,6 @@ require("lazy").setup({ "junegunn/vim-easy-align", lazy = true, cmd = "EasyAlign", - config = function() - require("kide.core.keybindings").easy_align() - end, }, -- 表格模式插件 From ae8dd1243fa5a4ad5b4e718e6bbddc128bb8679d Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 8 Jul 2023 09:57:45 +0800 Subject: [PATCH 184/708] config --- lua/kide/plugins/lazy-nvim.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 3dd1fac9..9dac64d5 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -25,7 +25,7 @@ require("lazy").setup({ }, { "neovim/nvim-lspconfig", - event = { "BufNewFile", "BufReadPost" }, + event = { "VeryLazy", "BufNewFile", "BufReadPost" }, config = function() require("kide.lsp") end, @@ -113,7 +113,7 @@ require("lazy").setup({ { "jose-elias-alvarez/null-ls.nvim", lazy = true, - event = { "BufNewFile", "BufReadPost" }, + event = { "VeryLazy", "BufNewFile", "BufReadPost" }, config = function() require("kide.plugins.config.null-ls") end, @@ -169,7 +169,7 @@ require("lazy").setup({ -- treesitter (新增) { "nvim-treesitter/nvim-treesitter", - event = { "BufNewFile", "BufReadPost" }, + event = { "VeryLazy", "BufNewFile", "BufReadPost" }, build = ":TSUpdate", config = function() require("kide.plugins.config.nvim-treesitter") @@ -178,7 +178,7 @@ require("lazy").setup({ { "nvim-treesitter/nvim-treesitter-textobjects", dependencies = { "nvim-treesitter/nvim-treesitter" }, - event = { "BufNewFile", "BufReadPost" }, + event = { "VeryLazy", "BufNewFile", "BufReadPost" }, }, -- java @@ -265,7 +265,6 @@ require("lazy").setup({ lazy = true, event = { "VeryLazy" }, cmd = { "Telescope" }, - keys = { "" }, config = function() require("kide.plugins.config.telescope") end, From 73a4ec0e7bb17e56d2f7bb1a462bef9abcee9e7f Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 8 Jul 2023 10:16:02 +0800 Subject: [PATCH 185/708] =?UTF-8?q?diffview-nvim=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/diffview-nvim.lua | 121 +--------------------- 1 file changed, 1 insertion(+), 120 deletions(-) diff --git a/lua/kide/plugins/config/diffview-nvim.lua b/lua/kide/plugins/config/diffview-nvim.lua index 7e299816..23f0d163 100644 --- a/lua/kide/plugins/config/diffview-nvim.lua +++ b/lua/kide/plugins/config/diffview-nvim.lua @@ -1,120 +1 @@ --- Lua -local actions = require("diffview.actions") - -require("diffview").setup({ - diff_binaries = false, -- Show diffs for binaries - enhanced_diff_hl = false, -- See ':h diffview-config-enhanced_diff_hl' - git_cmd = { "git" }, -- The git executable followed by default args. - use_icons = true, -- Requires nvim-web-devicons - icons = { -- Only applies when use_icons is true. - folder_closed = "", - folder_open = "", - }, - signs = { - fold_closed = "", - fold_open = "", - }, - file_panel = { - listing_style = "tree", -- One of 'list' or 'tree' - tree_options = { -- Only applies when listing_style is 'tree' - flatten_dirs = true, -- Flatten dirs that only contain one single dir - folder_statuses = "only_folded", -- One of 'never', 'only_folded' or 'always'. - }, - win_config = { -- See ':h diffview-config-win_config' - position = "left", - width = 35, - }, - }, - file_history_panel = { - git = { - log_options = { -- See ':h diffview-config-log_options' - single_file = { - diff_merges = "combined", - }, - multi_file = { - diff_merges = "first-parent", - }, - }, - }, - win_config = { -- See ':h diffview-config-win_config' - position = "bottom", - height = 16, - }, - }, - commit_log_panel = { - win_config = {}, -- See ':h diffview-config-win_config' - }, - default_args = { -- Default args prepended to the arg-list for the listed commands - DiffviewOpen = {}, - DiffviewFileHistory = {}, - }, - hooks = {}, -- See ':h diffview-config-hooks' - keymaps = { - disable_defaults = false, -- Disable the default keymaps - view = { - -- The `view` bindings are active in the diff buffers, only when the current - -- tabpage is a Diffview. - [""] = actions.select_next_entry, -- Open the diff for the next file - [""] = actions.select_prev_entry, -- Open the diff for the previous file - ["gf"] = actions.goto_file, -- Open the file in a new split in the previous tabpage - [""] = actions.goto_file_split, -- Open the file in a new split - ["gf"] = actions.goto_file_tab, -- Open the file in a new tabpage - ["e"] = actions.focus_files, -- Bring focus to the files panel - ["b"] = actions.toggle_files, -- Toggle the files panel. - }, - file_panel = { - ["j"] = actions.next_entry, -- Bring the cursor to the next file entry - [""] = actions.next_entry, - ["k"] = actions.prev_entry, -- Bring the cursor to the previous file entry. - [""] = actions.prev_entry, - [""] = actions.select_entry, -- Open the diff for the selected entry. - ["o"] = actions.select_entry, - ["<2-LeftMouse>"] = actions.select_entry, - ["-"] = actions.toggle_stage_entry, -- Stage / unstage the selected entry. - ["S"] = actions.stage_all, -- Stage all entries. - ["U"] = actions.unstage_all, -- Unstage all entries. - ["X"] = actions.restore_entry, -- Restore entry to the state on the left side. - ["R"] = actions.refresh_files, -- Update stats and entries in the file list. - ["L"] = actions.open_commit_log, -- Open the commit log panel. - [""] = actions.scroll_view(-0.25), -- Scroll the view up - [""] = actions.scroll_view(0.25), -- Scroll the view down - [""] = actions.select_next_entry, - [""] = actions.select_prev_entry, - ["gf"] = actions.goto_file, - [""] = actions.goto_file_split, - ["gf"] = actions.goto_file_tab, - ["i"] = actions.listing_style, -- Toggle between 'list' and 'tree' views - ["f"] = actions.toggle_flatten_dirs, -- Flatten empty subdirectories in tree listing style. - ["e"] = actions.focus_files, - ["b"] = actions.toggle_files, - }, - file_history_panel = { - ["g!"] = actions.options, -- Open the option panel - [""] = actions.open_in_diffview, -- Open the entry under the cursor in a diffview - ["y"] = actions.copy_hash, -- Copy the commit hash of the entry under the cursor - ["L"] = actions.open_commit_log, - ["zR"] = actions.open_all_folds, - ["zM"] = actions.close_all_folds, - ["j"] = actions.next_entry, - [""] = actions.next_entry, - ["k"] = actions.prev_entry, - [""] = actions.prev_entry, - [""] = actions.select_entry, - ["o"] = actions.select_entry, - ["<2-LeftMouse>"] = actions.select_entry, - [""] = actions.scroll_view(-0.25), - [""] = actions.scroll_view(0.25), - [""] = actions.select_next_entry, - [""] = actions.select_prev_entry, - ["gf"] = actions.goto_file, - [""] = actions.goto_file_split, - ["gf"] = actions.goto_file_tab, - ["e"] = actions.focus_files, - ["b"] = actions.toggle_files, - }, - option_panel = { - [""] = actions.select_entry, - ["q"] = actions.close, - }, - }, -}) +require("diffview").setup({}) From 19bae5f2f592c8789a69b8870663eddcd2ca9a9e Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 8 Jul 2023 22:43:04 +0800 Subject: [PATCH 186/708] maven --- lua/kide/core/utils/init.lua | 7 ++-- lua/kide/core/utils/maven.lua | 61 ++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/lua/kide/core/utils/init.lua b/lua/kide/core/utils/init.lua index 2f21695e..5f3a968d 100644 --- a/lua/kide/core/utils/init.lua +++ b/lua/kide/core/utils/init.lua @@ -195,18 +195,17 @@ M.is_linux = M.os_type() == M.Linux M.is_mac = M.os_type() == M.Mac --- complete ----@param complete {} ----@param opt {multiple:false, multiple_repeated:false, single:false} +---@param opt {model:"single"|"multiple"} M.command_args_complete = function(complete, opt) opt = opt or {} if complete ~= nil then return function(_, cmd_line, _) - if opt.multiple ~= nil and opt.multiple then + if opt.model == "multiple" then local args = vim.split(cmd_line, " ") return vim.tbl_filter(function(item) return not vim.tbl_contains(args, item) end, complete) - elseif opt.single ~= nil and opt.single then + elseif opt.model == "single" then local args = vim.split(cmd_line, " ") for _, value in ipairs(args) do if vim.tbl_contains(complete, value) then diff --git a/lua/kide/core/utils/maven.lua b/lua/kide/core/utils/maven.lua index 95bb9cef..f6343932 100644 --- a/lua/kide/core/utils/maven.lua +++ b/lua/kide/core/utils/maven.lua @@ -49,6 +49,13 @@ local exec = function(cmd, pom, opt) end local function create_command(buf, name, cmd, complete, opt) vim.api.nvim_buf_create_user_command(buf, name, function(opts) + if type(cmd) == "function" then + cmd = cmd(opts) + end + if cmd == nil then + return + end + if opts.args then exec(cmd .. " " .. opts.args, vim.fn.expand("%"), opt) else @@ -62,33 +69,71 @@ end local maven_args_complete = utils.command_args_complete +local function get_class_name() + if require("nvim-treesitter.query").has_query_files("java", "indents") then + local ts_utils = require("nvim-treesitter.ts_utils") + local node = ts_utils.get_node_at_cursor() + if node ~= nil and node:type() ~= "identifier" then + node = node:parent() + end + if node ~= nil and node:type() == "identifier" then + return vim.treesitter.get_node_text(node, 0) + end + end +end + M.maven_command = function(buf) + create_command( + buf, + "Maven", + "mvn", + maven_args_complete({ + "clean", + "compile", + "test-compile", + "verify", + "package", + "install", + "deploy", + }, { model = "multiple" }), + { update = true, close_on_exit = false } + ) + -- 判断为 java 文件 + if vim.api.nvim_buf_get_option(buf, "filetype") == "java" then + create_command(buf, "MavenExecJava", function(_) + local filename = vim.fn.expand("%:p") + filename = string.gsub(filename, "^[%-/%w%s]*%/src%/main%/java%/", "") + filename = string.gsub(filename, "[/\\]", ".") + filename = string.gsub(filename, "%.java$", "") + return 'mvn exec:java -Dexec.mainClass="' .. filename .. '"' + end, nil, { update = true, close_on_exit = false }) + end create_command( buf, "MavenCompile", "mvn clean compile", - maven_args_complete({ "test-compile" }, { multiple = true }), + maven_args_complete({ "test-compile" }, { model = "multiple" }), { update = true, close_on_exit = false } ) create_command( buf, "MavenInstll", "mvn clean install", - maven_args_complete({ "-DskipTests", "-Dmaven.test.skip=true" }, { single = true }), + maven_args_complete({ "-DskipTests", "-Dmaven.test.skip=true" }, { model = "single" }), { update = true, close_on_exit = false } ) create_command( buf, "MavenPackage", "mvn clean package", - maven_args_complete({ "-DskipTests", "-Dmaven.test.skip=true" }, { single = true }), + maven_args_complete({ "-DskipTests", "-Dmaven.test.skip=true" }, { model = "single" }), { update = true, close_on_exit = false } ) create_command( buf, "MavenDependencyTree", "mvn dependency:tree", - maven_args_complete({ "-Doutput=.dependency.txt" }, { multiple = true }), + maven_args_complete({ "-Doutput=.dependency.txt" }, { model = "single" }), { close_on_exit = false } ) create_command(buf, "MavenDependencyAnalyzeDuplicate", "mvn dependency:analyze-duplicate", nil, { @@ -98,7 +143,13 @@ M.maven_command = function(buf) close_on_exit = false, }) create_command(buf, "MavenDownloadSources", "mvn dependency:sources -DdownloadSources=true") - create_command(buf, "MavenTest", "mvn test", maven_args_complete({ "-Dtest=" }, {}), { close_on_exit = false }) + create_command( + buf, + "MavenTest", + "mvn test", + maven_args_complete({ "-Dtest=" }, { model = "single" }), + { close_on_exit = false } + ) end M.setup = function() From 535c39c5d855649e76e6bb7e40ad531ab0b313ed Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 10 Jul 2023 16:58:40 +0800 Subject: [PATCH 187/708] jdt path --- lua/kide/core/utils/url.lua | 532 ++++++++++++++++++ lua/kide/plugins/config/telescope.lua | 4 + .../config/telescope/buffer_previewer.lua | 10 +- 3 files changed, 545 insertions(+), 1 deletion(-) create mode 100644 lua/kide/core/utils/url.lua diff --git a/lua/kide/core/utils/url.lua b/lua/kide/core/utils/url.lua new file mode 100644 index 00000000..f167c437 --- /dev/null +++ b/lua/kide/core/utils/url.lua @@ -0,0 +1,532 @@ +-- https://github.com/golgote/neturl/blob/master/lib/net/url.lua +-- net/url.lua - a robust url parser and builder +-- +-- Bertrand Mansion, 2011-2021; License MIT +-- @module net.url +-- @alias M + +local M = {} +M.version = "1.1.0" + +--- url options +-- - `separator` is set to `&` by default but could be anything like `&amp;` or `;` +-- - `cumulative_parameters` is false by default. If true, query parameters with the same name will be stored in a table. +-- - `legal_in_path` is a table of characters that will not be url encoded in path components +-- - `legal_in_query` is a table of characters that will not be url encoded in query values. Query parameters only support a small set of legal characters (-_.). +-- - `query_plus_is_space` is true by default, so a plus sign in a query value will be converted to %20 (space), not %2B (plus) +-- @todo Add option to limit the size of the argument table +-- @todo Add option to limit the depth of the argument table +-- @todo Add option to process dots in parameter names, ie. `param.filter=1` +M.options = { + separator = '&', + cumulative_parameters = false, + legal_in_path = { + [":"] = true, ["-"] = true, ["_"] = true, ["."] = true, + ["!"] = true, ["~"] = true, ["*"] = true, ["'"] = true, + ["("] = true, [")"] = true, ["@"] = true, ["&"] = true, + ["="] = true, ["$"] = true, [","] = true, + [";"] = true + }, + legal_in_query = { + [":"] = true, ["-"] = true, ["_"] = true, ["."] = true, + [","] = true, ["!"] = true, ["~"] = true, ["*"] = true, + ["'"] = true, [";"] = true, ["("] = true, [")"] = true, + ["@"] = true, ["$"] = true, + }, + query_plus_is_space = true +} + +--- list of known and common scheme ports +-- as documented in IANA URI scheme list +M.services = { + acap = 674, + cap = 1026, + dict = 2628, + ftp = 21, + gopher = 70, + http = 80, + https = 443, + iax = 4569, + icap = 1344, + imap = 143, + ipp = 631, + ldap = 389, + mtqp = 1038, + mupdate = 3905, + news = 2009, + nfs = 2049, + nntp = 119, + rtsp = 554, + sip = 5060, + snmp = 161, + telnet = 23, + tftp = 69, + vemmi = 575, + afs = 1483, + jms = 5673, + rsync = 873, + prospero = 191, + videotex = 516 +} + +local function decode(str) + return (str:gsub("%%(%x%x)", function(c) + return string.char(tonumber(c, 16)) + end)) +end + +local function encode(str, legal) + return (str:gsub("([^%w])", function(v) + if legal[v] then + return v + end + return string.upper(string.format("%%%02x", string.byte(v))) + end)) +end + +-- for query values, + can mean space if configured as such +local function decodeValue(str) + if M.options.query_plus_is_space then + str = str:gsub('+', ' ') + end + return decode(str) +end + +local function concat(a, b) + if type(a) == 'table' then + return a:build() .. b + else + return a .. b:build() + end +end + +function M:addSegment(path) + if type(path) == 'string' then + self.path = self.path .. '/' .. encode(path:gsub("^/+", ""), M.options.legal_in_path) + end + return self +end + +--- builds the url +-- @return a string representing the built url +function M:build() + local url = '' + if self.path then + local path = self.path + url = url .. tostring(path) + end + if self.query then + local qstring = tostring(self.query) + if qstring ~= "" then + url = url .. '?' .. qstring + end + end + if self.host then + local authority = self.host + if self.port and self.scheme and M.services[self.scheme] ~= self.port then + authority = authority .. ':' .. self.port + end + local userinfo + if self.user and self.user ~= "" then + userinfo = self.user + if self.password then + userinfo = userinfo .. ':' .. self.password + end + end + if userinfo and userinfo ~= "" then + authority = userinfo .. '@' .. authority + end + if authority then + if url ~= "" then + url = '//' .. authority .. '/' .. url:gsub('^/+', '') + else + url = '//' .. authority + end + end + end + if self.scheme then + url = self.scheme .. ':' .. url + end + if self.fragment then + url = url .. '#' .. self.fragment + end + return url +end + +--- builds the querystring +-- @param tab The key/value parameters +-- @param sep The separator to use (optional) +-- @param key The parent key if the value is multi-dimensional (optional) +-- @return a string representing the built querystring +function M.buildQuery(tab, sep, key) + local query = {} + if not sep then + sep = M.options.separator or '&' + end + local keys = {} + for k in pairs(tab) do + keys[#keys+1] = k + end + table.sort(keys, function (a, b) + local function padnum(n, rest) return ("%03d"..rest):format(tonumber(n)) end + return tostring(a):gsub("(%d+)(%.)",padnum) < tostring(b):gsub("(%d+)(%.)",padnum) + end) + for _,name in ipairs(keys) do + local value = tab[name] + name = encode(tostring(name), {["-"] = true, ["_"] = true, ["."] = true}) + if key then + if M.options.cumulative_parameters and string.find(name, '^%d+$') then + name = tostring(key) + else + name = string.format('%s[%s]', tostring(key), tostring(name)) + end + end + if type(value) == 'table' then + query[#query+1] = M.buildQuery(value, sep, name) + else + local value = encode(tostring(value), M.options.legal_in_query) + if value ~= "" then + query[#query+1] = string.format('%s=%s', name, value) + else + query[#query+1] = name + end + end + end + return table.concat(query, sep) +end + +--- Parses the querystring to a table +-- This function can parse multidimensional pairs and is mostly compatible +-- with PHP usage of brackets in key names like ?param[key]=value +-- @param str The querystring to parse +-- @param sep The separator between key/value pairs, defaults to `&` +-- @todo limit the max number of parameters with M.options.max_parameters +-- @return a table representing the query key/value pairs +function M.parseQuery(str, sep) + if not sep then + sep = M.options.separator or '&' + end + + local values = {} + for key,val in str:gmatch(string.format('([^%q=]+)(=*[^%q=]*)', sep, sep)) do + local key = decodeValue(key) + local keys = {} + key = key:gsub('%[([^%]]*)%]', function(v) + -- extract keys between balanced brackets + if string.find(v, "^-?%d+$") then + v = tonumber(v) + else + v = decodeValue(v) + end + table.insert(keys, v) + return "=" + end) + key = key:gsub('=+.*$', "") + key = key:gsub('%s', "_") -- remove spaces in parameter name + val = val:gsub('^=+', "") + + if not values[key] then + values[key] = {} + end + if #keys > 0 and type(values[key]) ~= 'table' then + values[key] = {} + elseif #keys == 0 and type(values[key]) == 'table' then + values[key] = decodeValue(val) + elseif M.options.cumulative_parameters + and type(values[key]) == 'string' then + values[key] = { values[key] } + table.insert(values[key], decodeValue(val)) + end + + local t = values[key] + for i,k in ipairs(keys) do + if type(t) ~= 'table' then + t = {} + end + if k == "" then + k = #t+1 + end + if not t[k] then + t[k] = {} + end + if i == #keys then + t[k] = val + end + t = t[k] + end + + end + setmetatable(values, { __tostring = M.buildQuery }) + return values +end + +--- set the url query +-- @param query Can be a string to parse or a table of key/value pairs +-- @return a table representing the query key/value pairs +function M:setQuery(query) + local query = query + if type(query) == 'table' then + query = M.buildQuery(query) + end + self.query = M.parseQuery(query) + return query +end + +--- set the authority part of the url +-- The authority is parsed to find the user, password, port and host if available. +-- @param authority The string representing the authority +-- @return a string with what remains after the authority was parsed +function M:setAuthority(authority) + self.authority = authority + self.port = nil + self.host = nil + self.userinfo = nil + self.user = nil + self.password = nil + + authority = authority:gsub('^([^@]*)@', function(v) + self.userinfo = v + return '' + end) + + authority = authority:gsub(':(%d+)$', function(v) + self.port = tonumber(v) + return '' + end) + + local function getIP(str) + -- ipv4 + local chunks = { str:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$") } + if #chunks == 4 then + for _, v in pairs(chunks) do + if tonumber(v) > 255 then + return false + end + end + return str + end + -- ipv6 + local chunks = { str:match("^%["..(("([a-fA-F0-9]*):"):rep(8):gsub(":$","%%]$"))) } + if #chunks == 8 or #chunks < 8 and + str:match('::') and not str:gsub("::", "", 1):match('::') then + for _,v in pairs(chunks) do + if #v > 0 and tonumber(v, 16) > 65535 then + return false + end + end + return str + end + return nil + end + + local ip = getIP(authority) + if ip then + self.host = ip + elseif type(ip) == 'nil' then + -- domain + if authority ~= '' and not self.host then + local host = authority:lower() + if string.match(host, '^[%d%a%-%.]+$') ~= nil and + string.sub(host, 0, 1) ~= '.' and + string.sub(host, -1) ~= '.' and + string.find(host, '%.%.') == nil then + self.host = host + end + end + end + + if self.userinfo then + local userinfo = self.userinfo + userinfo = userinfo:gsub(':([^:]*)$', function(v) + self.password = v + return '' + end) + if string.find(userinfo, "^[%w%+%.]+$") then + self.user = userinfo + else + -- incorrect userinfo + self.userinfo = nil + self.user = nil + self.password = nil + end + end + + return authority +end + +--- Parse the url into the designated parts. +-- Depending on the url, the following parts can be available: +-- scheme, userinfo, user, password, authority, host, port, path, +-- query, fragment +-- @param url Url string +-- @return a table with the different parts and a few other functions +function M.parse(url) + local comp = {} + M.setAuthority(comp, "") + M.setQuery(comp, "") + + local url = tostring(url or '') + url = url:gsub('#(.*)$', function(v) + comp.fragment = v + return '' + end) + url =url:gsub('^([%w][%w%+%-%.]*)%:', function(v) + comp.scheme = v:lower() + return '' + end) + url = url:gsub('%?(.*)', function(v) + M.setQuery(comp, v) + return '' + end) + url = url:gsub('^//([^/]*)', function(v) + M.setAuthority(comp, v) + return '' + end) + + comp.path = url:gsub("([^/]+)", function (s) return encode(decode(s), M.options.legal_in_path) end) + + setmetatable(comp, { + __index = M, + __tostring = M.build, + __concat = concat, + __div = M.addSegment + }) + return comp +end + +--- removes dots and slashes in urls when possible +-- This function will also remove multiple slashes +-- @param path The string representing the path to clean +-- @return a string of the path without unnecessary dots and segments +function M.removeDotSegments(path) + local fields = {} + if string.len(path) == 0 then + return "" + end + local startslash = false + local endslash = false + if string.sub(path, 1, 1) == "/" then + startslash = true + end + if (string.len(path) > 1 or startslash == false) and string.sub(path, -1) == "/" then + endslash = true + end + + path:gsub('[^/]+', function(c) table.insert(fields, c) end) + + local new = {} + local j = 0 + + for i,c in ipairs(fields) do + if c == '..' then + if j > 0 then + j = j - 1 + end + elseif c ~= "." then + j = j + 1 + new[j] = c + end + end + local ret = "" + if #new > 0 and j > 0 then + ret = table.concat(new, '/', 1, j) + else + ret = "" + end + if startslash then + ret = '/'..ret + end + if endslash then + ret = ret..'/' + end + return ret +end + +local function reducePath(base_path, relative_path) + if string.sub(relative_path, 1, 1) == "/" then + return '/' .. string.gsub(relative_path, '^[%./]+', '') + end + local path = base_path + local startslash = string.sub(path, 1, 1) ~= "/"; + if relative_path ~= "" then + path = (startslash and '' or '/') .. path:gsub("[^/]*$", "") + end + path = path .. relative_path + path = path:gsub("([^/]*%./)", function (s) + if s ~= "./" then return s else return "" end + end) + path = string.gsub(path, "/%.$", "/") + local reduced + while reduced ~= path do + reduced = path + path = string.gsub(reduced, "([^/]*/%.%./)", function (s) + if s ~= "../../" then return "" else return s end + end) + end + path = string.gsub(path, "([^/]*/%.%.?)$", function (s) + if s ~= "../.." then return "" else return s end + end) + local reduced + while reduced ~= path do + reduced = path + path = string.gsub(reduced, '^/?%.%./', '') + end + return (startslash and '' or '/') .. path +end + +--- builds a new url by using the one given as parameter and resolving paths +-- @param other A string or a table representing a url +-- @return a new url table +function M:resolve(other) + if type(self) == "string" then + self = M.parse(self) + end + if type(other) == "string" then + other = M.parse(other) + end + if other.scheme then + return other + else + other.scheme = self.scheme + if not other.authority or other.authority == "" then + other:setAuthority(self.authority) + if not other.path or other.path == "" then + other.path = self.path + local query = other.query + if not query or not next(query) then + other.query = self.query + end + else + other.path = reducePath(self.path, other.path) + end + end + return other + end +end + +--- normalize a url path following some common normalization rules +-- described on The URL normalization page of Wikipedia +-- @return the normalized path +function M:normalize() + if type(self) == 'string' then + self = M.parse(self) + end + if self.path then + local path = self.path + path = reducePath(path, "") + -- normalize multiple slashes + path = string.gsub(path, "//+", "/") + self.path = path + end + return self +end + +local hex_to_char = function(x) + return string.char(tonumber(x, 16)) +end + +M.unescape = function(url) + return url:gsub("%%(%x%x)", hex_to_char) +end + +return M diff --git a/lua/kide/plugins/config/telescope.lua b/lua/kide/plugins/config/telescope.lua index c82a465c..8205e3a6 100644 --- a/lua/kide/plugins/config/telescope.lua +++ b/lua/kide/plugins/config/telescope.lua @@ -18,6 +18,10 @@ set.edit = require("kide.plugins.config.telescope.actions.set").edit local previewers = require("telescope.previewers") previewers.buffer_previewer_maker = require("kide.plugins.config.telescope.buffer_previewer").file_maker +local conf = require("telescope.config").values +conf["qflist_previewer"] = function(...) + return require("kide.plugins.config.telescope.buffer_previewer").qflist.new(...) +end telescope.setup({ defaults = { vimgrep_arguments = { diff --git a/lua/kide/plugins/config/telescope/buffer_previewer.lua b/lua/kide/plugins/config/telescope/buffer_previewer.lua index 3775404f..fe43d9b6 100644 --- a/lua/kide/plugins/config/telescope/buffer_previewer.lua +++ b/lua/kide/plugins/config/telescope/buffer_previewer.lua @@ -531,7 +531,15 @@ previewers.vimgrep = defaulter(function(opts) return previewers.new_buffer_previewer { title = "Grep Preview", dyn_title = function(_, entry) - return Path:new(from_entry.path(entry, false, false)):normalize(cwd) + local fp = from_entry.path(entry, false, false) + if vim.startswith(fp, 'jdt://') then + local url = require('kide.core.utils.url') + -- fp = url.unescape(fp) + fp = string.gsub(fp, '%%5C', '') + local u = url.parse(fp) + return u.path + end + return Path:new(fp):normalize(cwd) end, get_buffer_by_name = function(_, entry) From c5dddb22731e8808ac909d1f777c52413ce9730c Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 11 Jul 2023 20:52:27 +0800 Subject: [PATCH 188/708] use sqlls --- lua/kide/lsp/sqlls.lua | 6 ------ lua/kide/plugins/lazy-nvim.lua | 5 ----- 2 files changed, 11 deletions(-) diff --git a/lua/kide/lsp/sqlls.lua b/lua/kide/lsp/sqlls.lua index dc935810..97aeaddb 100644 --- a/lua/kide/lsp/sqlls.lua +++ b/lua/kide/lsp/sqlls.lua @@ -1,8 +1,2 @@ -vim.g.sql_type_default = "mysql" return { - server = { - on_attach = function(client, bufnr) - require("sqls").on_attach(client, bufnr) - end, - }, } diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 9dac64d5..4934585e 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -640,11 +640,6 @@ require("lazy").setup({ }, -- databases - { - "nanotee/sqls.nvim", - lazy = true, - ft = { "sql", "mysql" }, - }, { "tpope/vim-dadbod", lazy = true, From 680f44d441e5115d22ab90c5a010cd7900791510 Mon Sep 17 00:00:00 2001 From: luokai Date: Tue, 11 Jul 2023 21:04:58 +0800 Subject: [PATCH 189/708] =?UTF-8?q?=E4=B8=8D=E6=98=AF=20cmp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/nvim-cmp.lua | 4 ---- lua/kide/plugins/lazy-nvim.lua | 10 ++-------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/lua/kide/plugins/config/nvim-cmp.lua b/lua/kide/plugins/config/nvim-cmp.lua index a94806f7..d7002180 100644 --- a/lua/kide/plugins/config/nvim-cmp.lua +++ b/lua/kide/plugins/config/nvim-cmp.lua @@ -1,6 +1,5 @@ local lspkind = require("lspkind") local cmp = require("cmp") -local config = require("kide.config") local function sorting() local comparators = { @@ -16,9 +15,6 @@ local function sorting() cmp.config.compare.length, cmp.config.compare.order, } - if config.plugin.copilot.enable then - table.insert(comparators, 1, require("copilot_cmp.comparators").prioritize) - end return { priority_weight = 2, comparators = comparators, diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 4934585e..81d52ac6 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -791,18 +791,12 @@ require("lazy").setup({ lazy = true, cmd = "Copilot", config = function() - require("copilot").setup({ - filetypes = { - java = false, - }, - suggestion = { enabled = false }, - panel = { enabled = false }, - }) + require("copilot").setup({}) end, }, { "zbirenbaum/copilot-cmp", - enabled = config.plugin.copilot.enable, + enabled = false, lazy = true, dependencies = { "zbirenbaum/copilot.lua" }, event = { "InsertEnter", "VeryLazy" }, From e0a6e16ea7abddfc9ff6c488f101284e903590b8 Mon Sep 17 00:00:00 2001 From: luokai Date: Thu, 13 Jul 2023 23:06:37 +0800 Subject: [PATCH 190/708] lsp_ui --- lua/kide/lsp/init.lua | 4 ++-- lua/kide/lsp/lsp_ui.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index b4d31b5d..6ea2e670 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -143,10 +143,10 @@ vim.api.nvim_create_autocmd("LspAttach", { -- 文档格式化 local function markdown_format(input) if input then - input = string.gsub(input, '%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@"]*)%]%(file:/[^%)]+%)', function(i1) + input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@"]*)%]%(file:/[^%)]+%)', function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, '%[([%a%$_]?[%.%w%(%),\\_%[%]%s :%-@"]*)%]%(jdt://[^%)]+%)', function(i1) + input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@"]*)%]%(jdt://[^%)]+%)', function(i1) return "`" .. i1 .. "`" end) end diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index b9f35f12..649fddda 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -59,10 +59,10 @@ M.hover_actions = { }, style = "fillchars", -- Maximal width of the hover window. Nil means no max. - max_width = nil, + max_width = 80, -- Maximal height of the hover window. Nil means no max. - max_height = nil, + max_height = 20, -- whether the hover action window gets automatically focused -- default: false From c69d8906af9af30ce846f114eb6d1e97e4f06dfe Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 14 Jul 2023 18:30:01 +0800 Subject: [PATCH 191/708] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=8A=A4=E7=9C=BC?= =?UTF-8?q?=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/basic.lua | 3 +++ lua/kide/lsp/lsp_ui.lua | 2 +- lua/kide/plugins/config/lualine.lua | 2 +- lua/kide/plugins/lazy-nvim.lua | 10 +++++----- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 293817e3..715c2147 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -1,6 +1,9 @@ local config = require("kide.config") vim.g.mapleader = " " vim.opt.title = true +vim.opt.exrc = true +vim.opt.secure = false +vim.opt.ttyfast = true vim.opt.clipboard = "unnamedplus" diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 649fddda..806e3278 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -43,7 +43,7 @@ M.symbol_map = { } M.window = { - winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None", + winhighlight = "Normal:Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", } M.hover_actions = { diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index aca8c8e3..318943da 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -1,7 +1,7 @@ local config = { options = { icons_enabled = true, - theme = "gruvbox", + theme = "gruvbox-material", component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = { diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 81d52ac6..c008b7c3 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -123,7 +123,7 @@ require("lazy").setup({ -- use 'morhetz/gruvbox' { "ellisonleao/gruvbox.nvim", - enabled = true, + enabled = false, lazy = false, priority = 1000, config = function() @@ -132,15 +132,15 @@ require("lazy").setup({ }, { "sainnhe/gruvbox-material", - enabled = false, + enabled = true, lazy = false, priority = 1000, config = function() - -- require("kide.plugins.config.gruvbox") - vim.opt.background = "dark" - vim.g.gruvbox_material_background = "hard" + vim.g.gruvbox_material_background = "medium" vim.g.gruvbox_material_better_performance = true + vim.g.gruvbox_material_diagnostic_virtual_text = "colored" + vim.g.gruvbox_material_current_word = "underline" vim.cmd([[colorscheme gruvbox-material]]) end, }, From 11546a13a5e6f2c7a262d3f788295b3f1be10efa Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 15 Jul 2023 18:38:06 +0800 Subject: [PATCH 192/708] ui update --- lua/kide/plugins/config/symbols-outline.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/config/symbols-outline.lua b/lua/kide/plugins/config/symbols-outline.lua index 30d1789e..cdcc6af2 100644 --- a/lua/kide/plugins/config/symbols-outline.lua +++ b/lua/kide/plugins/config/symbols-outline.lua @@ -12,7 +12,7 @@ require("symbols-outline").setup({ show_numbers = false, show_relative_numbers = false, show_symbol_details = true, - preview_bg_highlight = "Pmenu", + preview_bg_highlight = "Normal,FloatBorder:Normal,CursorLine:Visual,Search:None", autofold_depth = nil, auto_unfold_hover = true, fold_markers = { "", "" }, From 742fc1ca9c150a8d40e3c4a62e2fc5e8ca2d9ce7 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 15 Jul 2023 19:00:00 +0800 Subject: [PATCH 193/708] treeutils --- lua/kide/plugins/config/nvim-tree.lua | 21 ++++++++++++++------- lua/kide/plugins/config/utils/treeutil.lua | 8 ++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/lua/kide/plugins/config/nvim-tree.lua b/lua/kide/plugins/config/nvim-tree.lua index df72aacc..4da22de4 100644 --- a/lua/kide/plugins/config/nvim-tree.lua +++ b/lua/kide/plugins/config/nvim-tree.lua @@ -1,7 +1,19 @@ -local function custom_callback(callback_name) - return string.format(":lua require('kide.plugins.config.utils.treeutil').%s()", callback_name) +local function on_attach(bufnr) + local api = require("nvim-tree.api") + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + api.config.mappings.default_on_attach(bufnr) + + local treeutils = require("kide.plugins.config.utils.treeutil") + + vim.keymap.set("n", "ff", treeutils.launch_find_files, opts("Launch Find Files")) + vim.keymap.set("n", "fg", treeutils.launch_live_grep, opts("Launch Live Grep")) end + require("nvim-tree").setup({ + on_attach = on_attach, disable_netrw = true, hijack_netrw = true, -- auto_close = true, @@ -56,11 +68,6 @@ require("nvim-tree").setup({ signcolumn = "yes", mappings = { custom_only = false, - -- list = { - -- - -- { key = "ff", cb = custom_callback("launch_find_files") }, - -- { key = "fg", cb = custom_callback("launch_live_grep") }, - -- }, }, }, renderer = { diff --git a/lua/kide/plugins/config/utils/treeutil.lua b/lua/kide/plugins/config/utils/treeutil.lua index 524217a3..ee57ba4e 100644 --- a/lua/kide/plugins/config/utils/treeutil.lua +++ b/lua/kide/plugins/config/utils/treeutil.lua @@ -1,4 +1,4 @@ -local lib = require("nvim-tree.lib") +local api = require("nvim-tree.api") local openfile = require("nvim-tree.actions.node.open-file") local actions = require("telescope.actions") local action_state = require("telescope.actions.state") @@ -30,11 +30,7 @@ function M.launch_telescope(func_name, opts) if not telescope_status_ok then return end - local lib_status_ok, lib = pcall(require, "nvim-tree.lib") - if not lib_status_ok then - return - end - local node = lib.get_node_at_cursor() + local node = api.tree.get_node_under_cursor() local is_folder = node.fs_stat and node.fs_stat.type == "directory" or false local basedir = is_folder and node.absolute_path or vim.fn.fnamemodify(node.absolute_path, ":h") if node.name == ".." and TreeExplorer ~= nil then From 2f03099502954edd8933a3d19a6ac4fecb568b82 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 15 Jul 2023 21:21:08 +0800 Subject: [PATCH 194/708] broder single --- lua/kide/plugins/lazy-nvim.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index c008b7c3..6a134e38 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -349,7 +349,7 @@ require("lazy").setup({ direction = "float", close_on_exit = true, float_opts = { - border = "double", + border = "single", winblend = 0, }, }) From 6b54e037b040a9e194e0fa5ddd9d5d367b025906 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 15 Jul 2023 21:28:12 +0800 Subject: [PATCH 195/708] ft TermSelect --- lua/kide/core/keybindings.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index d063f6e8..fe11e24e 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -109,6 +109,8 @@ M.setup = function() map("n", "fr", "lua require('spectre').open_visual({select_word=true})", opt) map("v", "fr", ":lua require('spectre').open_visual()", opt) + -- ToggleTerm + map("n", "ft", "TermSelect", opt) -- ToggleTask map("n", "ts", "Telescope toggletasks spawn", opt) From 8cf0f9001a8477a69ca85c7c541c300aa7fd7515 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 15 Jul 2023 21:36:10 +0800 Subject: [PATCH 196/708] toggleterm --- lua/kide/plugins/lazy-nvim.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 6a134e38..42bc2319 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -345,12 +345,10 @@ require("lazy").setup({ config = function() require("toggleterm").setup({ shade_terminals = true, - -- shade_filetypes = { "none", "fzf" }, direction = "float", close_on_exit = true, float_opts = { border = "single", - winblend = 0, }, }) end, From e57e82ef8653264df26c91bd8b3865e86dad6598 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 15 Jul 2023 21:52:54 +0800 Subject: [PATCH 197/708] resize key --- lua/kide/core/basic.lua | 5 +++++ lua/kide/core/keybindings.lua | 9 +++++++++ lua/kide/plugins/lazy-nvim.lua | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 715c2147..614dffb7 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -216,3 +216,8 @@ autocmd("FileType", { pattern = { "gitcommit" }, command = "setlocal spell", }) +autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("spell"), + pattern = "*.md", + command = "setlocal spell", +}) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index fe11e24e..04eab992 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -24,6 +24,15 @@ M.setup = function() keymap("n", "", "k", opt) keymap("n", "", "l", opt) + map("n", "", ":res +5", opt) + map("n", "", ":res -5", opt) + map("n", "", ":res -5", opt) + map("n", "", ":res +5", opt) + map("n", "", ":vertical resize+5", opt) + map("n", "", ":vertical resize-5", opt) + map("n", "", ":vertical resize-5", opt) + map("n", "", ":vertical resize+5", opt) + vim.api.nvim_create_user_command("BufferCloseOther", function() require("kide.core.utils").close_other_bufline() end, {}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 42bc2319..de688d04 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -345,7 +345,7 @@ require("lazy").setup({ config = function() require("toggleterm").setup({ shade_terminals = true, - direction = "float", + direction = "horizontal", close_on_exit = true, float_opts = { border = "single", From 9af2d2ac286f1cf6c4d6ff8ddf4bcb6dc3288848 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 15 Jul 2023 21:59:52 +0800 Subject: [PATCH 198/708] terminal_color --- lua/kide/plugins/config/nvim-colorizer.lua | 2 +- lua/kide/theme/gruvbox.lua | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lua/kide/plugins/config/nvim-colorizer.lua b/lua/kide/plugins/config/nvim-colorizer.lua index 326e542c..577b1cdf 100644 --- a/lua/kide/plugins/config/nvim-colorizer.lua +++ b/lua/kide/plugins/config/nvim-colorizer.lua @@ -3,7 +3,7 @@ require("colorizer").setup({ user_default_options = { RGB = true, -- #RGB hex codes RRGGBB = true, -- #RRGGBB hex codes - names = true, -- "Name" codes like Blue or blue + names = false, -- "Name" codes like Blue or blue RRGGBBAA = false, -- #RRGGBBAA hex codes AARRGGBB = false, -- 0xAARRGGBB hex codes rgb_fn = false, -- CSS rgb() and rgba() functions diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index 602fd42d..7ad47c9f 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -6,12 +6,10 @@ local colors = { black2 = "#2e2e2e", black3 = "#313131", gray = "#928374", - red = "#fb4934", - green = "#b8bb26", - yellow = "#fabd2f", - yellow2 = "#d79921", - blue = "#83a598", - blue2 = "#458588", + red = vim.g.terminal_color_1 or "#fb4934", + green = vim.g.terminal_color_2 or "#b8bb26", + yellow = vim.g.terminal_color_3 or "#fabd2f", + blue = vim.g.terminal_color_4 or "#83a598", } M.colors = colors local flat_telescope = { From 542de3b02a95178ac5f7b1c8d553ffa24baf83e8 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 16 Jul 2023 11:16:29 +0800 Subject: [PATCH 199/708] ui update --- lua/kide/lsp/lsp_ui.lua | 8 ++++---- lua/kide/plugins/config/indent-blankline.lua | 21 ++++++-------------- lua/kide/plugins/lazy-nvim.lua | 3 ++- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 806e3278..e63a5599 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -48,13 +48,13 @@ M.window = { M.hover_actions = { border = { - { "╭", "FloatBorder" }, + { "┌", "FloatBorder" }, { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, + { "┐", "FloatBorder" }, { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, + { "┘", "FloatBorder" }, { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, + { "└", "FloatBorder" }, { "│", "FloatBorder" }, }, style = "fillchars", diff --git a/lua/kide/plugins/config/indent-blankline.lua b/lua/kide/plugins/config/indent-blankline.lua index 3bd06dad..5c97f3c0 100644 --- a/lua/kide/plugins/config/indent-blankline.lua +++ b/lua/kide/plugins/config/indent-blankline.lua @@ -9,10 +9,15 @@ require("indent_blankline").setup({ disable_with_nolist = true, -- filetype_exclude = { "help", "terminal", "packer", "NvimTree", "git", "text" }, filetype_exclude = { + "lspinfo", + "packer", + "checkhealth", + "man", "help", "terminal", "packer", - "markdown", + "packer", + -- "markdown", "git", "text", "txt", @@ -32,19 +37,5 @@ require("indent_blankline").setup({ "dbui", "dbout", }, - buftype_exclude = { "terminal" }, use_treesitter = true, - context_patterns = { - "class", - "function", - "method", - "block", - "list_literal", - "selector", - "^if", - "^table", - "if_statement", - "while", - "for", - }, }) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index de688d04..33728a0a 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -384,7 +384,8 @@ require("lazy").setup({ -- blankline { "lukas-reineke/indent-blankline.nvim", - event = { "BufReadPost" }, + enabled = true, + event = { "UIEnter" }, config = function() require("kide.plugins.config.indent-blankline") end, From aa72124b1564a10a186af65944ff9c31a2aaeb8a Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 16 Jul 2023 11:17:18 +0800 Subject: [PATCH 200/708] udpate --- lua/kide/plugins/config/indent-blankline.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/kide/plugins/config/indent-blankline.lua b/lua/kide/plugins/config/indent-blankline.lua index 5c97f3c0..7d1c47e9 100644 --- a/lua/kide/plugins/config/indent-blankline.lua +++ b/lua/kide/plugins/config/indent-blankline.lua @@ -16,7 +16,6 @@ require("indent_blankline").setup({ "help", "terminal", "packer", - "packer", -- "markdown", "git", "text", From 33a77f44cae68f662ff89cb7882d59753289b3c5 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 16 Jul 2023 11:32:29 +0800 Subject: [PATCH 201/708] indent-blankline color --- lua/kide/plugins/config/indent-blankline.lua | 2 ++ lua/kide/theme/gruvbox.lua | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lua/kide/plugins/config/indent-blankline.lua b/lua/kide/plugins/config/indent-blankline.lua index 7d1c47e9..18a8d31c 100644 --- a/lua/kide/plugins/config/indent-blankline.lua +++ b/lua/kide/plugins/config/indent-blankline.lua @@ -38,3 +38,5 @@ require("indent_blankline").setup({ }, use_treesitter = true, }) + +require("kide.theme.gruvbox").load_indent_blankline_highlights() diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index 7ad47c9f..b2f75586 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -82,4 +82,10 @@ M.load_which_key_highlights = function() }) end +M.load_indent_blankline_highlights = function() + M.load_highlights({ + IndentBlanklineContextChar = { fg = colors.red }, + }) +end + return M From 2062424c39e5b22cd52935baf3b98705b9a9f0c2 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 19 Jul 2023 14:04:19 +0800 Subject: [PATCH 202/708] fix: neogit config --- lua/kide/plugins/config/neogit.lua | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lua/kide/plugins/config/neogit.lua b/lua/kide/plugins/config/neogit.lua index 1e94e5ea..740376a8 100644 --- a/lua/kide/plugins/config/neogit.lua +++ b/lua/kide/plugins/config/neogit.lua @@ -62,14 +62,6 @@ neogit.setup({ folded = true, }, }, - -- override/add mappings - mappings = { - -- modify status buffer mappings - status = { - -- Adds a mapping with "B" as key that does the "BranchPopup" command - ["B"] = "BranchPopup", - }, - }, status = { recent_commit_count = 40, }, From b5196989192f4ecba51326473fbdd6681f3412c8 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 19 Jul 2023 20:49:01 +0800 Subject: [PATCH 203/708] gruvbox --- lua/kide/plugins/config/gruvbox.lua | 29 ----------------------------- lua/kide/plugins/config/lualine.lua | 2 +- lua/kide/plugins/lazy-nvim.lua | 18 +++++++++++++++--- 3 files changed, 16 insertions(+), 33 deletions(-) diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua index a9212974..fdb23d9a 100644 --- a/lua/kide/plugins/config/gruvbox.lua +++ b/lua/kide/plugins/config/gruvbox.lua @@ -4,37 +4,8 @@ if transparent_mode then overrides.Pmenu = { bg = "none", } -else - -- overrides.NormalFloat = { - -- bg = "#313131", - -- } - -- overrides.Pmenu = { - -- bg = "#2e2e2e", - -- } - overrides.FloatBorder = { - fg = "#a89984", - } end require("gruvbox").setup({ - undercurl = true, - underline = true, - bold = true, - italic = { - strings = true, - comments = true, - operators = false, - folds = true, - }, - strikethrough = true, - invert_selection = false, - invert_signs = false, - invert_tabline = false, - invert_intend_guides = false, - inverse = true, -- invert background for search, diffs, statuslines and errors - contrast = "", -- can be "hard", "soft" or empty string - palette_overrides = {}, - overrides = overrides, - dim_inactive = false, transparent_mode = transparent_mode, }) vim.opt.background = "dark" diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index 318943da..aca8c8e3 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -1,7 +1,7 @@ local config = { options = { icons_enabled = true, - theme = "gruvbox-material", + theme = "gruvbox", component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" }, disabled_filetypes = { diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 33728a0a..a3966261 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -123,16 +123,18 @@ require("lazy").setup({ -- use 'morhetz/gruvbox' { "ellisonleao/gruvbox.nvim", - enabled = false, + enabled = true, lazy = false, priority = 1000, config = function() - require("kide.plugins.config.gruvbox") + require("gruvbox").setup({}) + vim.opt.background = "dark" + vim.cmd([[colorscheme gruvbox]]) end, }, { "sainnhe/gruvbox-material", - enabled = true, + enabled = false, lazy = false, priority = 1000, config = function() @@ -144,6 +146,16 @@ require("lazy").setup({ vim.cmd([[colorscheme gruvbox-material]]) end, }, + { + "morhetz/gruvbox", + enabled = false, + lazy = false, + priority = 1000, + config = function() + vim.opt.background = "dark" + vim.cmd([[colorscheme gruvbox]]) + end, + }, -- 文件管理 { From e090e3e7928fb197b1a85ddb78d235f3b9561cd1 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 19 Jul 2023 20:51:52 +0800 Subject: [PATCH 204/708] del --- lua/kide/plugins/config/gruvbox.lua | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 lua/kide/plugins/config/gruvbox.lua diff --git a/lua/kide/plugins/config/gruvbox.lua b/lua/kide/plugins/config/gruvbox.lua deleted file mode 100644 index fdb23d9a..00000000 --- a/lua/kide/plugins/config/gruvbox.lua +++ /dev/null @@ -1,12 +0,0 @@ -local transparent_mode = false -local overrides = {} -if transparent_mode then - overrides.Pmenu = { - bg = "none", - } -end -require("gruvbox").setup({ - transparent_mode = transparent_mode, -}) -vim.opt.background = "dark" -vim.cmd([[colorscheme gruvbox]]) From 91cfadf3ea1ce3093b44d5ba26e8f8535f88f50f Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 22 Jul 2023 09:41:39 +0800 Subject: [PATCH 205/708] lsp ui update --- lua/kide/lsp/init.lua | 139 +------------------------------- lua/kide/lsp/lsp_ui.lua | 140 +++++++++++++++++++++++++++++++++ lua/kide/plugins/lazy-nvim.lua | 2 +- 3 files changed, 142 insertions(+), 139 deletions(-) diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index 6ea2e670..c96068bf 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -1,3 +1,4 @@ +require("kide.lsp.lsp_ui").init() local mason_lspconfig = require("mason-lspconfig") mason_lspconfig.setup({ ensure_installed = { @@ -61,28 +62,6 @@ for _, value in pairs(server_configs) do end end --- LSP 相关美化参考 https://github.com/NvChad/NvChad -local function lspSymbol(name, icon) - local hl = "DiagnosticSign" .. name - vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl }) -end - -local lsp_ui = require("kide.lsp.lsp_ui") -lspSymbol("Error", lsp_ui.diagnostics.icons.error) -lspSymbol("Info", lsp_ui.diagnostics.icons.info) -lspSymbol("Hint", lsp_ui.diagnostics.icons.hint) -lspSymbol("Warn", lsp_ui.diagnostics.icons.warning) - -vim.diagnostic.config({ - virtual_text = true, - signs = true, - underline = true, - update_in_insert = false, - severity_sort = false, -}) - -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp_ui.hover_actions) - -- LspAttach 事件 vim.api.nvim_create_augroup("LspAttach_keymap", {}) vim.api.nvim_create_autocmd("LspAttach", { @@ -139,119 +118,3 @@ vim.api.nvim_create_autocmd("LspAttach", { end end, }) - --- 文档格式化 -local function markdown_format(input) - if input then - input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@"]*)%]%(file:/[^%)]+%)', function(i1) - return "`" .. i1 .. "`" - end) - input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@"]*)%]%(jdt://[^%)]+%)', function(i1) - return "`" .. i1 .. "`" - end) - end - return input -end - -local function split_lines(value) - value = string.gsub(value, "\r\n?", "\n") - return vim.split(value, "\n", { plain = true }) -end -local function convert_input_to_markdown_lines(input, contents) - contents = contents or {} - -- MarkedString variation 1 - if type(input) == "string" then - input = markdown_format(input) - vim.list_extend(contents, split_lines(input)) - else - assert(type(input) == "table", "Expected a table for Hover.contents") - -- MarkupContent - if input.kind then - -- The kind can be either plaintext or markdown. - -- If it's plaintext, then wrap it in a block - - -- Some servers send input.value as empty, so let's ignore this :( - local value = input.value or "" - - if input.kind == "plaintext" then - -- wrap this in a block so that stylize_markdown - -- can properly process it as plaintext - value = string.format("\n%s\n", value) - end - - -- assert(type(value) == 'string') - vim.list_extend(contents, split_lines(value)) - -- MarkupString variation 2 - elseif input.language then - -- Some servers send input.value as empty, so let's ignore this :( - -- assert(type(input.value) == 'string') - table.insert(contents, "```" .. input.language) - vim.list_extend(contents, split_lines(input.value or "")) - table.insert(contents, "```") - -- By deduction, this must be MarkedString[] - else - -- Use our existing logic to handle MarkedString - for _, marked_string in ipairs(input) do - convert_input_to_markdown_lines(marked_string, contents) - end - end - end - if (contents[1] == "" or contents[1] == nil) and #contents == 1 then - return {} - end - return contents -end - -local function jhover(_, result, ctx, config) - config = config or {} - config.focus_id = ctx.method - if vim.api.nvim_get_current_buf() ~= ctx.bufnr then - -- Ignore result since buffer changed. This happens for slow language servers. - return - end - if not (result and result.contents) then - if config.silent ~= true then - vim.notify("No information available") - end - return - end - local markdown_lines = convert_input_to_markdown_lines(result.contents) - markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines) - if vim.tbl_isempty(markdown_lines) then - if config.silent ~= true then - vim.notify("No information available") - end - return - end - local bufnr, winnr = vim.lsp.util.open_floating_preview(markdown_lines, "markdown", config) - vim.api.nvim_win_set_option(winnr, "winhighlight", lsp_ui.window.winhighlight) - return bufnr, winnr -end -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(jhover, lsp_ui.hover_actions) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(function(a, result, ctx, b) - local bufnr, winnr = vim.lsp.handlers.signature_help(a, result, ctx, b) - vim.api.nvim_win_set_option(winnr, "winhighlight", lsp_ui.window.winhighlight) - return bufnr, winnr -end, lsp_ui.hover_actions) - -local source = require("cmp_nvim_lsp.source") -source.resolve = function(self, completion_item, callback) - -- client is stopped. - if self.client.is_stopped() then - return callback() - end - - -- client has no completion capability. - if not self:_get(self.client.server_capabilities, { "completionProvider", "resolveProvider" }) then - return callback() - end - - self:_request("completionItem/resolve", completion_item, function(_, response) - -- jdtls 文档格式化 - if self.client.name == "jdtls" and response and response.documentation then - response.documentation.value = markdown_format(response.documentation.value) - end - -- print(vim.inspect(response)) - callback(response or completion_item) - end) -end diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index e63a5599..a33fbca6 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -82,4 +82,144 @@ M.diagnostics = { error = "", }, } + +-- LSP 相关美化参考 https://github.com/NvChad/NvChad +local function lspSymbol(name, icon) + local hl = "DiagnosticSign" .. name + vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl }) +end +M.init = function() + local lsp_ui = M + lspSymbol("Error", lsp_ui.diagnostics.icons.error) + lspSymbol("Info", lsp_ui.diagnostics.icons.info) + lspSymbol("Hint", lsp_ui.diagnostics.icons.hint) + lspSymbol("Warn", lsp_ui.diagnostics.icons.warning) + + vim.diagnostic.config({ + virtual_text = true, + signs = true, + underline = true, + update_in_insert = false, + severity_sort = false, + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp_ui.hover_actions) + + -- 文档格式化 + local function markdown_format(input) + if input then + input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@"]*)%]%(file:/[^%)]+%)', function(i1) + return "`" .. i1 .. "`" + end) + input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@"]*)%]%(jdt://[^%)]+%)', function(i1) + return "`" .. i1 .. "`" + end) + end + return input + end + + local function split_lines(value) + value = string.gsub(value, "\r\n?", "\n") + return vim.split(value, "\n", { plain = true }) + end + local function convert_input_to_markdown_lines(input, contents) + contents = contents or {} + -- MarkedString variation 1 + if type(input) == "string" then + input = markdown_format(input) + vim.list_extend(contents, split_lines(input)) + else + assert(type(input) == "table", "Expected a table for Hover.contents") + -- MarkupContent + if input.kind then + -- The kind can be either plaintext or markdown. + -- If it's plaintext, then wrap it in a block + + -- Some servers send input.value as empty, so let's ignore this :( + local value = input.value or "" + + if input.kind == "plaintext" then + -- wrap this in a block so that stylize_markdown + -- can properly process it as plaintext + value = string.format("\n%s\n", value) + end + + -- assert(type(value) == 'string') + vim.list_extend(contents, split_lines(value)) + -- MarkupString variation 2 + elseif input.language then + -- Some servers send input.value as empty, so let's ignore this :( + -- assert(type(input.value) == 'string') + table.insert(contents, "```" .. input.language) + vim.list_extend(contents, split_lines(input.value or "")) + table.insert(contents, "```") + -- By deduction, this must be MarkedString[] + else + -- Use our existing logic to handle MarkedString + for _, marked_string in ipairs(input) do + convert_input_to_markdown_lines(marked_string, contents) + end + end + end + if (contents[1] == "" or contents[1] == nil) and #contents == 1 then + return {} + end + return contents + end + + local function jhover(_, result, ctx, config) + config = config or {} + config.focus_id = ctx.method + if vim.api.nvim_get_current_buf() ~= ctx.bufnr then + -- Ignore result since buffer changed. This happens for slow language servers. + return + end + if not (result and result.contents) then + if config.silent ~= true then + vim.notify("No information available") + end + return + end + local markdown_lines = convert_input_to_markdown_lines(result.contents) + markdown_lines = vim.lsp.util.trim_empty_lines(markdown_lines) + if vim.tbl_isempty(markdown_lines) then + if config.silent ~= true then + vim.notify("No information available") + end + return + end + local bufnr, winnr = vim.lsp.util.open_floating_preview(markdown_lines, "markdown", config) + vim.api.nvim_win_set_option(winnr, "winhighlight", lsp_ui.window.winhighlight) + return bufnr, winnr + end + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(jhover, lsp_ui.hover_actions) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(function(a, result, ctx, b) + local bufnr, winnr = vim.lsp.handlers.signature_help(a, result, ctx, b) + vim.api.nvim_win_set_option(winnr, "winhighlight", lsp_ui.window.winhighlight) + return bufnr, winnr + end, lsp_ui.hover_actions) + + local source = require("cmp_nvim_lsp.source") + source.resolve = function(self, completion_item, callback) + -- client is stopped. + if self.client.is_stopped() then + return callback() + end + + -- client has no completion capability. + if not self:_get(self.client.server_capabilities, { "completionProvider", "resolveProvider" }) then + return callback() + end + + self:_request("completionItem/resolve", completion_item, function(_, response) + -- jdtls 文档格式化 + if self.client.name == "jdtls" and response and response.documentation then + response.documentation.value = markdown_format(response.documentation.value) + end + -- print(vim.inspect(response)) + callback(response or completion_item) + end) + end +end + return M diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index a3966261..d8fd5c0c 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -614,7 +614,7 @@ require("lazy").setup({ "j-hui/fidget.nvim", lazy = true, tag = "legacy", - event = "VeryLazy", + event = "LspAttach", config = function() require("fidget").setup({ text = { From 4422f3f0dfdb25b80987f3ffaa1ff79dacf3ba86 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 22 Jul 2023 09:52:20 +0800 Subject: [PATCH 206/708] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6ade1277..e63db12f 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ git clone https://github.com/JavaHello/nvim.git ## Java 配置 +- 查找支持查找`jar` 包 `class` +- 美化 `lsp_hover/doc` 显示 + > 如果不使用 `Java` 语言开发,无需配置 [NVIM 打造 Java IDE](https://javahello.github.io/dev/tools/NVIM-LSP-Java-IDE-vscode.html) From 8575a3d5447c76f75ed90b361f34e657c43d6c32 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 22 Jul 2023 09:53:53 +0800 Subject: [PATCH 207/708] update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e63db12f..f37bdb0b 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ git clone https://github.com/JavaHello/nvim.git ## Java 配置 -- 查找支持查找`jar` 包 `class` +- 添加了`telescope`支持查找`jar` 包 `class` - 美化 `lsp_hover/doc` 显示 > 如果不使用 `Java` 语言开发,无需配置 From ffd73d77c9a5bb97f852ad26d092d0487513e906 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 22 Jul 2023 10:06:23 +0800 Subject: [PATCH 208/708] nvim-lastplace --- lua/kide/core/basic.lua | 19 ++++++++++--------- lua/kide/plugins/lazy-nvim.lua | 13 +++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 614dffb7..21f514e5 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -152,15 +152,16 @@ if vim.g.neovide then vim.g.neovide_profiler = false end -autocmd("BufReadPost", { - pattern = "*", - callback = function() - local l = vim.fn.line("'\"") - if l > 1 and l <= vim.fn.line("$") then - vim.fn.execute("normal! g'\"") - end - end, -}) +-- use ethanholz/nvim-lastplace +-- autocmd("BufReadPost", { +-- pattern = "*", +-- callback = function() +-- local l = vim.fn.line("'\"") +-- if l > 1 and l <= vim.fn.line("$") then +-- vim.fn.execute("normal! g'\"") +-- end +-- end, +-- }) vim.opt_global.grepprg = "rg --vimgrep --no-heading --smart-case" vim.opt_global.grepformat = "%f:%l:%c:%m,%f:%l:%m" diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index d8fd5c0c..1ea25867 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -740,6 +740,19 @@ require("lazy").setup({ end, }, + { + "ethanholz/nvim-lastplace", + lazy = true, + event = { "BufReadPost" }, + config = function() + require("nvim-lastplace").setup({ + lastplace_ignore_buftype = { "quickfix", "nofile", "help" }, + lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }, + lastplace_open_folds = true, + }) + end, + }, + { "akinsho/flutter-tools.nvim", lazy = true, From f1ae11f9e6679e528c72e9bb4767cbd2a7afa0c3 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 22 Jul 2023 10:58:38 +0800 Subject: [PATCH 209/708] textobjects --- .../config/nvim-treesitter-context.lua | 39 ---------- lua/kide/plugins/config/nvim-treesitter.lua | 59 -------------- lua/kide/plugins/lazy-nvim.lua | 77 ++++++++++++++++++- 3 files changed, 76 insertions(+), 99 deletions(-) delete mode 100644 lua/kide/plugins/config/nvim-treesitter-context.lua delete mode 100644 lua/kide/plugins/config/nvim-treesitter.lua diff --git a/lua/kide/plugins/config/nvim-treesitter-context.lua b/lua/kide/plugins/config/nvim-treesitter-context.lua deleted file mode 100644 index 0d94ca73..00000000 --- a/lua/kide/plugins/config/nvim-treesitter-context.lua +++ /dev/null @@ -1,39 +0,0 @@ -require("treesitter-context").setup({ - enable = false, -- Enable this plugin (Can be enabled/disabled later via commands) - max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. - trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' - patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries. - -- For all filetypes - -- Note that setting an entry here replaces all other patterns for this entry. - -- By setting the 'default' entry below, you can control which nodes you want to - -- appear in the context window. - default = { - "class", - "function", - "method", - -- 'for', -- These won't appear in the context - -- 'while', - -- 'if', - -- 'switch', - -- 'case', - }, - -- Example for a specific filetype. - -- If a pattern is missing, *open a PR* so everyone can benefit. - -- rust = { - -- 'impl_item', - -- }, - }, - exact_patterns = { - -- Example for a specific filetype with Lua patterns - -- Treat patterns.rust as a Lua pattern (i.e "^impl_item$" will - -- exactly match "impl_item" only) - -- rust = true, - }, - - -- [!] The options below are exposed but shouldn't require your attention, - -- you can safely ignore them. - - zindex = 20, -- The Z-index of the context window - mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline' - separator = nil, -- Separator between context and content. Should be a single character string, like '-'. -}) diff --git a/lua/kide/plugins/config/nvim-treesitter.lua b/lua/kide/plugins/config/nvim-treesitter.lua deleted file mode 100644 index 96153326..00000000 --- a/lua/kide/plugins/config/nvim-treesitter.lua +++ /dev/null @@ -1,59 +0,0 @@ -require("nvim-treesitter.configs").setup({ - -- One of "all", "maintained" (parsers with maintainers), or a list of languages - ensure_installed = { - "html", - "css", - "vim", - "yaml", - "http", - "bash", - "markdown", - "org", - "norg", - }, - - -- Install languages synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- List of parsers to ignore installing - ignore_install = {}, - - highlight = { - -- `false` will disable the whole extension - enable = true, - - -- list of language that will be disabled - disable = {}, - - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, - textobjects = { - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]m"] = "@function.outer", - ["]]"] = "@class.outer", - }, - goto_next_end = { - ["]M"] = "@function.outer", - ["]["] = "@class.outer", - }, - goto_previous_start = { - ["[m"] = "@function.outer", - ["[["] = "@class.outer", - }, - goto_previous_end = { - ["[M"] = "@function.outer", - ["[]"] = "@class.outer", - }, - }, - }, -}) --- 开启 Folding -vim.wo.foldmethod = "expr" -vim.wo.foldexpr = "nvim_treesitter#foldexpr()" diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 1ea25867..72b28e29 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -184,7 +184,82 @@ require("lazy").setup({ event = { "VeryLazy", "BufNewFile", "BufReadPost" }, build = ":TSUpdate", config = function() - require("kide.plugins.config.nvim-treesitter") + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "markdown", + }, + sync_install = false, + ignore_install = {}, + + highlight = { + enable = true, + disable = {}, + additional_vim_regex_highlighting = false, + }, + textobjects = { + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = { query = "@class.outer", desc = "Next class start" }, + ["]o"] = "@loop.*", + ["]s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, + ["]z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + ["[o"] = "@loop.*", + ["[s"] = { query = "@scope", query_group = "locals", desc = "Next scope" }, + ["[z"] = { query = "@fold", query_group = "folds", desc = "Next fold" }, + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + }, + goto_next = { + ["]d"] = "@conditional.outer", + }, + goto_previous = { + ["[d"] = "@conditional.outer", + }, + }, + select = { + enable = true, + lookahead = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" }, + ["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" }, + }, + selection_modes = { + ["@parameter.outer"] = "v", -- charwise + ["@function.outer"] = "V", -- linewise + ["@class.outer"] = "", -- blockwise + }, + include_surrounding_whitespace = false, + }, + swap = { + enable = true, + swap_next = { + ["a"] = "@parameter.inner", + }, + swap_previous = { + ["A"] = "@parameter.inner", + }, + }, + }, + }) + -- 开启 Folding + vim.wo.foldmethod = "expr" + vim.wo.foldexpr = "nvim_treesitter#foldexpr()" end, }, { From 91ffbb3fede1c3fbea3939c519bbcfa069ff8009 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 22 Jul 2023 11:30:14 +0800 Subject: [PATCH 210/708] incremental_selection --- lua/kide/plugins/lazy-nvim.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 72b28e29..5ef5838e 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -196,6 +196,18 @@ require("lazy").setup({ disable = {}, additional_vim_regex_highlighting = false, }, + indent = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, textobjects = { move = { enable = true, From 7777ad5dd8b8da1ade004c09c42ec06e1d3c8fb6 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 10:27:51 +0800 Subject: [PATCH 211/708] ui update --- ftplugin/alpha.lua | 1 - ftplugin/c.lua | 3 -- ftplugin/cpp.lua | 3 -- ftplugin/html.lua | 2 - ftplugin/java.lua | 3 -- ftplugin/javascript.lua | 3 -- ftplugin/lua.lua | 3 -- ftplugin/nginx.lua | 3 -- ftplugin/rust.lua | 3 -- init.lua | 28 +++++++++++ lua/kide/core/basic.lua | 14 ++---- lua/kide/lsp/java.lua | 4 ++ lua/kide/plugins/config/nvim-ufo.lua | 22 --------- lua/kide/plugins/lazy-nvim.lua | 71 +++++++++++++++++++++++++--- lua/kide/theme/gruvbox.lua | 6 ++- 15 files changed, 107 insertions(+), 62 deletions(-) delete mode 100644 ftplugin/alpha.lua delete mode 100644 ftplugin/c.lua delete mode 100644 ftplugin/cpp.lua delete mode 100644 ftplugin/html.lua delete mode 100644 ftplugin/java.lua delete mode 100644 ftplugin/javascript.lua delete mode 100644 ftplugin/lua.lua delete mode 100644 ftplugin/nginx.lua delete mode 100644 ftplugin/rust.lua delete mode 100644 lua/kide/plugins/config/nvim-ufo.lua diff --git a/ftplugin/alpha.lua b/ftplugin/alpha.lua deleted file mode 100644 index 4911e28c..00000000 --- a/ftplugin/alpha.lua +++ /dev/null @@ -1 +0,0 @@ -vim.opt_local.foldenable = false diff --git a/ftplugin/c.lua b/ftplugin/c.lua deleted file mode 100644 index 5603e941..00000000 --- a/ftplugin/c.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.foldcolumn = "1" -vim.opt_local.foldenable = true -vim.opt_local.signcolumn = "yes" diff --git a/ftplugin/cpp.lua b/ftplugin/cpp.lua deleted file mode 100644 index 5603e941..00000000 --- a/ftplugin/cpp.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.foldcolumn = "1" -vim.opt_local.foldenable = true -vim.opt_local.signcolumn = "yes" diff --git a/ftplugin/html.lua b/ftplugin/html.lua deleted file mode 100644 index 123c5e98..00000000 --- a/ftplugin/html.lua +++ /dev/null @@ -1,2 +0,0 @@ -vim.opt_local.foldcolumn = "1" -vim.opt_local.foldenable = true diff --git a/ftplugin/java.lua b/ftplugin/java.lua deleted file mode 100644 index 5603e941..00000000 --- a/ftplugin/java.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.foldcolumn = "1" -vim.opt_local.foldenable = true -vim.opt_local.signcolumn = "yes" diff --git a/ftplugin/javascript.lua b/ftplugin/javascript.lua deleted file mode 100644 index 5603e941..00000000 --- a/ftplugin/javascript.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.foldcolumn = "1" -vim.opt_local.foldenable = true -vim.opt_local.signcolumn = "yes" diff --git a/ftplugin/lua.lua b/ftplugin/lua.lua deleted file mode 100644 index 5603e941..00000000 --- a/ftplugin/lua.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.foldcolumn = "1" -vim.opt_local.foldenable = true -vim.opt_local.signcolumn = "yes" diff --git a/ftplugin/nginx.lua b/ftplugin/nginx.lua deleted file mode 100644 index 5603e941..00000000 --- a/ftplugin/nginx.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.foldcolumn = "1" -vim.opt_local.foldenable = true -vim.opt_local.signcolumn = "yes" diff --git a/ftplugin/rust.lua b/ftplugin/rust.lua deleted file mode 100644 index 5603e941..00000000 --- a/ftplugin/rust.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.foldcolumn = "1" -vim.opt_local.foldenable = true -vim.opt_local.signcolumn = "yes" diff --git a/init.lua b/init.lua index e7ae4853..73c8edcd 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,31 @@ -- math.randomseed(os.time()) +vim.g.transparent_mode = false + +if vim.g.neovide then + vim.g.transparent_mode = true + vim.g.neovide_cursor_vfx_mode = "railgun" + vim.opt_global.guifont = "Hack Nerd Font Mono,Hack:h13" + vim.g.neovide_fullscreen = false + vim.g.neovide_input_use_logo = true + local alpha = function() + return string.format("%x", math.floor(255 * vim.g.transparency or 0.8)) + end + -- g:neovide_transparency should be 0 if you want to unify transparency of content and title bar. + vim.g.neovide_transparency = 0.0 + vim.g.transparency = 0.8 + vim.g.neovide_background_color = "#282828" .. alpha() + + vim.g.neovide_floating_blur_amount_x = 2.0 + vim.g.neovide_floating_blur_amount_y = 2.0 + + vim.g.neovide_hide_mouse_when_typing = true + + vim.g.neovide_profiler = false + vim.g.neovide_padding_top = 0 + vim.g.neovide_padding_bottom = 0 + vim.g.neovide_padding_right = 0 + vim.g.neovide_padding_left = 0 +end + require("kide.core") require("kide.plugins") diff --git a/lua/kide/core/basic.lua b/lua/kide/core/basic.lua index 21f514e5..26b800de 100644 --- a/lua/kide/core/basic.lua +++ b/lua/kide/core/basic.lua @@ -52,7 +52,6 @@ vim.opt.fileencoding = "UTF-8" -- jk移动时光标下上方保留8行 vim.opt.scrolloff = 3 vim.opt.sidescrolloff = 3 -vim.opt.signcolumn = "auto" vim.opt.pumheight = 20 -- 缩进配置 vim.opt.tabstop = 4 @@ -137,20 +136,17 @@ vim.opt.timeoutlen = 450 vim.opt.mouse = "a" +-- vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] +vim.opt.foldcolumn = "0" +vim.opt.foldenable = true +vim.opt.signcolumn = "auto" + -- 默认不要折叠 -- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file vim.opt.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value vim.opt.foldlevelstart = 99 vim.opt_global.completeopt = "menu,menuone,noselect" -if vim.g.neovide then - vim.g.neovide_cursor_vfx_mode = "railgun" - vim.opt_global.guifont = "Hack Nerd Font Mono,Hack:h13" - vim.g.neovide_transparency = 1 - vim.g.neovide_fullscreen = true - vim.g.neovide_input_use_logo = true - vim.g.neovide_profiler = false -end -- use ethanholz/nvim-lastplace -- autocmd("BufReadPost", { diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index ca0d67d2..ee7f2de7 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -350,6 +350,10 @@ config["on_attach"] = function(client, buffer) end local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, +} -- capabilities.experimental = { -- hoverActions = true, -- hoverRange = true, diff --git a/lua/kide/plugins/config/nvim-ufo.lua b/lua/kide/plugins/config/nvim-ufo.lua deleted file mode 100644 index 3feb0fa6..00000000 --- a/lua/kide/plugins/config/nvim-ufo.lua +++ /dev/null @@ -1,22 +0,0 @@ -require("kide.core.keybindings").ufo_mapkey() - --- Option 3: treesitter as a main provider instead --- Only depend on `nvim-treesitter/queries/filetype/folds.scm`, --- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()` -local ftMap = { - c = { "treesitter" }, - cpp = { "treesitter" }, - rust = { "treesitter" }, - java = { "treesitter" }, - lua = { "treesitter" }, - html = { "treesitter" }, - nginx = { "indent" }, - vim = "indent", - python = { "indent" }, -} -require("ufo").setup({ - provider_selector = function(bufnr, filetype, buftype) - -- return { "treesitter", "indent" } - return ftMap[filetype] - end, -}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 5ef5838e..45b3e7ca 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -127,7 +127,9 @@ require("lazy").setup({ lazy = false, priority = 1000, config = function() - require("gruvbox").setup({}) + require("gruvbox").setup({ + transparent_mode = vim.g.transparent_mode, + }) vim.opt.background = "dark" vim.cmd([[colorscheme gruvbox]]) end, @@ -269,9 +271,9 @@ require("lazy").setup({ }, }, }) - -- 开启 Folding - vim.wo.foldmethod = "expr" - vim.wo.foldexpr = "nvim_treesitter#foldexpr()" + -- 开启 Folding see nvim-ufo + -- vim.wo.foldmethod = "expr" + -- vim.wo.foldexpr = "nvim_treesitter#foldexpr()" end, }, { @@ -821,9 +823,66 @@ require("lazy").setup({ { "kevinhwang91/nvim-ufo", lazy = true, - event = { "BufReadPost" }, + event = { "VeryLazy" }, config = function() - require("kide.plugins.config.nvim-ufo") + -- lsp->treesitter->indent + local ftMap = { + vim = "indent", + python = { "indent" }, + git = "", + } + + local function customizeSelector(bufnr) + local function handleFallbackException(err, providerName) + if type(err) == "string" and err:match("UfoFallbackException") then + return require("ufo").getFolds(bufnr, providerName) + else + return require("promise").reject(err) + end + end + + return require("ufo").getFolds(bufnr, "lsp") + :catch(function(err) + return handleFallbackException(err, "treesitter") + end) + :catch(function(err) + return handleFallbackException(err, "indent") + end) + end + local handler = function(virtText, lnum, endLnum, width, truncate) + local newVirtText = {} + local suffix = (" 󰁂 %d "):format(endLnum - lnum) + local sufWidth = vim.fn.strdisplaywidth(suffix) + local targetWidth = width - sufWidth + local curWidth = 0 + for _, chunk in ipairs(virtText) do + local chunkText = chunk[1] + local chunkWidth = vim.fn.strdisplaywidth(chunkText) + if targetWidth > curWidth + chunkWidth then + table.insert(newVirtText, chunk) + else + chunkText = truncate(chunkText, targetWidth - curWidth) + local hlGroup = chunk[2] + table.insert(newVirtText, { chunkText, hlGroup }) + chunkWidth = vim.fn.strdisplaywidth(chunkText) + -- str width returned from truncate() may less than 2nd argument, need padding + if curWidth + chunkWidth < targetWidth then + suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth) + end + break + end + curWidth = curWidth + chunkWidth + end + table.insert(newVirtText, { suffix, "MoreMsg" }) + return newVirtText + end + require("ufo").setup({ + provider_selector = function(bufnr, filetype, buftype) + return ftMap[filetype] or customizeSelector + end, + fold_virt_text_handler = handler, + }) + require("kide.core.keybindings").ufo_mapkey() end, }, diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index b2f75586..750341b9 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -77,8 +77,12 @@ M.load_highlights = function(hl_groups) end M.load_which_key_highlights = function() + local bg + if not vim.g.transparent_mode then + bg = colors.black3 + end M.load_highlights({ - WhichKeyFloat = { bg = colors.black3 }, + WhichKeyFloat = { bg = bg }, }) end From 9ea643e9d2a4804cf3961dceac7340367c68f028 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 10:51:10 +0800 Subject: [PATCH 212/708] =?UTF-8?q?=E7=AE=80=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/config/alpha-nvim.lua | 32 - lua/kide/plugins/config/ascli-header.lua | 695 ------------------- lua/kide/plugins/config/comment.lua | 1 - lua/kide/plugins/config/diffview-nvim.lua | 1 - lua/kide/plugins/config/markdown-preview.lua | 1 - lua/kide/plugins/config/mason-nvim.lua | 1 - lua/kide/plugins/config/neogen.lua | 6 - lua/kide/plugins/config/nvim-autopairs.lua | 5 - lua/kide/plugins/config/nvim-colorizer.lua | 27 - lua/kide/plugins/config/nvim-notify.lua | 35 - lua/kide/plugins/config/rest-nvim.lua | 22 - lua/kide/plugins/config/toggletasks.lua | 13 - lua/kide/plugins/config/translate.lua | 12 - lua/kide/plugins/config/wilder.lua | 39 -- lua/kide/plugins/lazy-nvim.lua | 154 +++- 15 files changed, 133 insertions(+), 911 deletions(-) delete mode 100644 lua/kide/plugins/config/alpha-nvim.lua delete mode 100644 lua/kide/plugins/config/ascli-header.lua delete mode 100644 lua/kide/plugins/config/comment.lua delete mode 100644 lua/kide/plugins/config/diffview-nvim.lua delete mode 100644 lua/kide/plugins/config/markdown-preview.lua delete mode 100644 lua/kide/plugins/config/mason-nvim.lua delete mode 100644 lua/kide/plugins/config/neogen.lua delete mode 100644 lua/kide/plugins/config/nvim-autopairs.lua delete mode 100644 lua/kide/plugins/config/nvim-colorizer.lua delete mode 100644 lua/kide/plugins/config/nvim-notify.lua delete mode 100644 lua/kide/plugins/config/rest-nvim.lua delete mode 100644 lua/kide/plugins/config/toggletasks.lua delete mode 100644 lua/kide/plugins/config/translate.lua delete mode 100644 lua/kide/plugins/config/wilder.lua diff --git a/lua/kide/plugins/config/alpha-nvim.lua b/lua/kide/plugins/config/alpha-nvim.lua deleted file mode 100644 index a86b67ff..00000000 --- a/lua/kide/plugins/config/alpha-nvim.lua +++ /dev/null @@ -1,32 +0,0 @@ -local alpha = require("alpha") -local dashboard = require("alpha.themes.dashboard") --- local ascli = require("kide.plugins.config.ascli-header") - --- Set header --- dashboard.section.header.val = ascli[math.random(0, #ascli)] -dashboard.section.header.val = { - " ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗", - " ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║", - " ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║", - " ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║", - " ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║", - " ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝", -} -local opt = { noremap = true, silent = true } --- Set menu -dashboard.section.buttons.val = { - dashboard.button(" ff", "󰈞 Find File", ":Telescope find_files", opt), - dashboard.button(" fg", "󰈭 Find Word ", ":Telescope live_grep", opt), - dashboard.button( - " fp", - " Recent Projects", - ":lua require'telescope'.extensions.project.project{ display_type = 'full' }", - opt - ), - dashboard.button(" fo", " Recent File", ":Telescope oldfiles", opt), - dashboard.button(" ns", " Settings", ":e $MYVIMRC | :cd %:p:h ", opt), - dashboard.button(" q ", "󰅙 Quit NVIM", ":qa", opt), -} - --- Send config to alpha -alpha.setup(dashboard.opts) diff --git a/lua/kide/plugins/config/ascli-header.lua b/lua/kide/plugins/config/ascli-header.lua deleted file mode 100644 index add5934d..00000000 --- a/lua/kide/plugins/config/ascli-header.lua +++ /dev/null @@ -1,695 +0,0 @@ -local M = {} -M[0] = { - " ▄█ █ █▄ ", - " ▐██ ▄█ ███ █▄ ██▌ ", - " ▐██▌ ██████████████ ▐██▌ ", - " ████ ████████████████ ████ ", - " ▐█████ ██████████████████ █████▌ ", - " ████████████████████████████████ ", - " ███████▀▀████████████▀▀███████ ", - " █████▌ ▄▄ ▀████▀ ▄▄ ▐█████ ", - " ▄▄██████▄ ▀▀ ████ ▀▀ ▄██████▄▄ ", - " ██████████████████████████████████ ", - " ████████████████████████████████████ ", - " ██████ ███████▀▄██▄▀███████ ██████▌ ", - "▐█████ ██████████████████ █████▌ ", - " ▐█████ ██████▀ ▀██████ █████▌ ", - " █████▄ ███ ███ ▄█████ ", - " ██████ █ █ ██████ ", - " █████ █████ ", - " █████ █████ ", - " ████ ▄ ▄ ████ ", - " ████ ██ ██ ████ ", - " ████████ ▄██▄ ████████ ", - " ████████████████████████ ", - " ████████████████████████ ", - " ▀█████████▀▀█████████▀ ", - " ▀███▀ ▀███▀ ", -} - -M[1] = { - " ███████████████████████████ ", - " ███████▀▀▀░░░░░░░▀▀▀███████ ", - " ████▀░░░░░░░░░░░░░░░░░▀████ ", - " ███│░░░░░░░░░░░░░░░░░░░│███ ", - " ██▌│░░░░░░░░░░░░░░░░░░░│▐██ ", - " ██░└┐░░░░░░░░░░░░░░░░░┌┘░██ ", - " ██░░└┐░░░░░░░░░░░░░░░┌┘░░██ ", - " ██░░┌┘▄▄▄▄▄░░░░░▄▄▄▄▄└┐░░██ ", - " ██▌░│██████▌░░░▐██████│░▐██ ", - " ███░│▐███▀▀░░▄░░▀▀███▌│░███ ", - " ██▀─┘░░░░░░░▐█▌░░░░░░░└─▀██ ", - " ██▄░░░▄▄▄▓░░▀█▀░░▓▄▄▄░░░▄██ ", - " ████▄─┘██▌░░░░░░░▐██└─▄████ ", - " █████░░▐█─┬┬┬┬┬┬┬─█▌░░█████ ", - " ████▌░░░▀┬┼┼┼┼┼┼┼┬▀░░░▐████ ", - " █████▄░░░└┴┴┴┴┴┴┴┘░░░▄█████ ", - " ███████▄░░░░░░░░░░░▄███████ ", - " ██████████▄▄▄▄▄▄▄██████████ ", -} - -M[2] = { - " ▄▄▄▄▄███████████████████▄▄▄▄▄ ", - " ▄██████████▀▀▀▀▀▀▀▀▀▀██████▀████▄ ", - " █▀████████▄ ▀▀████ ▀██▄ ", - " █▄▄██████████████████▄▄▄ ▄██▀ ", - " ▀█████████████████████████▄ ▄██▀ ", - " ▀████▀▀▀▀▀▀▀▀▀▀▀▀█████████▄▄██▀ ", - " ▀███▄ ▀██████▀ ", - " ▀██████▄ ▄████▀ ", - " ▀█████▄▄▄▄▄▄▄███▀ ", - " ▀████▀▀▀████▀ ", - " ▀███▄███▀ ", - " ▀█▀ ", -} - -M[3] = { - " ⠀⠀⠀⠀⠀⠀⠀⡴⠞⠉⢉⣭⣿⣿⠿⣳⣤⠴⠖⠛⣛⣿⣿⡷⠖⣶⣤⡀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⣼⠁⢀⣶⢻⡟⠿⠋⣴⠿⢻⣧⡴⠟⠋⠿⠛⠠⠾⢛⣵⣿⠀⠀⠀⠀ ", - " ⣼⣿⡿⢶⣄⠀⢀⡇⢀⡿⠁⠈⠀⠀⣀⣉⣀⠘⣿⠀⠀⣀⣀⠀⠀⠀⠛⡹⠋⠀⠀⠀⠀ ", - " ⣭⣤⡈⢑⣼⣻⣿⣧⡌⠁⠀⢀⣴⠟⠋⠉⠉⠛⣿⣴⠟⠋⠙⠻⣦⡰⣞⠁⢀⣤⣦⣤⠀ ", - " ⠀⠀⣰⢫⣾⠋⣽⠟⠑⠛⢠⡟⠁⠀⠀⠀⠀⠀⠈⢻⡄⠀⠀⠀⠘⣷⡈⠻⣍⠤⢤⣌⣀ ", - " ⢀⡞⣡⡌⠁⠀⠀⠀⠀⢀⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⢿⡀⠀⠀⠀⠸⣇⠀⢾⣷⢤⣬⣉ ", - " ⡞⣼⣿⣤⣄⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⣿⠀⠸⣿⣇⠈⠻ ", - " ⢰⣿⡿⢹⠃⠀⣠⠤⠶⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⣿⠀⠀⣿⠛⡄⠀ ", - " ⠈⠉⠁⠀⠀⠀⡟⡀⠀⠈⡗⠲⠶⠦⢤⣤⣤⣄⣀⣀⣸⣧⣤⣤⠤⠤⣿⣀⡀⠉⣼⡇⠀ ", - " ⣿⣴⣴⡆⠀⠀⠻⣄⠀⠀⠡⠀⠀⠀⠈⠛⠋⠀⠀⠀⡈⠀⠻⠟⠀⢀⠋⠉⠙⢷⡿⡇⠀ ", - " ⣻⡿⠏⠁⠀⠀⢠⡟⠀⠀⠀⠣⡀⠀⠀⠀⠀⠀⢀⣄⠀⠀⠀⠀⢀⠈⠀⢀⣀⡾⣴⠃⠀ ", - " ⢿⠛⠀⠀⠀⠀⢸⠁⠀⠀⠀⠀⠈⠢⠄⣀⠠⠼⣁⠀⡱⠤⠤⠐⠁⠀⠀⣸⠋⢻⡟⠀⠀ ", - " ⠈⢧⣀⣤⣶⡄⠘⣆⠀⠀⠀⠀⠀⠀⠀⢀⣤⠖⠛⠻⣄⠀⠀⠀⢀⣠⡾⠋⢀⡞⠀⠀⠀ ", - " ⠀⠀⠻⣿⣿⡇⠀⠈⠓⢦⣤⣤⣤⡤⠞⠉⠀⠀⠀⠀⠈⠛⠒⠚⢩⡅⣠⡴⠋⠀⠀⠀⠀ ", - " ⠀⠀⠀⠈⠻⢧⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠐⣻⠿⠋⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠉⠓⠶⣤⣄⣀⡀⠀⠀⠀⠀⠀⢀⣀⣠⡴⠖⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀ ", -} - -M[4] = { - " ⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣤⣴⣶⣶⣶⣶⣶⠶⣶⣤⣤⣀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⢀⣤⣾⣿⣿⣿⠁⠀⢀⠈⢿⢀⣀⠀⠹⣿⣿⣿⣦⣄⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⠿⠀⠀⣟⡇⢘⣾⣽⠀⠀⡏⠉⠙⢛⣿⣷⡖⠀ ", - " ⠀⠀⠀⠀⠀⣾⣿⣿⡿⠿⠷⠶⠤⠙⠒⠀⠒⢻⣿⣿⡷⠋⠀⠴⠞⠋⠁⢙⣿⣄ ", - " ⠀⠀⠀⠀⢸⣿⣿⣯⣤⣤⣤⣤⣤⡄⠀⠀⠀⠀⠉⢹⡄⠀⠀⠀⠛⠛⠋⠉⠹⡇ ", - " ⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⣀⣠⣤⣤⣤⣤⣤⣤⣤⣼⣇⣀⣀⣀⣛⣛⣒⣲⢾⡷ ", - " ⢀⠤⠒⠒⢼⣿⣿⠶⠞⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⣼⠃ ", - " ⢮⠀⠀⠀⠀⣿⣿⣆⠀⠀⠻⣿⡿⠛⠉⠉⠁⠀⠉⠉⠛⠿⣿⣿⠟⠁⠀⣼⠃⠀ ", - " ⠈⠓⠶⣶⣾⣿⣿⣿⣧⡀⠀⠈⠒⢤⣀⣀⡀⠀⠀⣀⣀⡠⠚⠁⠀⢀⡼⠃⠀⠀ ", - " ⠀⠀⠀⠈⢿⣿⣿⣿⣿⣿⣷⣤⣤⣤⣤⣭⣭⣭⣭⣭⣥⣤⣤⣤⣴⣟⠁ ", -} - -M[5] = { - " ▄▄▄▄▄▄▄▄▄ ", - " ▄█████████████▄ ", - " █████ █████████████████ █████ ", - " ▐████▌ ▀███▄ ▄███▀ ▐████▌ ", - " █████▄ ▀███▄ ▄███▀ ▄█████ ", - " ▐██▀███▄ ▀███▄███▀ ▄███▀██▌ ", - " ███▄▀███▄ ▀███▀ ▄███▀▄███ ", - " ▐█▄▀█▄▀███ ▄ ▀ ▄ ███▀▄█▀▄█▌ ", - " ███▄▀█▄██ ██▄██ ██▄█▀▄███ ", - " ▀███▄▀██ █████ ██▀▄███▀ ", - " █▄ ▀█████ █████ █████▀ ▄█ ", - " ███ ███ ███ ", - " ███▄ ▄█ ███ █▄ ▄███ ", - " █████ ▄███ ███ ███▄ █████ ", - " █████ ████ ███ ████ █████ ", - " █████ ████▄▄▄▄▄████ █████ ", - " ▀███ █████████████ ███▀ ", - " ▀█ ███ ▄▄▄▄▄ ███ █▀ ", - " ▀█▌▐█████▌▐█▀ ", - " ███████ ", -} - -M[6] = { - " ████ ████ ", - " ███ ███ ", - " ███ ███ ", - " ███ ███ ", - " ███ ███ ", - "████ ████ ", - "████ ████ ", - "██████ ███████ ██████ ", - "█████████████████████████████████ ", - " ███████████████████████████████ ", - " ████ ███████████████████ ████ ", - " ███▀███████████▀███ ", - " ████──▀███████▀──████ ", - " █████───█████───█████ ", - " ███████████████████ ", - " █████████████████ ", - " ███████████████ ", - " █████████████ ", - " ███████████ ", - " ███──▀▀▀──███ ", - " ███─█████─███ ", - " ███─███─███ ", - " █████████ ", -} - -M[7] = { - " ▄█ ", - " ▄██░█ ", - " ██ ██░░░░█ ", - " ██░░█ █░░░░░░█ ", - " ▄█░░░███░░░░░██ ", - " █░░░░█░░░░░░██████████▀ ", - " █░░░░▄▄▄▄▄░░░░░░░░░░█ ", - " ▀███████░▐░░░░░░░░░▌░░░░░█ ", - " ██░░░░▐░░▄██████████▄░█ ", - " █░░░░▌▄███████▀▀▀▀█▀█▀ ", - " ██░░▄▄████████░░░░▌░██ ", - " █▐██████▌███▌░░░░▐░░██ ", - " ██▌████▐██▐░░░░░▐░░░░██ ", - " █▐█▐▌█▀███▀▀░░░░░▐░░░░░██ ", - " █░░██▐█░░▄░░░▄█░░░▐░░░░░░██ ", - " █░░░▐▌█▌▀▀░░░█░█▌░░▐░░░░████ ", - " █░░░░▐▀▀░░░░▄█░░█▌░░▌░░███ ", - " ▄██░░░░░▌░░░▄██░▄██▌░▐░███ ", - " ██░░░▐░░▀█▄░▄███▌░▐░░█ ", - " ███░░█░░░██▀▀░█░░▌░░░█ ", - " █░░░▌░░▐█████░▐░░░░██ ", - " █░░░░░▀▄▄░░░░░█░░░░░░██ ", - " ██░░░░░░░░▀▄▄▄▀░░████████▄ ", - " █░█████░░░░░█░░░░█ ", - " ██ ██░░░░██░░░█ ", - " █ █░░░█ ███░░█ ", - " █░░░█ ██░█ ", - " █░░░█ ██ ", - " █░█ ", -} - -M[8] = { - " ▄▄██████████▄▄ ", - " ▀▀▀ ██ ▀▀▀ ", - " ▄██▄ ▄▄████████████▄▄ ▄██▄ ", - " ▄███▀ ▄████▀▀▀ ▀▀▀████▄ ▀███▄ ", - " ████▄ ▄███▀ ▀███▄ ▄████ ", - " ███▀█████▀▄████▄ ▄████▄▀█████▀███ ", - " ██▀ ███▀ ██████ ██████ ▀███ ▀██ ", - " ▀ ▄██▀ ▀████▀ ▄▄ ▀████▀ ▀██▄ ▀ ", - " ███ ▀▀ ███ ", - " ██████████████████████████████ ", - " ▄█ ▀██ ███ ██ ██ ███ ██▀ █▄ ", - " ███ ███ ███ ██ ██ ███▄███ ███ ", - " ▀██▄████████ ██ ██ ████████▄██▀ ", - " ▀███▀ ▀████ ██ ██ ████▀ ▀███▀ ", - " ▀███▄ ▀███████ ███████▀ ▄███▀ ", - " ▀███ ▀▀██████████▀▀▀ ███▀ ", - " ▀ ▄▄▄ ██ ▄▄▄ ▀ ", - " ▀████████████▀ ", -} - -M[9] = { - " ▄▄▀▀▀▀▀▀▀▀▄▄ ", - " ▄▀▀ ▀▄▄ ", - " ▄▀ ▀▄ ", - " ▌ ▀▄ ▀▀▄ ", - " ▌ ▀▌ ▌ ", - " ▐ ▌ ▐ ", - " ▌▐ ▐ ▐ ▌ ▌ ", - " ▐ ▌ ▌ ▐ ▌ ▐ ▌▐ ▐ ", - " ▐ ▌ ▌▄▄▀▀▌▌ ▐▀▌▀▌▄ ▐ ▌ ▌ ", - " ▌▌ ▐▀▄▌▌▐▐ ▐▐▐ ▐ ▌▌ ▐ ▌▄▐ ", - " ▄▀▄▐ ▌▌▄▀▄▐ ▌▌ ▐ ▌▄▀▄ ▐ ▐ ▌ ▀▄ ", - " ▀▄▀ ▌ ▄▀ ▌█▐ ▐▐▀ ▌█▐ ▀▄▐ ▌▌ ▀ ", - " ▀▀▄▄▐ ▀▄▀ ▀▄▀ ▀▄▀▄▀ ▌ ▐ ", - " ▀▐▀▄ ▀▄ ▐ ▀▌▐ ", - " ▌ ▌▐ ▀ ▐ ▐ ", - " ▐ ▐ ▌ ▄▄▀▀▀▀▄ ▌ ▐ ", - " ▌▐ ▐▄ ▐ ▌ ▄▀ ▐ ", - " ▐ ▌▐▐▀▄ ▀▄▄▄▀ ▄▀▐ ▐ ", - " ▌▌ ▌▐ ▌ ▀▄▄ ▄▌▐ ▌ ▐ ", - " ▐ ▐ ▐▐ ▌ ▀▀▄▀▌▐ ▌ ▌ ", - " ▌ ▌▐ ▌ ▐▀▄▌ ▐ ", -} - -M[10] = { - " ▀████▀▄▄ ▄█ ", - " █▀ ▀▀▄▄▄▄▄ ▄▄▀▀█ ", - " ▄ █ ▀▀▀▀▄ ▄▀ ", - " ▄▀ ▀▄ ▀▄ ▀▄▀ ", - " ▄▀ █ █▀ ▄█▀▄ ▄█ ", - " ▀▄ ▀▄ █ ▀██▀ ██▄█ ", - " ▀▄ ▄▀ █ ▄██▄ ▄ ▄ ▀▀ █ ", - " █ ▄▀ █ ▀██▀ ▀▀ ▀▀ ▄▀ ", - " █ █ █ ▄▄ ▄▀ ", -} - -M[11] = { - " ▄████████▄ ", - " ▄█▀▒▒▒▒▒▒▒▀██▄ ", - " ▄█▀▒▒▒▒▒▒▄▒▒▒▒▒▒▐█▌ ", - " ▄█▒▒▒▒▒▒▒▒▒▒▀█▒▒▒▄██ ", - " ▄█▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▀▒▒▒█▄ ", - " ▄█▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▄ ", - " ▄█▒▒▒▄██████▄▒▒▒▒▄█████▄▒▒▒▒█ ", - " █▒▒▒█▀░░░░░▀█ ▒▒▒█▀░░░░▀█▒▒▒█ ", - " █▒▒▒█░░▄░░░░▀████▀░░░▄░░█▒▒▒█ ", - " ▄███▄▒█▄░▐▀▄░░░░░░░░░▄▀▌░▄█▒▒███▄", - " █▀░░█▄▒█░▐▐▀▀▄▄▄ ▄▄▄▀▀▌▌░█▒▒█░░▀█", - " █░░░░█▒█░▐▐ ▄▄ █ ▄▄ ▌▌░█▒█░░░░█", - " █░▄░░█▒█░▐▐▄ ▀▀ █ ▀▀ ▄▌▌░█▒█░░▄░█", - " █░░█░█▒█░░▌▄█▄▄▀ ▀▄▄█▄▐░░█▒█░█░░█", - " █▄░█████████▀░░▀▄▀░░▀█████████░▄█", - " ██▀░░▄▀░░▀░░▀▄░░░▄▀░░▀░░▀▄░░▀██ ", - " ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██", - " █░▄░░░░░░░░░░░░░░░░░░░░░░░░░░░▄░█", - " █░▀█▄░░░░░░░░░░░░░░░░░░░░░░░▄█▀░█", - " █░░█▀███████████████████████▀█░░█", - " █░░█ █ █ █ █ █ █░░█", - " █░░░▀█▄▄█▄▄▄█▄▄▄█▄▄▄█▄▄▄█▄▄█▀░░░█", - " ▀█░░▀█▄█ █ █ █ █▄█▀░░░█▀ ", - " ▀█░░░▀▀█▄▄ █ █ █▄▄█▀▀░░░░█▀ ", - " ▀█░░░░░▀▀█████████▀▀░░░░░░█▀ ", - " ▀█░░░░░░░▄░░░░░░░▄░░░░░░█▀ ", - " ▀██▄░░░▀▀▀▀▀▀▀▀▀░░░▄██▀ ", - " ▀██▄▄░░░░░░░▄▄██▀ ", - " ▀▀███████▀▀ ", -} - -M[12] = { - " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠤⠖⠚⢉⣩⣭⡭⠛⠓⠲⠦⣄⡀⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⢀⡴⠋⠁⠀⠀⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠳⢦⡀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⢀⡴⠃⢀⡴⢳⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣆⠀⠀⠀ ", - " ⠀⠀⠀⠀⡾⠁⣠⠋⠀⠈⢧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢧⠀⠀ ", - " ⠀⠀⠀⣸⠁⢰⠃⠀⠀⠀⠈⢣⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣇⠀ ", - " ⠀⠀⠀⡇⠀⡾⡀⠀⠀⠀⠀⣀⣹⣆⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⠀ ", - " ⠀⠀⢸⠃⢀⣇⡈⠀⠀⠀⠀⠀⠀⢀⡑⢄⡀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇ ", - " ⠀⠀⢸⠀⢻⡟⡻⢶⡆⠀⠀⠀⠀⡼⠟⡳⢿⣦⡑⢄⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇ ", - " ⠀⠀⣸⠀⢸⠃⡇⢀⠇⠀⠀⠀⠀⠀⡼⠀⠀⠈⣿⡗⠂⠀⠀⠀⠀⠀⠀⠀⢸⠁ ", - " ⠀⠀⡏⠀⣼⠀⢳⠊⠀⠀⠀⠀⠀⠀⠱⣀⣀⠔⣸⠁⠀⠀⠀⠀⠀⠀⠀⢠⡟⠀ ", - " ⠀⠀⡇⢀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⠃⠀ ", - " ⠀⢸⠃⠘⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠁⠀⠀⢀⠀⠀⠀⠀⠀⣾⠀⠀ ", - " ⠀⣸⠀⠀⠹⡄⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⡞⠀⠀⠀⠸⠀⠀⠀⠀⠀⡇⠀⠀ ", - " ⠀⡏⠀⠀⠀⠙⣆⠀⠀⠀⠀⠀⠀⠀⢀⣠⢶⡇⠀⠀⢰⡀⠀⠀⠀⠀⠀⡇⠀⠀ ", - " ⢰⠇⡄⠀⠀⠀⡿⢣⣀⣀⣀⡤⠴⡞⠉⠀⢸⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⣧⠀⠀ ", - " ⣸⠀⡇⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⢹⠀⠀⢸⠀⠀⢀⣿⠇⠀⠀⠀⠁⠀⢸⠀⠀ ", - " ⣿⠀⡇⠀⠀⠀⠀⠀⢀⡤⠤⠶⠶⠾⠤⠄⢸⠀⡀⠸⣿⣀⠀⠀⠀⠀⠀⠈⣇⠀ ", - " ⡇⠀⡇⠀⠀⡀⠀⡴⠋⠀⠀⠀⠀⠀⠀⠀⠸⡌⣵⡀⢳⡇⠀⠀⠀⠀⠀⠀⢹⡀ ", - " ⡇⠀⠇⠀⠀⡇⡸⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠮⢧⣀⣻⢂⠀⠀⠀⠀⠀⠀⢧ ", - " ⣇⠀⢠⠀⠀⢳⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡎⣆⠀⠀⠀⠀⠀⠘ ", -} - -M[13] = { - "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀ ", - "⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀ ", - "⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀ ", - "⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀ ", - "⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀ ", - "⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀ ", - "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀ ", -} - -M[14] = { - "", - "⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣠⣤⣤⣴⣦⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠀⢀⣤⣾⣿⣿⣿⣿⠿⠿⠿⠿⣿⣿⣿⣿⣶⣤⡀⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⣠⣾⣿⣿⡿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢿⣿⣿⣶⡀⠀⠀⠀⠀ ", - "⠀⠀⠀⣴⣿⣿⠟⠁⠀⠀⠀⣶⣶⣶⣶⡆⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣦⠀⠀⠀ ", - "⠀⠀⣼⣿⣿⠋⠀⠀⠀⠀⠀⠛⠛⢻⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣧⠀⠀ ", - "⠀⢸⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⣿⡇⠀ ", - "⠀⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⠀ ", - "⠀⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⡟⢹⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⣹⣿⣿⠀ ", - "⠀⣿⣿⣷⠀⠀⠀⠀⠀⠀⣰⣿⣿⠏⠀⠀⢻⣿⣿⡄⠀⠀⠀⠀⠀⠀⣿⣿⡿⠀ ", - "⠀⢸⣿⣿⡆⠀⠀⠀⠀⣴⣿⡿⠃⠀⠀⠀⠈⢿⣿⣷⣤⣤⡆⠀⠀⣰⣿⣿⠇⠀ ", - "⠀⠀⢻⣿⣿⣄⠀⠀⠾⠿⠿⠁⠀⠀⠀⠀⠀⠘⣿⣿⡿⠿⠛⠀⣰⣿⣿⡟⠀⠀ ", - "⠀⠀⠀⠻⣿⣿⣧⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⠏⠀⠀⠀ ", - "⠀⠀⠀⠀⠈⠻⣿⣿⣷⣤⣄⡀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⠟⠁⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠀⠈⠛⠿⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠋⠁⠀⠀⠀⠀⠀⠀ ", - "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠛⠛⠛⠛⠛⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", -} - -M[15] = { - " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡴⣪⣭⣿⣷⣶⣄⠀⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⠤⢤⢔⡾⣹⣿⣿⣿⣿⣿⣿⣷⡄⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⢰⢳⣿⣿⣿⠋⣻⣿⣿⣿⣿⣿⣿⣾⣿⠟⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⢀⠔⠁⠀⠀⠀⢸⣼⣷⣻⣧⣴⣿⣏⣿⣿⣿⣿⣿⣿⣿⣶⣶⣦⠤ ", - " ⠀⠀⠀⠀⢠⠇⠀⠀⠀⠀⠀⠈⢿⣿⣷⣿⣏⡿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⠁⠀ ", - " ⠀⠀⠀⢀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠹⢿⣿⣿⣿⣝⣿⣯⣾⠋⣇⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⢠⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⡄⠀⠀⠙⣽⣝⠋⢡⣯⣀⠘⢦⡀⠀⠀⠀⠀ ", - " ⠀⠀⡷⡁⠀⡄⠀⢠⠻⠀⠀⠀⢸⠙⠀⠀⠀⠙⡇⢹⣧⠛⠂⠀⢤⣉⠢⡀⠀⠀ ", - " ⡠⢊⠚⢇⣰⢣⠀⡞⠒⠣⠀⠀⠘⡄⠘⠓⠲⢆⣳⠀⠀⣠⣄⣀⣀⠙⢯⣾⡄⠀ ", - " ⣇⣇⡌⠈⡜⡌⢳⣧⣤⣄⡑⠄⣀⣳⢀⣠⣤⣴⣾⡆⠀⣿⠖⣠⣮⠀⠀⣿⠇⠀ ", - " ⠈⠛⢇⠀⠿⠷⡘⣿⢙⠿⡏⠀⠈⠉⢻⣻⣿⡏⢹⡟⣢⣿⣟⡻⠋⢀⡴⠁⠀⠀ ", - " ⠀⠀⠈⠢⢤⣀⣋⡿⢮⡉⠁⠀⠀⠀⠈⢉⣙⠷⠛⠺⣿⣙⣛⠭⠝⠋⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡩⠒⠶⠲⠞⠓⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣵⣕⣉⣫⣿⣦⠀⠱⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⡾⡿⡟⣻⣿⡏⠱⣮⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⣰⢿⡛⣿⣾⣜⣾⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⢀⣴⣿⣾⣿⣿⣿⣿⣿⣿⣾⡏⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⢀⣵⣿⣿⣿⣿⣿⣿⣿⡿⣿⣿⣿⣿⣿⣯⣿⣿⠟⠃⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠈⢻⣿⣿⣶⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠟⠀⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⠈⠻⠿⠿⣿⣿⣿⣿⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", - " ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣽⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ", -} - -M[16] = { - "", - " ████▌█████▌█ ████████▐▀██▀ ", - " ▄█████ █████▌ █ ▀██████▌█▄▄▀▄ ", - " ▌███▌█ ▐███▌▌ ▄▄ ▌█▌███▐███ ▀ ", - " ▐ ▐██ ▄▄▐▀█ ▐▄█▀▌█▐███▐█ ", - " ███ ▌▄█▌ ▀ ▀██ ▀██████▌ ", - " ▀█▌▀██▀ ▄ ███▐███ ", - " ██▌ ▐███████▌ ", - " ███ ▀█▀ ▐██▐███▀▌ ", - " ▌█▌█▄ ▄▄████▀ ▀ ", - " █▀██▄▄▄ ▄▄▀▀▒█▀█ ", - "", -} - -M[17] = { - "", - "", - " ⢀⣴⡾⠃⠄⠄⠄⠄⠄⠈⠺⠟⠛⠛⠛⠛⠻⢿⣿⣿⣿⣿⣶⣤⡀ ", - " ⢀⣴⣿⡿⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣸⣿⣿⣿⣿⣿⣿⣿⣷ ", - " ⣴⣿⡿⡟⡼⢹⣷⢲⡶⣖⣾⣶⢄⠄⠄⠄⠄⠄⢀⣼⣿⢿⣿⣿⣿⣿⣿⣿⣿ ", - " ⣾⣿⡟⣾⡸⢠⡿⢳⡿⠍⣼⣿⢏⣿⣷⢄⡀⠄⢠⣾⢻⣿⣸⣿⣿⣿⣿⣿⣿⣿ ", - " ⣡⣿⣿⡟⡼⡁⠁⣰⠂⡾⠉⢨⣿⠃⣿⡿⠍⣾⣟⢤⣿⢇⣿⢇⣿⣿⢿⣿⣿⣿⣿⣿ ", - " ⣱⣿⣿⡟⡐⣰⣧⡷⣿⣴⣧⣤⣼⣯⢸⡿⠁⣰⠟⢀⣼⠏⣲⠏⢸⣿⡟⣿⣿⣿⣿⣿⣿ ", - " ⣿⣿⡟⠁⠄⠟⣁⠄⢡⣿⣿⣿⣿⣿⣿⣦⣼⢟⢀⡼⠃⡹⠃⡀⢸⡿⢸⣿⣿⣿⣿⣿⡟ ", - " ⣿⣿⠃⠄⢀⣾⠋⠓⢰⣿⣿⣿⣿⣿⣿⠿⣿⣿⣾⣅⢔⣕⡇⡇⡼⢁⣿⣿⣿⣿⣿⣿⢣ ", - " ⣿⡟⠄⠄⣾⣇⠷⣢⣿⣿⣿⣿⣿⣿⣿⣭⣀⡈⠙⢿⣿⣿⡇⡧⢁⣾⣿⣿⣿⣿⣿⢏⣾ ", - " ⣿⡇⠄⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢻⠇⠄⠄⢿⣿⡇⢡⣾⣿⣿⣿⣿⣿⣏⣼⣿ ", - " ⣿⣷⢰⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⢰⣧⣀⡄⢀⠘⡿⣰⣿⣿⣿⣿⣿⣿⠟⣼⣿⣿ ", - " ⢹⣿⢸⣿⣿⠟⠻⢿⣿⣿⣿⣿⣿⣿⣿⣶⣭⣉⣤⣿⢈⣼⣿⣿⣿⣿⣿⣿⠏⣾⣹⣿⣿ ", - " ⢸⠇⡜⣿⡟⠄⠄⠄⠈⠙⣿⣿⣿⣿⣿⣿⣿⣿⠟⣱⣻⣿⣿⣿⣿⣿⠟⠁⢳⠃⣿⣿⣿ ", - " ⣰⡗⠹⣿⣄⠄⠄⠄⢀⣿⣿⣿⣿⣿⣿⠟⣅⣥⣿⣿⣿⣿⠿⠋ ⣾⡌⢠⣿⡿⠃ ", - " ⠜⠋⢠⣷⢻⣿⣿⣶⣾⣿⣿⣿⣿⠿⣛⣥⣾⣿⠿⠟⠛⠉ ", - "", - "", -} - -M[18] = { - "", - " ⣿⡇⣿⣿⣿⠛⠁⣴⣿⡿⠿⠧⠹⠿⠘⣿⣿⣿⡇⢸⡻⣿⣿⣿⣿⣿⣿⣿ ", - " ⢹⡇⣿⣿⣿⠄⣞⣯⣷⣾⣿⣿⣧⡹⡆⡀⠉⢹⡌⠐⢿⣿⣿⣿⡞⣿⣿⣿ ", - " ⣾⡇⣿⣿⡇⣾⣿⣿⣿⣿⣿⣿⣿⣿⣄⢻⣦⡀⠁⢸⡌⠻⣿⣿⣿⡽⣿⣿ ", - " ⡇⣿⠹⣿⡇⡟⠛⣉⠁⠉⠉⠻⡿⣿⣿⣿⣿⣿⣦⣄⡉⠂⠈⠙⢿⣿⣝⣿ ", - " ⠤⢿⡄⠹⣧⣷⣸⡇⠄⠄⠲⢰⣌⣾⣿⣿⣿⣿⣿⣿⣶⣤⣤⡀⠄⠈⠻⢮ ", - " ⣧⠄⢘⢻⣿⡇⢀⣀⠄⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⠄⢀ ", - " ⣿⡆⢸⣿⣿⣿⣬⣭⣴⣿⣿⣿⣿⣿⣿⣿⣯⠝⠛⠛⠙⢿⡿⠃⠄⢸ ", - " ⢿⣿⡀⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⡾⠁⢠⡇⢀ ", - " ⢸⣿⡇⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣏⣫⣻⡟⢀⠄⣿⣷⣾ ", - " ⢸⣿⡇⠄⠈⠙⠿⣿⣿⣿⣮⣿⣿⣿⣿⣿⣿⣿⣿⡿⢠⠊⢀⡇⣿⣿ ", - " ⣿⡇⢀⡲⠄⠄⠈⠙⠻⢿⣿⣿⠿⠿⠟⠛⠋⠁⣰⠇ ⢸⣿⣿⣿ ", - " ⣿⡇⢬⡻⡇⡄⠄⠄⠄⡰⢖⠔⠉⠄⠄⠄⠄⣼⠏ ⢸⣿⣿⣿ ", - " ⣿⡇⠄⠙⢌⢷⣆⡀⡾⡣⠃⠄⠄⠄⠄⠄⣼⡟ ⢿⣿⣿ ", - "", -} - -M[19] = { - "", - " ⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄ ", - " ⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄ ", - " ⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄ ", - " ⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄ ", - " ⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰ ", - " ⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤ ", - " ⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗ ", - " ⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟ ", - " ⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃ ", - " ⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃ ", - " ⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃ ", - " ⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁ ", - " ⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁ ", - " ⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁ ⢀⣠⣴ ", - " ⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿⣿⣿ ", - "", -} - -M[20] = { - "", - " ⣿⢸⣿⣿⣿⣿⣿⢹⣿⣿⣿⣿⣿⢿⣿⡇⡇⣿⣿⡇⢹⣿⣿⣿⣿⣿⣿⠄⢸⣿ ", - " ⡟⢸⣿⣿⣭⣭⡭⣼⣶⣿⣿⣿⣿⢸⣧⣇⠇⢸⣿⣿⠈⣿⣿⣿⣿⣿⣿⡆⠘⣿ ", - " ⡇⢸⣿⣿⣿⣿⡇⣻⡿⣿⣿⡟⣿⢸⣿⣿⠇⡆⣝⠿⡌⣸⣿⣿⣿⣿⣿⡇⠄⣿ ", - " ⢣⢾⣾⣷⣾⣽⣻⣿⣇⣿⣿⣧⣿⢸⣿⣿⡆⢸⣹⣿⣆⢥⢛⡿⣿⣿⣿⡇⠄⣿ ", - " ⣛⡓⣉⠉⠙⠻⢿⣿⣿⣟⣻⠿⣹⡏⣿⣿⣧⢸⣧⣿⣿⣨⡟⣿⣿⣿⣿⡇⠄⣿ ", - " ⠸⣷⣹⣿⠄⠄⠄⠄⠘⢿⣿⣿⣯⣳⣿⣭⣽⢼⣿⣜⣿⣇⣷⡹⣿⣿⣿⠁⢰⣿ ", - " ⢻⣷⣿⡄⢈⠿⠇⢸⣿⣿⣿⣿⣿⣿⣟⠛⠲⢯⣿⣒⡾⣼⣷⡹⣿⣿⠄⣼⣿ ", - " ⡄⢸⣿⣿⣷⣬⣽⣯⣾⣿⣿⣿⣿⣿⣿⣿⣿⡀⠄⢀⠉⠙⠛⠛⠳⠽⠿⢠⣿⣿ ", - " ⡇⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⢄⣹⡿⠃⠄⠄⣰⠎⡈⣾⣿⣿ ", - " ⡇⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣾⣭⣽⣖⣄⣴⣯⣾⢷⣿⣿⣿ ", - " ⣧⠸⣿⣿⣿⣿⣿⣿⠯⠊⠙⢻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣏⣾⣿⣿⣿ ", - " ⣿⣦⠹⣿⣿⣿⣿⣿⠄⢀⣴⢾⣼⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣾⣿⣿⣿⣿ ", - " ⣿⣿⣇⢽⣿⣿⣿⡏⣿⣿⣿⣿⣿⡇⣿⣿⣿⣿⡿⣿⣛⣻⠿⣟⣼⣿⣿⣿⣿⢃ ", - " ⣿⣿⣿⡎⣷⣽⠻⣇⣿⣿⣿⡿⣟⣵⣿⣟⣽⣾⣿⣿⣿⣿⢯⣾⣿⣿⣿⠟⠱⡟ ", - " ⣿⣿⣿⣿⢹⣿⣿⢮⣚⡛⠒⠛⢛⣋⣶⣿⣿⣿⣿⣿⣟⣱⠿⣿⣿⠟⣡⣺⢿ ", - "", -} - -M[21] = { - "", - " ⣇⣿⠘⣿⣿⣿⡿⡿⣟⣟⢟⢟⢝⠵⡝⣿⡿⢂⣼⣿⣷⣌⠩⡫⡻⣝⠹⢿⣿⣷ ", - " ⡆⣿⣆⠱⣝⡵⣝⢅⠙⣿⢕⢕⢕⢕⢝⣥⢒⠅⣿⣿⣿⡿⣳⣌⠪⡪⣡⢑⢝⣇ ", - " ⡆⣿⣿⣦⠹⣳⣳⣕⢅⠈⢗⢕⢕⢕⢕⢕⢈⢆⠟⠋⠉⠁⠉⠉⠁⠈⠼⢐⢕⢽ ", - " ⡗⢰⣶⣶⣦⣝⢝⢕⢕⠅⡆⢕⢕⢕⢕⢕⣴⠏⣠⡶⠛⡉⡉⡛⢶⣦⡀⠐⣕⢕ ", - " ⡝⡄⢻⢟⣿⣿⣷⣕⣕⣅⣿⣔⣕⣵⣵⣿⣿⢠⣿⢠⣮⡈⣌⠨⠅⠹⣷⡀⢱⢕ ", - " ⡝⡵⠟⠈⢀⣀⣀⡀⠉⢿⣿⣿⣿⣿⣿⣿⣿⣼⣿⢈⡋⠴⢿⡟⣡⡇⣿⡇⡀⢕ ", - " ⡝⠁⣠⣾⠟⡉⡉⡉⠻⣦⣻⣿⣿⣿⣿⣿⣿⣿⣿⣧⠸⣿⣦⣥⣿⡇⡿⣰⢗⢄ ", - " ⠁⢰⣿⡏⣴⣌⠈⣌⠡⠈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣬⣉⣉⣁⣄⢖⢕⢕⢕ ", - " ⡀⢻⣿⡇⢙⠁⠴⢿⡟⣡⡆⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣵⣵⣿ ", - " ⡻⣄⣻⣿⣌⠘⢿⣷⣥⣿⠇⣿⣿⣿⣿⣿⣿⠛⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ ", - " ⣷⢄⠻⣿⣟⠿⠦⠍⠉⣡⣾⣿⣿⣿⣿⣿⣿⢸⣿⣦⠙⣿⣿⣿⣿⣿⣿⣿⣿⠟ ", - " ⡕⡑⣑⣈⣻⢗⢟⢞⢝⣻⣿⣿⣿⣿⣿⣿⣿⠸⣿⠿⠃⣿⣿⣿⣿⣿⣿⡿⠁⣠ ", - " ⡝⡵⡈⢟⢕⢕⢕⢕⣵⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣿⣿⣿⣿⣿⠿⠋⣀⣈⠙ ", - " ⡝⡵⡕⡀⠑⠳⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⡠⡲⡫⡪⡪⡣ ", - "", -} - -M[22] = { - "", - " ⣿⣿⣷⡁⢆⠈⠕⢕⢂⢕⢂⢕⢂⢔⢂⢕⢄⠂⣂⠂⠆⢂⢕⢂⢕⢂⢕⢂⢕⢂ ", - " ⣿⣿⣿⡷⠊⡢⡹⣦⡑⢂⢕⢂⢕⢂⢕⢂⠕⠔⠌⠝⠛⠶⠶⢶⣦⣄⢂⢕⢂⢕ ", - " ⣿⣿⠏⣠⣾⣦⡐⢌⢿⣷⣦⣅⡑⠕⠡⠐⢿⠿⣛⠟⠛⠛⠛⠛⠡⢷⡈⢂⢕⢂ ", - " ⠟⣡⣾⣿⣿⣿⣿⣦⣑⠝⢿⣿⣿⣿⣿⣿⡵⢁⣤⣶⣶⣿⢿⢿⢿⡟⢻⣤⢑⢂ ", - " ⣾⣿⣿⡿⢟⣛⣻⣿⣿⣿⣦⣬⣙⣻⣿⣿⣷⣿⣿⢟⢝⢕⢕⢕⢕⢽⣿⣿⣷⣔ ", - " ⣿⣿⠵⠚⠉⢀⣀⣀⣈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣗⢕⢕⢕⢕⢕⢕⣽⣿⣿⣿⣿ ", - " ⢷⣂⣠⣴⣾⡿⡿⡻⡻⣿⣿⣴⣿⣿⣿⣿⣿⣿⣷⣵⣵⣵⣷⣿⣿⣿⣿⣿⣿⡿ ", - " ⢌⠻⣿⡿⡫⡪⡪⡪⡪⣺⣿⣿⣿⣿⣿⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃ ", - " ⠣⡁⠹⡪⡪⡪⡪⣪⣾⣿⣿⣿⣿⠋⠐⢉⢍⢄⢌⠻⣿⣿⣿⣿⣿⣿⣿⣿⠏⠈ ", - " ⡣⡘⢄⠙⣾⣾⣾⣿⣿⣿⣿⣿⣿⡀⢐⢕⢕⢕⢕⢕⡘⣿⣿⣿⣿⣿⣿⠏⠠⠈ ", - " ⠌⢊⢂⢣⠹⣿⣿⣿⣿⣿⣿⣿⣿⣧⢐⢕⢕⢕⢕⢕⢅⣿⣿⣿⣿⡿⢋⢜⠠⠈ ", - " ⠄⠁⠕⢝⡢⠈⠻⣿⣿⣿⣿⣿⣿⣿⣷⣕⣑⣑⣑⣵⣿⣿⣿⡿⢋⢔⢕⣿⠠⠈ ", - " ⠨⡂⡀⢑⢕⡅⠂⠄⠉⠛⠻⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢋⢔⢕⢕⣿⣿⠠⠈ ", - " ⠄⠪⣂⠁⢕⠆⠄⠂⠄⠁⡀⠂⡀⠄⢈⠉⢍⢛⢛⢛⢋⢔⢕⢕⢕⣽⣿⣿⠠⠈ ", - "", -} - -M[23] = { - "", - "⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⣀⣀⣀⡀⠀⢀⡀⠀⢀⣀⣀⣀⠀⡀⠀⠀⠀⠀⠀⠀", - "⠀⠀⠀⠀⠀⣠⣎⣀⣀⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⡄⠀⠀⠀⠀", - "⠀⠀⠀⠀⣰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀", - "⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⡿⠏⠿⠿⠿⠿⠿⣿⣿⣿⣿⣿⣿⡆⠀⠀", - "⠀⠀⠀⣿⣿⣿⣿⣿⣿⡿⢿⠋⠉⠀⠀⠀⠀⠀⡀⠀⠀⠘⢿⣿⣿⣿⣿⣧⠀⠀", - "⠀⠀⢰⣿⣿⣿⣿⠟⢁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠇⠀⠀⡈⠀⠻⣿⣿⣿⣿⠀⠀", - "⠀⠀⣼⣿⣿⡿⠁⠀⢸⠀⠈⢳⣶⣤⣄⠀⠈⠀⠁⠀⠀⠀⢀⠀⠹⣿⣿⡟⠀⠀", - "⠀⠀⣿⣿⣿⠀⠀⠈⣼⡇⠀⠘⠻⠟⠁⠀⠀⠀⠀⢤⣀⡀⠌⠀⠀⣿⣿⠃⠀⠀", - "⠀⠀⣿⣿⣿⡀⠀⠀⡏⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣿⡿⠋⢰⢠⣿⡏⠀⠀⠀", - "⠀⠀⣿⣿⣿⡇⠀⠀⢷⡃⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣯⣾⡟⠀⠀⠀⠀", - "⠀⠀⣿⣿⣿⡿⠀⠀⣼⣿⡄⠀⠈⠀⢑⠶⠀⠀⠀⠀⢀⣾⣿⣿⣿⡇⠀⠀⠀⠀", - "⠀⠀⣿⣿⣿⠁⠀⠀⣿⣿⠁⠀⠀⠀⢀⣀⣠⣤⣤⣴⠟⣿⣿⣿⣿⡇⠀⠀⠀⠀", - "⠀⠀⠙⢿⠃⠀⠀⢸⣿⣟⠀⠀⢀⣤⣾⣿⣿⣿⠟⠁⢰⣿⣿⣿⣿⠃⠀⠀⠀⠀", - "⠀⠀⠠⠴⠀⠀⠀⠿⠿⠿⠧⠾⠿⠿⠿⠿⠿⠃⠀⠀⠾⠿⠿⠟⠁⠀ ", - "", -} - -M[24] = { - "", - "⣿⣯⣿⣟⣟⡼⣿⡼⡿⣷⣿⣿⣿⠽⡟⢋⣿⣿⠘⣼⣷⡟⠻⡿⣷⡼⣝⡿⡾⣿", - "⣿⣿⣿⣿⢁⣵⡇⡟⠀⣿⣿⣿⠇⠀⡇⣴⣿⣿⣧⣿⣿⡇⠀⢣⣿⣷⣀⡏⢻⣿", - "⣿⣿⠿⣿⣿⣿⠷⠁⠀⠛⠛⠋⠀⠂⠹⠿⠿⠿⠿⠿⠉⠁⠀⠘⠛⠛⠛⠃⢸⣯", - "⣿⡇⠀⣄⣀⣀⣈⣁⠈⠉⠃⠀⠀⠀⠀⠀⠀⠀⠀⠠⠎⠈⠀⣀⣁⣀⣀⡠⠈⠉", - "⣿⣯⣽⡿⢟⡿⠿⠛⠛⠿⣶⣄⠀⠀⠀⠀⠀⠀⠈⢠⣴⣾⠛⠛⠿⠻⠛⠿⣷⣶", - "⣿⣿⣿⠀⠀⠀⣿⡿⣶⣿⣫⠉⠀⠀⠀⠀⠀⠀⠀⠈⠰⣿⠿⠾⣿⡇⠀⠀⢺⣿", - "⣿⣿⠻⡀⠀⠀⠙⠏⠒⡻⠃⠀⠀⠀⠀⣀⠀⠀⠀⠀⠀⠐⡓⢚⠟⠁⠀⠀⡾⢫", - "⣿⣿⠀⠀⡀⠀⠀⡈⣉⡀⡠⣐⣅⣽⣺⣿⣯⡡⣴⣴⣔⣠⣀⣀⡀⢀⡀⡀⠀⣸", - "⣿⣿⣷⣿⣟⣿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢻⢾⣷⣿", - "⣿⣿⣟⠫⡾⠟⠫⢾⠯⡻⢟⡽⢶⢿⣿⣿⡛⠕⠎⠻⠝⠪⢖⠝⠟⢫⠾⠜⢿⣿", - "⣿⣿⣿⠉⠀⠀⠀⠀⠈⠀⠀⠀⠀⣰⣋⣀⣈⣢⠀⠀⠀⠀⠀⠀⠀⠀⠀⣐⢸⣿", - "⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⢀⣾⣿", - "⣿⣿⣿⣿⣦⡔⠀⠀⠀⠀⠀⠀⢻⣿⡿⣿⣿⢽⣿⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿", - "⣿⣿⣿⣿⣿⣿⣶⣤⣀⠀⠀⠀⠘⠛⢅⣙⣙⠿⠉⠀⠀⠀⢀⣠⣴⣿⣿⣿⣿⣿", - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣤⣄⣅⠀⠓⠀⠀⣀⣠⣴⣺⣿⣿⣿⣿⣿⣿⣿⣿", - "", -} - -M[25] = { - "", - " ⡿⠉⠄⠄⠄⠄⠈⠙⠿⠟⠛⠉⠉⠉⠄⠄⠄⠈⠉⠉⠉⠛⠛⠻⢿⣿⣿⣿⣿⣿ ", - " ⠁⠄⠄⠄⢀⡴⣋⣵⣮⠇⡀⠄⠄⠄⠄⠄⠄⢀⠄⠄⠄⡀⠄⠄⠄⠈⠛⠿⠋⠉ ", - " ⠄⠄⠄⢠⣯⣾⣿⡿⣳⡟⣰⣿⣠⣂⡀⢀⠄⢸⡄⠄⢀⣈⢆⣱⣤⡀⢄⠄⠄⠄ ", - " ⠄⠄⠄⣼⣿⣿⡟⣹⡿⣸⣿⢳⣿⣿⣿⣿⣴⣾⢻⣆⣿⣿⣯⢿⣿⣿⣷⣧⣀⣤ ", - " ⠄⠄⣼⡟⣿⠏⢀⣿⣇⣿⣏⣿⣿⣿⣿⣿⣿⣿⢸⡇⣿⣿⣿⣟⣿⣿⣿⣿⣏⠋ ", - " ⡆⣸⡟⣼⣯⠏⣾⣿⢸⣿⢸⣿⣿⣿⣿⣿⣿⡟⠸⠁⢹⡿⣿⣿⢻⣿⣿⣿⣿⠄ ", - " ⡇⡟⣸⢟⣫⡅⣶⢆⡶⡆⣿⣿⣿⣿⣿⢿⣛⠃⠰⠆⠈⠁⠈⠙⠈⠻⣿⢹⡏⠄ ", - " ⣧⣱⡷⣱⠿⠟⠛⠼⣇⠇⣿⣿⣿⣿⣿⣿⠃⣰⣿⣿⡆⠄⠄⠄⠄⠄⠉⠈⠄⠄ ", - " ⡏⡟⢑⠃⡠⠂⠄⠄⠈⣾⢻⣿⣿⡿⡹⡳⠋⠉⠁⠉⠙⠄⢀⠄⠄⠄⠄⠄⠂⠄ ", - " ⡇⠁⢈⢰⡇⠄⠄⡙⠂⣿⣿⣿⣿⣱⣿⡗⠄⠄⠄⢀⡀⠄⠈⢰⠄⠄⠄⠐⠄⠄ ", - " ⠄⠄⠘⣿⣧⠴⣄⣡⢄⣿⣿⣿⣷⣿⣿⡇⢀⠄⠤⠈⠁⣠⣠⣸⢠⠄⠄⠄⠄⠄ ", - " ⢀⠄⠄⣿⣿⣷⣬⣵⣿⣿⣿⣿⣿⣿⣿⣷⣟⢷⡶⢗⡰⣿⣿⠇⠘⠄⠄⠄⠄⠄ ", - " ⣿⠄⠄⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣶⣾⣿⣿⡟⢀⠃⠄⢸⡄⠁⣸ ", - " ⣿⠄⠄⠘⢿⣿⣿⣿⣿⣿⣿⢛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣟⢄⡆⠄⢀⣪⡆⠄⣿ ", - " ⡟⠄⠄⠄⠄⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢿⣟⣻⣩⣾⣃⣴⣿⣿⡇⠸⢾ ", - "", -} - -M[26] = { - "", - "⡆⣐⢕⢕⢕⢕⢕⢕⢕⢕⠅⢗⢕⢕⢕⢕⢕⢕⢕⠕⠕⢕⢕⢕⢕⢕⢕⢕⢕⢕", - "⢐⢕⢕⢕⢕⢕⣕⢕⢕⠕⠁⢕⢕⢕⢕⢕⢕⢕⢕⠅⡄⢕⢕⢕⢕⢕⢕⢕⢕⢕", - "⢕⢕⢕⢕⢕⠅⢗⢕⠕⣠⠄⣗⢕⢕⠕⢕⢕⢕⠕⢠⣿⠐⢕⢕⢕⠑⢕⢕⠵⢕", - "⢕⢕⢕⢕⠁⢜⠕⢁⣴⣿⡇⢓⢕⢵⢐⢕⢕⠕⢁⣾⢿⣧⠑⢕⢕⠄⢑⢕⠅⢕", - "⢕⢕⠵⢁⠔⢁⣤⣤⣶⣶⣶⡐⣕⢽⠐⢕⠕⣡⣾⣶⣶⣶⣤⡁⢓⢕⠄⢑⢅⢑", - "⠍⣧⠄⣶⣾⣿⣿⣿⣿⣿⣿⣷⣔⢕⢄⢡⣾⣿⣿⣿⣿⣿⣿⣿⣦⡑⢕⢤⠱⢐", - "⢠⢕⠅⣾⣿⠋⢿⣿⣿⣿⠉⣿⣿⣷⣦⣶⣽⣿⣿⠈⣿⣿⣿⣿⠏⢹⣷⣷⡅⢐", - "⣔⢕⢥⢻⣿⡀⠈⠛⠛⠁⢠⣿⣿⣿⣿⣿⣿⣿⣿⡀⠈⠛⠛⠁⠄⣼⣿⣿⡇⢔", - "⢕⢕⢽⢸⢟⢟⢖⢖⢤⣶⡟⢻⣿⡿⠻⣿⣿⡟⢀⣿⣦⢤⢤⢔⢞⢿⢿⣿⠁⢕", - "⢕⢕⠅⣐⢕⢕⢕⢕⢕⣿⣿⡄⠛⢀⣦⠈⠛⢁⣼⣿⢗⢕⢕⢕⢕⢕⢕⡏⣘⢕", - "⢕⢕⠅⢓⣕⣕⣕⣕⣵⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣷⣕⢕⢕⢕⢕⡵⢀⢕⢕", - "⢑⢕⠃⡈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢃⢕⢕⢕", - "⣆⢕⠄⢱⣄⠛⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⢁⢕⢕⠕⢁", - "⣿⣦⡀⣿⣿⣷⣶⣬⣍⣛⣛⣛⡛⠿⠿⠿⠛⠛⢛⣛⣉⣭⣤⣂⢜⠕⢑⣡⣴⣿", - "", -} - -M[27] = { - "", - "⡿⠋⠄⣀⣀⣤⣴⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣌⠻⣿⣿", - "⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⠹⣿", - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠹", - "⣿⣿⡟⢹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡛⢿⣿⣿⣿⣮⠛⣿⣿⣿⣿⣿⣿⡆", - "⡟⢻⡇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣣⠄⡀⢬⣭⣻⣷⡌⢿⣿⣿⣿⣿⣿", - "⠃⣸⡀⠈⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠈⣆⢹⣿⣿⣿⡈⢿⣿⣿⣿⣿", - "⠄⢻⡇⠄⢛⣛⣻⣿⣿⣿⣿⣿⣿⣿⣿⡆⠹⣿⣆⠸⣆⠙⠛⠛⠃⠘⣿⣿⣿⣿", - "⠄⠸⣡⠄⡈⣿⣿⣿⣿⣿⣿⣿⣿⠿⠟⠁⣠⣉⣤⣴⣿⣿⠿⠿⠿⡇⢸⣿⣿⣿", - "⠄⡄⢿⣆⠰⡘⢿⣿⠿⢛⣉⣥⣴⣶⣿⣿⣿⣿⣻⠟⣉⣤⣶⣶⣾⣿⡄⣿⡿⢸", - "⠄⢰⠸⣿⠄⢳⣠⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⣼⣿⣿⣿⣿⣿⣿⡇⢻⡇⢸", - "⢷⡈⢣⣡⣶⠿⠟⠛⠓⣚⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⢸⠇⠘", - "⡀⣌⠄⠻⣧⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠛⠛⠛⢿⣿⣿⣿⣿⣿⡟⠘⠄⠄", - "⣷⡘⣷⡀⠘⣿⣿⣿⣿⣿⣿⣿⣿⡋⢀⣠⣤⣶⣶⣾⡆⣿⣿⣿⠟⠁⠄⠄⠄⠄", - "⣿⣷⡘⣿⡀⢻⣿⣿⣿⣿⣿⣿⣿⣧⠸⣿⣿⣿⣿⣿⣷⡿⠟⠉⠄⠄⠄⠄⡄⢀", - "⣿⣿⣷⡈⢷⡀⠙⠛⠻⠿⠿⠿⠿⠿⠷⠾⠿⠟⣛⣋⣥⣶⣄⠄⢀⣄⠹⣦⢹⣿", - "", -} - -M[28] = { - "", - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣿⡿⠿⢿⣿⣿⣿⣿⣿⣿", - "⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⠛⠉⠉⠉⠙⠻⣅⠀⠈⢧⠀⠈⠛⠉⠉⢻⣿⣿", - "⣿⣿⣿⣿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⣤⡶⠟⠀⠀⣈⠓⢤⣶⡶⠿⠛⠻⣿", - "⣿⣿⣿⣿⣿⢣⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣀⣴⠶⠿⠿⢷⡄⠀⠀⢀⣤⣾⣿", - "⣿⣿⣿⣿⣡⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⣦⣤⣤⡀⠀⢷⡀⠀⠀⣻⣿⣿", - "⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡈⠛⠶⠛⠃⠈⠈⢿⣿⣿", - "⣿⣿⠟⠘⠀⠀⠀⠀⠀⠀⠀⠀⢀⡆⠀⠀⠀⠀⠀⠀⣧⠀⠀⠀⠀⠀⠀⠈⣿⣿", - "⣿⠏⠀⠁⠀⠀⠀⠀⠀⠀⠀⢀⣶⡄⠀⠀⠀⠀⠀⠀⣡⣄⣿⡆⠀⠀⠀⠀⣿⣿", - "⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠚⠛⠛⢛⣲⣶⣿⣷⣉⠉⢉⣥⡄⠀⠀⠀⠨⣿⣿", - "⡇⢠⡆⠀⠀⢰⠀⠀⠀⠀⢸⣿⣧⣠⣿⣿⣿⣿⣿⣿⣷⣾⣿⡅⠀⠀⡄⠠⢸⣿", - "⣧⠸⣇⠀⠀⠘⣤⡀⠀⠀⠘⣿⣿⣿⣿⣿⠟⠛⠻⣿⣿⣿⡿⢁⠀⠀⢰⠀⢸⣿", - "⣿⣷⣽⣦⠀⠀⠙⢷⡀⠀⠀⠙⠻⠿⢿⣷⣾⣿⣶⠾⢟⣥⣾⣿⣧⠀⠂⢀⣿⣿", - "⣿⣿⣿⣿⣷⣆⣠⣤⣤⣤⣀⣀⡀⠀⠒⢻⣶⣾⣿⣿⣿⣿⣿⣿⣿⢀⣀⣾⣿⣿", - "", -} - -M[29] = { - "", - "⣿⣿⣿⣿⣯⣿⣿⠄⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠈⣿⣿⣿⣿⣿⣿⣆⠄", - "⢻⣿⣿⣿⣾⣿⢿⣢⣞⣿⣿⣿⣿⣷⣶⣿⣯⣟⣿⢿⡇⢃⢻⣿⣿⣿⣿⣿⢿⡄", - "⠄⢿⣿⣯⣏⣿⣿⣿⡟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣧⣾⢿⣮⣿⣿⣿⣿⣾⣷", - "⠄⣈⣽⢾⣿⣿⣿⣟⣄⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣝⣯⢿⣿⣿⣿⣿", - "⣿⠟⣫⢸⣿⢿⣿⣾⣿⢿⣿⣿⢻⣿⣿⣿⢿⣿⣿⣿⢸⣿⣼⣿⣿⣿⣿⣿⣿⣿", - "⡟⢸⣟⢸⣿⠸⣷⣝⢻⠘⣿⣿⢸⢿⣿⣿⠄⣿⣿⣿⡆⢿⣿⣼⣿⣿⣿⣿⢹⣿", - "⡇⣿⡿⣿⣿⢟⠛⠛⠿⡢⢻⣿⣾⣞⣿⡏⠖⢸⣿⢣⣷⡸⣇⣿⣿⣿⢼⡿⣿⣿", - "⣡⢿⡷⣿⣿⣾⣿⣷⣶⣮⣄⣿⣏⣸⣻⣃⠭⠄⠛⠙⠛⠳⠋⣿⣿⣇⠙⣿⢸⣿", - "⠫⣿⣧⣿⣿⣿⣿⣿⣿⣿⣿⣿⠻⣿⣾⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣹⢷⣿⡼⠋", - " ⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⣿⣿⣿ ", - " ⢻⢹⣿⠸⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⣼⣿⣿⣿⣿⡟ ", - " ⠈⢸⣿ ⠙⢿⣿⣿⣹⣿⣿⣿⣿⣟⡃⣽⣿⣿⡟⠁⣿⣿⢻⣿⣿⢿ ", - " ⠘⣿⡄ ⠙⢿⣿⣿⣾⣿⣷⣿⣿⣿⠟⠁ ⣿⣿⣾⣿⡟⣿ ", - " ⢻⡇⠸⣆ ⠈⠻⣿⡿⠿⠛⠉ ⢸⣿⣇⣿⣿⢿⣿ ", - "", -} - -M[30] = { - "", - "⣿⠟⣽⣿⣿⣿⣿⣿⢣⠟⠋⡜⠄⢸⣿⣿⡟⣬⢁⠠⠁⣤⠄⢰⠄⠇⢻⢸", - "⢏⣾⣿⣿⣿⠿⣟⢁⡴⡀⡜⣠⣶⢸⣿⣿⢃⡇⠂⢁⣶⣦⣅⠈⠇⠄⢸⢸", - "⣹⣿⣿⣿⡗⣾⡟⡜⣵⠃⣴⣿⣿⢸⣿⣿⢸⠘⢰⣿⣿⣿⣿⡀⢱⠄⠨⢸", - "⣿⣿⣿⣿⡇⣿⢁⣾⣿⣾⣿⣿⣿⣿⣸⣿⡎⠐⠒⠚⠛⠛⠿⢧⠄⠄⢠⣼", - "⣿⣿⣿⣿⠃⠿⢸⡿⠭⠭⢽⣿⣿⣿⢂⣿⠃⣤⠄⠄⠄⠄⠄⠄⠄⠄⣿⡾", - "⣼⠏⣿⡏⠄⠄⢠⣤⣶⣶⣾⣿⣿⣟⣾⣾⣼⣿⠒⠄⠄⠄⡠⣴⡄⢠⣿⣵", - "⣳⠄⣿⠄⠄⢣⠸⣹⣿⡟⣻⣿⣿⣿⣿⣿⣿⡿⡻⡖⠦⢤⣔⣯⡅⣼⡿⣹", - "⡿⣼⢸⠄⠄⣷⣷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣕⡜⡌⡝⡸⠙⣼⠟⢱⠏", - "⡇⣿⣧⡰⡄⣿⣿⣿⣿⡿⠿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣋⣪⣥⢠⠏⠄", - "⣧⢻⣿⣷⣧⢻⣿⣿⣿⡇⠄⢀⣀⣀⡙⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠂⠄⠄", - "⢹⣼⣿⣿⣿⣧⡻⣿⣿⣇⣴⣿⣿⣿⣷⢸⣿⣿⣿⣿⣿⣿⣿⣿⣰⠄⠄⠄", - "⣼⡟⡟⣿⢸⣿⣿⣝⢿⣿⣾⣿⣿⣿⢟⣾⣿⣿⣿⣿⣿⣿⣿⣿⠟⠄⡀⡀", - "⣿⢰⣿⢹⢸⣿⣿⣿⣷⣝⢿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⠉⠄⠄⣸⢰⡇", - "⣿⣾⣹⣏⢸⣿⣿⣿⣿⣿⣷⣍⡻⣛⣛⣛⡉⠁⠄⠄⠄⠄⠄⠄⢀⢇⡏⠄", - "", -} - -M[31] = { - "", - "⢰⡟⣡⡟⣱⣿⡿⠡⢛⣋⣥⣴⣌⢿⣿⣿⣿⣿⣷⣌⠻⢿⣿⣿⣿⣿⣿⣿", - "⠏⢼⡿⣰⡿⠿⠡⠿⠿⢯⣉⠿⣿⣿⣿⣿⣿⣿⣷⣶⣿⣦⣍⠻⢿⣿⣿⣿", - "⣼⣷⢠⠀⠀⢠⣴⡖⠀⠀⠈⠻⣿⡿⣿⣿⣿⣿⣿⣛⣯⣝⣻⣿⣶⣿⣿⣿", - "⣿⡇⣿⡷⠂⠈⡉⠀⠀⠀⣠⣴⣾⣿⣿⣿⣿⣿⣍⡤⣤⣤⣤⡀⠀⠉⠛⠿", - "⣿⢸⣿⡅⣠⣬⣥⣤⣴⣴⣿⣿⢿⣿⣿⣿⣿⣿⣟⡭⡄⣀⣉⡀⠀⠀⠀⠀", - "⡟⣿⣿⢰⣿⣿⣿⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣿⣿⣶⣦⣈⠀⠀⠀⢀⣶", - "⡧⣿⡇⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣾⣿", - "⡇⣿⠃⣿⣿⣿⣿⣿⠛⠛⢫⣿⣿⣻⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿", - "⡇⣿⠘⡇⢻⣿⣿⣿⡆⠀⠀⠀⠀⠈⠉⠙⠻⠏⠛⠻⣿⣿⣿⣿⣿⣭⡾⢁", - "⡇⣿⠀⠘⢿⣿⣿⣿⣧⢠⣤⠀⡤⢀⣠⣀⣀⠀⠀⣼⣿⣿⣿⣿⣿⠟⣁⠉", - "⣧⢻⠀⡄⠀⠹⣿⣿⣿⡸⣿⣾⡆⣿⣿⣿⠿⣡⣾⣿⣿⣿⣿⡿⠋⠐⢡⣶", - "⣿⡘⠈⣷⠀⠀⠈⠻⣿⣷⣎⠐⠿⢟⣋⣤⣾⣿⣿⣿⡿⠟⣩⠖⢠⡬⠈⠀", - "⣿⣧⠁⢻⡇⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⠿⠟⠋⠁⢀⠈⢀⡴⠈⠁⠀⠀", - "⠻⣿⣆⠘⣿⠀⠀ ⠀⠈⠙⠛⠋⠉⠀⠀⠀⠀⡀⠤⠚⠁ ", - "", -} - -M[32] = { - "", - " ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣭⣿⣶⣿⣦⣼⣆ ", - " ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ", - " ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷⠄⠄⠄⠄⠻⠿⢿⣿⣧⣄ ", - " ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ", - " ⢠⣿⣿⣿⠈ ⠡⠌⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ", - " ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘⠄ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ", - " ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ", - " ⣠⣿⠿⠛⠄⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ", - " ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇⠄⠛⠻⢷⣄ ", - " ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ", - " ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ", - " ⢰⣶ ⣶ ⢶⣆⢀⣶⠂⣶⡶⠶⣦⡄⢰⣶⠶⢶⣦ ⣴⣶ ", - " ⢸⣿⠶⠶⣿ ⠈⢻⣿⠁ ⣿⡇ ⢸⣿⢸⣿⢶⣾⠏ ⣸⣟⣹⣧ ", - " ⠸⠿ ⠿ ⠸⠿ ⠿⠷⠶⠿⠃⠸⠿⠄⠙⠷⠤⠿⠉⠉⠿⠆ ", - "", -} - -M[33] = { - " ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗", - " ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║", - " ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║", - " ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║", - " ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║", - " ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝", -} - -M[34] = { - "", - "███╗ ██╗██╗ ██╗██╗███╗ ███╗ ██╗██████╗ ███████╗", - "████╗ ██║██║ ██║██║████╗ ████║ ██║██╔══██╗██╔════╝", - "██╔██╗ ██║██║ ██║██║██╔████╔██║ ██║██║ ██║█████╗ ", - "██║╚██╗██║╚██╗ ██╔╝██║██║╚██╔╝██║ ██║██║ ██║██╔══╝ ", - "██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║ ██║██████╔╝███████╗", - "╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚═════╝ ╚══════╝", -} -return M diff --git a/lua/kide/plugins/config/comment.lua b/lua/kide/plugins/config/comment.lua deleted file mode 100644 index bd47faf7..00000000 --- a/lua/kide/plugins/config/comment.lua +++ /dev/null @@ -1 +0,0 @@ -require("Comment").setup() diff --git a/lua/kide/plugins/config/diffview-nvim.lua b/lua/kide/plugins/config/diffview-nvim.lua deleted file mode 100644 index 23f0d163..00000000 --- a/lua/kide/plugins/config/diffview-nvim.lua +++ /dev/null @@ -1 +0,0 @@ -require("diffview").setup({}) diff --git a/lua/kide/plugins/config/markdown-preview.lua b/lua/kide/plugins/config/markdown-preview.lua deleted file mode 100644 index 3c8ce8bf..00000000 --- a/lua/kide/plugins/config/markdown-preview.lua +++ /dev/null @@ -1 +0,0 @@ -vim.g.mkdp_page_title = "${name}" diff --git a/lua/kide/plugins/config/mason-nvim.lua b/lua/kide/plugins/config/mason-nvim.lua deleted file mode 100644 index ac266614..00000000 --- a/lua/kide/plugins/config/mason-nvim.lua +++ /dev/null @@ -1 +0,0 @@ -require("mason").setup() diff --git a/lua/kide/plugins/config/neogen.lua b/lua/kide/plugins/config/neogen.lua deleted file mode 100644 index 9a41f6c6..00000000 --- a/lua/kide/plugins/config/neogen.lua +++ /dev/null @@ -1,6 +0,0 @@ -require("neogen").setup({ - snippet_engine = "luasnip", - enabled = true, --if you want to disable Neogen - input_after_comment = true, -- (default: true) automatic jump (with insert mode) on inserted annotation - -- jump_map = "" -- (DROPPED SUPPORT, see [here](#cycle-between-annotations) !) The keymap in order to jump in the annotation fields (in insert mode) -}) diff --git a/lua/kide/plugins/config/nvim-autopairs.lua b/lua/kide/plugins/config/nvim-autopairs.lua deleted file mode 100644 index bdc3eaf3..00000000 --- a/lua/kide/plugins/config/nvim-autopairs.lua +++ /dev/null @@ -1,5 +0,0 @@ -local autopairs = require("nvim-autopairs") -local cmp_autopairs = require("nvim-autopairs.completion.cmp") -autopairs.setup({}) -local cmp = require("cmp") -cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) diff --git a/lua/kide/plugins/config/nvim-colorizer.lua b/lua/kide/plugins/config/nvim-colorizer.lua deleted file mode 100644 index 577b1cdf..00000000 --- a/lua/kide/plugins/config/nvim-colorizer.lua +++ /dev/null @@ -1,27 +0,0 @@ -require("colorizer").setup({ - filetypes = { "*" }, - user_default_options = { - RGB = true, -- #RGB hex codes - RRGGBB = true, -- #RRGGBB hex codes - names = false, -- "Name" codes like Blue or blue - RRGGBBAA = false, -- #RRGGBBAA hex codes - AARRGGBB = false, -- 0xAARRGGBB hex codes - rgb_fn = false, -- CSS rgb() and rgba() functions - hsl_fn = false, -- CSS hsl() and hsla() functions - css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB - css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn - -- Available modes for `mode`: foreground, background, virtualtext - mode = "background", -- Set the display mode. - -- Available methods are false / true / "normal" / "lsp" / "both" - -- True is same as normal - tailwind = false, -- Enable tailwind colors - -- parsers can contain values used in |user_default_options| - sass = { enable = false, parsers = { "css" } }, -- Enable sass colors - virtualtext = "■", - -- update color values even if buffer is not focused - -- example use: cmp_menu, cmp_docs - always_update = false, - }, - -- all the sub-options of filetypes apply to buftypes - buftypes = {}, -}) diff --git a/lua/kide/plugins/config/nvim-notify.lua b/lua/kide/plugins/config/nvim-notify.lua deleted file mode 100644 index c99cfd56..00000000 --- a/lua/kide/plugins/config/nvim-notify.lua +++ /dev/null @@ -1,35 +0,0 @@ -local notify = require("notify") -notify.setup({ - -- Animation style (see below for details) - stages = "fade_in_slide_out", - - -- Function called when a new window is opened, use for changing win settings/config - on_open = nil, - - -- Function called when a window is closed - on_close = nil, - - -- Render function for notifications. See notify-render() - render = "default", - - -- Default timeout for notifications - timeout = 3000, - - -- For stages that change opacity this is treated as the highlight behind the window - -- Set this to either a highlight group, an RGB hex value e.g. "#000000" or a function returning an RGB code for dynamic values - background_colour = "#000000", - - -- Minimum width for notification windows - minimum_width = 50, - - -- Icons for the different levels - icons = { - ERROR = "", - WARN = "", - INFO = "", - DEBUG = "", - TRACE = "✎", - }, -}) - -vim.notify = notify diff --git a/lua/kide/plugins/config/rest-nvim.lua b/lua/kide/plugins/config/rest-nvim.lua deleted file mode 100644 index 8efe3902..00000000 --- a/lua/kide/plugins/config/rest-nvim.lua +++ /dev/null @@ -1,22 +0,0 @@ -require("rest-nvim").setup({ - -- Open request results in a horizontal split - result_split_horizontal = false, - -- Skip SSL verification, useful for unknown certificates - skip_ssl_verification = false, - -- Highlight request on run - highlight = { - enabled = true, - timeout = 150, - }, - result = { - -- toggle showing URL, HTTP info, headers at top the of result window - show_url = true, - show_http_info = true, - show_headers = true, - }, - -- Jump to request line on run - jump_to_request = false, - env_file = ".env", - custom_dynamic_variables = {}, - yank_dry_run = true, -}) diff --git a/lua/kide/plugins/config/toggletasks.lua b/lua/kide/plugins/config/toggletasks.lua deleted file mode 100644 index edfeaa8a..00000000 --- a/lua/kide/plugins/config/toggletasks.lua +++ /dev/null @@ -1,13 +0,0 @@ -require("toggletasks").setup({ - search_paths = { - ".tasks", - ".toggletasks", - ".nvim/toggletasks", - ".nvim/tasks", - }, - toggleterm = { - close_on_exit = true, - }, -}) - -require("telescope").load_extension("toggletasks") diff --git a/lua/kide/plugins/config/translate.lua b/lua/kide/plugins/config/translate.lua deleted file mode 100644 index 45445f61..00000000 --- a/lua/kide/plugins/config/translate.lua +++ /dev/null @@ -1,12 +0,0 @@ -require("translate").setup({ - default = { - command = "translate_shell", - }, - preset = { - output = { - split = { - append = true, - }, - }, - }, -}) diff --git a/lua/kide/plugins/config/wilder.lua b/lua/kide/plugins/config/wilder.lua deleted file mode 100644 index fecc8475..00000000 --- a/lua/kide/plugins/config/wilder.lua +++ /dev/null @@ -1,39 +0,0 @@ -local wilder = require("wilder") -wilder.setup({ - modes = { ":", "/", "?" }, - next_key = "", - previous_key = "", - accept_key = "", - reject_key = "", -}) -local popupmenu_renderer = wilder.popupmenu_renderer(wilder.popupmenu_border_theme({ - highlighter = wilder.basic_highlighter(), - highlights = { - bg = "NormalFloat", - border = "NormalFloat", -- highlight to use for the border - }, - pumblend = 20, - -- 'single', 'double', 'rounded' or 'solid' - -- can also be a list of 8 characters, see :h wilder#popupmenu_border_theme() for more details - border = "rounded", - left = { " ", wilder.popupmenu_devicons() }, - right = { " ", wilder.popupmenu_scrollbar() }, -})) - -local wildmenu_renderer = wilder.wildmenu_renderer({ - highlighter = wilder.basic_highlighter(), - highlights = { - bg = "NormalFloat", - border = "NormalFloat", -- highlight to use for the border - }, - separator = " · ", - left = { " ", wilder.wildmenu_spinner(), " " }, - right = { " ", wilder.wildmenu_index() }, -}) -wilder.set_option( - "renderer", - wilder.renderer_mux({ - [":"] = popupmenu_renderer, - ["/"] = wildmenu_renderer, - }) -) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 45b3e7ca..399719c9 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -16,7 +16,7 @@ require("lazy").setup({ lazy = true, event = { "VeryLazy" }, config = function() - require("kide.plugins.config.mason-nvim") + require("mason").setup() end, }, { @@ -174,6 +174,7 @@ require("lazy").setup({ { "akinsho/bufferline.nvim", version = "*", + event = { "UIEnter" }, dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() require("kide.plugins.config.bufferline") @@ -414,7 +415,7 @@ require("lazy").setup({ "DiffviewToggleFiles", }, config = function() - require("kide.plugins.config.diffview-nvim") + require("diffview").setup({}) end, }, { @@ -461,7 +462,19 @@ require("lazy").setup({ lazy = true, dependencies = { "akinsho/toggleterm.nvim" }, config = function() - require("kide.plugins.config.toggletasks") + require("toggletasks").setup({ + search_paths = { + ".tasks", + ".toggletasks", + ".nvim/toggletasks", + ".nvim/tasks", + }, + toggleterm = { + close_on_exit = true, + }, + }) + + require("telescope").load_extension("toggletasks") end, }, @@ -477,6 +490,8 @@ require("lazy").setup({ -- 状态栏插件 { "nvim-lualine/lualine.nvim", + lazy = true, + event = { "UIEnter" }, config = function() require("kide.plugins.config.lualine") end, @@ -510,17 +525,24 @@ require("lazy").setup({ { "rcarriga/nvim-notify", config = function() - require("kide.plugins.config.nvim-notify") - end, - }, + local notify = require("notify") + notify.setup({ + stages = "fade_in_slide_out", + on_open = nil, + on_close = nil, + render = "default", + timeout = 3000, + minimum_width = 50, + icons = { + ERROR = "", + WARN = "", + INFO = "", + DEBUG = "", + TRACE = "✎", + }, + }) - -- wildmenu 补全美化 - { - "gelguy/wilder.nvim", - enabled = false, - keys = { ":", "/", "?" }, - config = function() - require("kide.plugins.config.wilder") + vim.notify = notify end, }, @@ -529,7 +551,33 @@ require("lazy").setup({ "NvChad/nvim-colorizer.lua", event = { "BufReadPost", "InsertEnter", "VeryLazy" }, config = function() - require("kide.plugins.config.nvim-colorizer") + require("colorizer").setup({ + filetypes = { "*" }, + user_default_options = { + RGB = true, -- #RGB hex codes + RRGGBB = true, -- #RRGGBB hex codes + names = false, -- "Name" codes like Blue or blue + RRGGBBAA = false, -- #RRGGBBAA hex codes + AARRGGBB = false, -- 0xAARRGGBB hex codes + rgb_fn = false, -- CSS rgb() and rgba() functions + hsl_fn = false, -- CSS hsl() and hsla() functions + css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB + css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Available modes for `mode`: foreground, background, virtualtext + mode = "background", -- Set the display mode. + -- Available methods are false / true / "normal" / "lsp" / "both" + -- True is same as normal + tailwind = false, -- Enable tailwind colors + -- parsers can contain values used in |user_default_options| + sass = { enable = false, parsers = { "css" } }, -- Enable sass colors + virtualtext = "■", + -- update color values even if buffer is not focused + -- example use: cmp_menu, cmp_docs + always_update = false, + }, + -- all the sub-options of filetypes apply to buftypes + buftypes = {}, + }) end, }, @@ -540,7 +588,7 @@ require("lazy").setup({ { "gc", mode = { "x" }, desc = "Comment" }, }, config = function() - require("kide.plugins.config.comment") + require("Comment").setup() end, }, { @@ -548,7 +596,11 @@ require("lazy").setup({ lazy = true, event = { "VeryLazy" }, config = function() - require("kide.plugins.config.neogen") + require("neogen").setup({ + snippet_engine = "luasnip", + enabled = true, + input_after_comment = true, + }) end, }, @@ -559,7 +611,7 @@ require("lazy").setup({ ft = "markdown", build = "cd app && yarn install", config = function() - require("kide.plugins.config.markdown-preview") + vim.g.mkdp_page_title = "${name}" end, }, -- mackdown cli 预览插件 @@ -598,7 +650,31 @@ require("lazy").setup({ { "goolord/alpha-nvim", config = function() - require("kide.plugins.config.alpha-nvim") + local alpha = require("alpha") + local dashboard = require("alpha.themes.dashboard") + dashboard.section.header.val = { + " ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗", + " ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║", + " ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║", + " ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║", + " ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║", + " ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝", + } + local opt = { noremap = true, silent = true } + dashboard.section.buttons.val = { + dashboard.button(" ff", "󰈞 Find File", ":Telescope find_files", opt), + dashboard.button(" fg", "󰈭 Find Word ", ":Telescope live_grep", opt), + dashboard.button( + " fp", + " Recent Projects", + ":lua require'telescope'.extensions.project.project{ display_type = 'full' }", + opt + ), + dashboard.button(" fo", " Recent File", ":Telescope oldfiles", opt), + dashboard.button(" ns", " Settings", ":e $MYVIMRC | :cd %:p:h ", opt), + dashboard.button(" q ", "󰅙 Quit NVIM", ":qa", opt), + } + alpha.setup(dashboard.opts) end, }, @@ -608,7 +684,18 @@ require("lazy").setup({ lazy = true, cmd = "Translate", config = function() - require("kide.plugins.config.translate") + require("translate").setup({ + default = { + command = "translate_shell", + }, + preset = { + output = { + split = { + append = true, + }, + }, + }, + }) end, }, -- StartupTime @@ -635,7 +722,11 @@ require("lazy").setup({ "windwp/nvim-autopairs", event = { "InsertEnter", "VeryLazy" }, config = function() - require("kide.plugins.config.nvim-autopairs") + local autopairs = require("nvim-autopairs") + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + autopairs.setup({}) + local cmp = require("cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) end, }, @@ -671,7 +762,28 @@ require("lazy").setup({ }) end, config = function() - require("kide.plugins.config.rest-nvim") + require("rest-nvim").setup({ + -- Open request results in a horizontal split + result_split_horizontal = false, + -- Skip SSL verification, useful for unknown certificates + skip_ssl_verification = false, + -- Highlight request on run + highlight = { + enabled = true, + timeout = 150, + }, + result = { + -- toggle showing URL, HTTP info, headers at top the of result window + show_url = true, + show_http_info = true, + show_headers = true, + }, + -- Jump to request line on run + jump_to_request = false, + env_file = ".env", + custom_dynamic_variables = {}, + yank_dry_run = true, + }) end, }, From 43320a6bcf2ec750c227a2c61d03f32b18b25b38 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 10:53:14 +0800 Subject: [PATCH 213/708] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/plugins/lazy-nvim.lua | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 399719c9..9f929aac 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -134,30 +134,6 @@ require("lazy").setup({ vim.cmd([[colorscheme gruvbox]]) end, }, - { - "sainnhe/gruvbox-material", - enabled = false, - lazy = false, - priority = 1000, - config = function() - vim.opt.background = "dark" - vim.g.gruvbox_material_background = "medium" - vim.g.gruvbox_material_better_performance = true - vim.g.gruvbox_material_diagnostic_virtual_text = "colored" - vim.g.gruvbox_material_current_word = "underline" - vim.cmd([[colorscheme gruvbox-material]]) - end, - }, - { - "morhetz/gruvbox", - enabled = false, - lazy = false, - priority = 1000, - config = function() - vim.opt.background = "dark" - vim.cmd([[colorscheme gruvbox]]) - end, - }, -- 文件管理 { @@ -1076,16 +1052,6 @@ require("lazy").setup({ require("copilot").setup({}) end, }, - { - "zbirenbaum/copilot-cmp", - enabled = false, - lazy = true, - dependencies = { "zbirenbaum/copilot.lua" }, - event = { "InsertEnter", "VeryLazy" }, - config = function() - require("copilot_cmp").setup() - end, - }, }, { ui = { icons = { From 235bfea3f16252d127d140c6ff3453b7400ec35d Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 11:09:25 +0800 Subject: [PATCH 214/708] lspkind_symbol_map --- lua/kide/lsp/lsp_ui.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index a33fbca6..0e6e2e37 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -1,5 +1,31 @@ local M = {} -local lspkind_symbol_map = require("lspkind").symbol_map +local lspkind_symbol_map = { + Text = "󰉿", + Method = "󰆧", + Function = "󰊕", + Constructor = "", + Field = "󰜢", + Variable = "󰀫", + Class = "󰠱", + Interface = "", + Module = "", + Property = "󰜢", + Unit = "󰑭", + Value = "󰎠", + Enum = "", + Keyword = "󰌋", + Snippet = "", + Color = "󰏘", + File = "󰈙", + Reference = "󰈇", + Folder = "󰉋", + EnumMember = "", + Constant = "󰏿", + Struct = "󰙅", + Event = "", + Operator = "󰆕", + TypeParameter = "", +} -- remove obsolete TS* highlight groups https://github.com/nvim-treesitter/nvim-treesitter/pull/3656 M.symbol_map = { From c48b0405ba03a09d1f0756e49762882355761370 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 11:42:47 +0800 Subject: [PATCH 215/708] winbar --- lua/kide/lsp/init.lua | 1 + lua/kide/plugins/config/lualine.lua | 2 +- lua/kide/plugins/config/nvim-navic.lua | 36 ---------------------- lua/kide/plugins/lazy-nvim.lua | 42 ++++++++++++++++++++++++-- 4 files changed, 42 insertions(+), 39 deletions(-) delete mode 100644 lua/kide/plugins/config/nvim-navic.lua diff --git a/lua/kide/lsp/init.lua b/lua/kide/lsp/init.lua index c96068bf..d2a094f3 100644 --- a/lua/kide/lsp/init.lua +++ b/lua/kide/lsp/init.lua @@ -114,6 +114,7 @@ vim.api.nvim_create_autocmd("LspAttach", { local bufnr = args.buf local client = vim.lsp.get_client_by_id(args.data.client_id) if client.server_capabilities.documentSymbolProvider then + vim.opt_local.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}" require("nvim-navic").attach(client, bufnr) end end, diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index aca8c8e3..d33e2438 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -28,7 +28,7 @@ local config = { end, }, "filename", - "navic", + -- "navic", }, lualine_x = { "encoding", "fileformat", "filetype" }, lualine_y = { "progress" }, diff --git a/lua/kide/plugins/config/nvim-navic.lua b/lua/kide/plugins/config/nvim-navic.lua deleted file mode 100644 index 6fec4e13..00000000 --- a/lua/kide/plugins/config/nvim-navic.lua +++ /dev/null @@ -1,36 +0,0 @@ -local navic = require("nvim-navic") -local symbol_map = require("kide.lsp.lsp_ui").symbol_map -navic.setup({ - icons = { - File = symbol_map.File.icon .. " ", - Module = symbol_map.Module.icon .. " ", - Namespace = symbol_map.Namespace.icon .. " ", - Package = symbol_map.Package.icon .. " ", - Class = symbol_map.Class.icon .. " ", - Method = symbol_map.Method.icon .. " ", - Property = symbol_map.Property.icon .. " ", - Field = symbol_map.Field.icon .. " ", - Constructor = symbol_map.Constructor.icon .. " ", - Enum = symbol_map.Enum.icon .. "", - Interface = symbol_map.Interface.icon .. "", - Function = symbol_map.Function.icon .. " ", - Variable = symbol_map.Variable.icon .. " ", - Constant = symbol_map.Constant.icon .. " ", - String = symbol_map.String.icon .. " ", - Number = symbol_map.Number.icon .. " ", - Boolean = symbol_map.Boolean.icon .. " ", - Array = symbol_map.Array.icon .. " ", - Object = symbol_map.Object.icon .. " ", - Key = symbol_map.Key.icon .. " ", - Null = symbol_map.Null.icon .. " ", - EnumMember = symbol_map.EnumMember.icon .. " ", - Struct = symbol_map.Struct.icon .. " ", - Event = symbol_map.Event.icon .. " ", - Operator = symbol_map.Operator.icon .. " ", - TypeParameter = symbol_map.TypeParameter.icon .. " ", - }, - -- highlight = false, - separator = "  ", - -- depth_limit = 0, - -- depth_limit_indicator = "..", -}) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 9f929aac..4b08ca77 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -885,7 +885,44 @@ require("lazy").setup({ "SmiteshP/nvim-navic", lazy = true, config = function() - require("kide.plugins.config.nvim-navic") + local navic = require("nvim-navic") + local symbol_map = require("kide.lsp.lsp_ui").symbol_map + navic.setup({ + icons = { + File = symbol_map.File.icon .. " ", + Module = symbol_map.Module.icon .. " ", + Namespace = symbol_map.Namespace.icon .. " ", + Package = symbol_map.Package.icon .. " ", + Class = symbol_map.Class.icon .. " ", + Method = symbol_map.Method.icon .. " ", + Property = symbol_map.Property.icon .. " ", + Field = symbol_map.Field.icon .. " ", + Constructor = symbol_map.Constructor.icon .. " ", + Enum = symbol_map.Enum.icon .. "", + Interface = symbol_map.Interface.icon .. "", + Function = symbol_map.Function.icon .. " ", + Variable = symbol_map.Variable.icon .. " ", + Constant = symbol_map.Constant.icon .. " ", + String = symbol_map.String.icon .. " ", + Number = symbol_map.Number.icon .. " ", + Boolean = symbol_map.Boolean.icon .. " ", + Array = symbol_map.Array.icon .. " ", + Object = symbol_map.Object.icon .. " ", + Key = symbol_map.Key.icon .. " ", + Null = symbol_map.Null.icon .. " ", + EnumMember = symbol_map.EnumMember.icon .. " ", + Struct = symbol_map.Struct.icon .. " ", + Event = symbol_map.Event.icon .. " ", + Operator = symbol_map.Operator.icon .. " ", + TypeParameter = symbol_map.TypeParameter.icon .. " ", + }, + lazy_update_context = true, + highlight = true, + safe_output = true, + separator = " > ", + -- depth_limit = 0, + -- depth_limit_indicator = "..", + }) end, }, @@ -929,7 +966,8 @@ require("lazy").setup({ end end - return require("ufo").getFolds(bufnr, "lsp") + return require("ufo") + .getFolds(bufnr, "lsp") :catch(function(err) return handleFallbackException(err, "treesitter") end) From 7672466c828f3c0bc9fe9c8c76924c328a329087 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 11:48:35 +0800 Subject: [PATCH 216/708] bdelete --- lua/kide/core/keybindings.lua | 2 +- lua/kide/plugins/lazy-nvim.lua | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 04eab992..e3422543 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -37,7 +37,7 @@ M.setup = function() require("kide.core.utils").close_other_bufline() end, {}) map("n", "s", ":w", opt) - map("n", "w", ":bd", opt) + map("n", "w", ":Bdelete", opt) map("n", "W", ":%bd", opt) map("n", "q", ":q", opt) -- buffer diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 4b08ca77..9cedebf5 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -156,6 +156,10 @@ require("lazy").setup({ require("kide.plugins.config.bufferline") end, }, + { + "famiu/bufdelete.nvim", + cmd = { "Bdelete" }, + }, -- treesitter (新增) { From 7bd2c70d84f6b0b511d8ffd93a286352757a7a6b Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 13:46:43 +0800 Subject: [PATCH 217/708] update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f37bdb0b..dc0732ca 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # NVIM IDE -可配置 `Java`, `Rust`, `C/C++`, `JavaScript` 等编程语言开发环境。 极速启动 (`startuptime` 20 ~ 70 ms)。 +可配置 `Java`, `Rust`, `C/C++`, `JavaScript` 等编程语言开发环境。 极速启动 (`startuptime` 15 ~ 60 ms)。 使用 `neovim-nightly` 版本。 From 24fbb5c18d7195f3706f483867054601ac2025d0 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 15:47:07 +0800 Subject: [PATCH 218/708] noice.nvim --- lua/kide/core/keybindings.lua | 79 +++++++++++++++-------------- lua/kide/plugins/config/lualine.lua | 25 ++++++++- lua/kide/plugins/lazy-nvim.lua | 54 +++++++++++++------- lua/kide/theme/gruvbox.lua | 20 ++++++++ 4 files changed, 123 insertions(+), 55 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index e3422543..75a8c15a 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -16,50 +16,50 @@ M.setup = function() -- n 模式下粘贴系统剪切板的内容 map("n", "v", '"+p', opt) -- 取消搜索高亮显示 - map("n", "", ":nohlsearch", opt) - map("n", "", ":nohlsearch", opt) + map("n", "", "nohlsearch", opt) + map("n", "", "nohlsearch", opt) keymap("n", "", "h", opt) keymap("n", "", "j", opt) keymap("n", "", "k", opt) keymap("n", "", "l", opt) - map("n", "", ":res +5", opt) - map("n", "", ":res -5", opt) - map("n", "", ":res -5", opt) - map("n", "", ":res +5", opt) - map("n", "", ":vertical resize+5", opt) - map("n", "", ":vertical resize-5", opt) - map("n", "", ":vertical resize-5", opt) - map("n", "", ":vertical resize+5", opt) + map("n", "", "res +5", opt) + map("n", "", "res -5", opt) + map("n", "", "res -5", opt) + map("n", "", "res +5", opt) + map("n", "", "vertical resize+5", opt) + map("n", "", "vertical resize-5", opt) + map("n", "", "vertical resize-5", opt) + map("n", "", "vertical resize+5", opt) vim.api.nvim_create_user_command("BufferCloseOther", function() require("kide.core.utils").close_other_bufline() end, {}) - map("n", "s", ":w", opt) - map("n", "w", ":Bdelete", opt) - map("n", "W", ":%bd", opt) - map("n", "q", ":q", opt) + map("n", "s", "write", opt) + map("n", "w", "Bdelete", opt) + map("n", "W", "%bd", opt) + map("n", "q", "q", opt) -- buffer - map("n", "n", ":BufferLineCycleNext ", opt) - map("n", "p", ":BufferLineCyclePrev ", opt) + map("n", "n", "BufferLineCycleNext ", opt) + map("n", "p", "BufferLineCyclePrev ", opt) -- window - map("n", "", ":vertical resize +5 ", opt) - map("n", "", ":vertical resize -5 ", opt) + map("n", "", "vertical resize +5 ", opt) + map("n", "", "vertical resize -5 ", opt) -- " 退出 terminal 模式 map("t", "", "", opt) -- map("t", "jk", "", opt) -- ToggleTerm - map("n", "", ":ToggleTerm", opt) - map("t", "", ":ToggleTerm", opt) - map("n", "tt", ":ToggleTerm", opt) - map("v", "tt", ":ToggleTermSendVisualSelection", opt) + map("n", "", "ToggleTerm", opt) + map("t", "", "ToggleTerm", opt) + map("n", "tt", "ToggleTerm", opt) + map("v", "tt", "ToggleTermSendVisualSelection", opt) -- map("t", "tt", ":ToggleTerm", opt) -- symbols-outline.nvim - map("n", "o", ":SymbolsOutline", opt) + map("n", "o", "SymbolsOutline", opt) -- Telescope map("n", "ff", "Telescope find_files", opt) @@ -79,24 +79,29 @@ M.setup = function() map("n", "fh", "Telescope help_tags", opt) -- translate - map("n", "tz", ":Translate ZH -source=EN -parse_after=window -output=floating", opt) - map("v", "tz", ":Translate ZH -source=EN -parse_after=window -output=floating", opt) - map("n", "te", ":Translate EN -source=ZH -parse_after=window -output=floating", opt) - map("v", "te", ":Translate EN -source=ZH -parse_after=window -output=floating", opt) + map("n", "tz", "Translate ZH -source=EN -parse_after=window -output=floating", opt) + map("v", "tz", "Translate ZH -source=EN -parse_after=window -output=floating", opt) + map("n", "te", "Translate EN -source=ZH -parse_after=window -output=floating", opt) + map("v", "te", "Translate EN -source=ZH -parse_after=window -output=floating", opt) -- camel_case require("kide.core.utils").camel_case_init() -- nvim-dap - keymap("n", "", ":lua require'dap'.continue()", opt) - keymap("n", "", ":lua require'dap'.step_over()", opt) - keymap("n", "", ":lua require'dap'.step_into()", opt) - keymap("n", "", ":lua require'dap'.step_out()", opt) - keymap("n", "db", ":lua require'dap'.toggle_breakpoint()", opt) - keymap("n", "dB", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))", opt) - keymap("n", "dp", ":lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))", opt) - keymap("n", "dr", ":lua require'dap'.repl.open()", opt) - keymap("n", "dl", ":lua require'dap'.run_last()", opt) + keymap("n", "", "lua require'dap'.continue()", opt) + keymap("n", "", "lua require'dap'.step_over()", opt) + keymap("n", "", "lua require'dap'.step_into()", opt) + keymap("n", "", "lua require'dap'.step_out()", opt) + keymap("n", "db", "lua require'dap'.toggle_breakpoint()", opt) + keymap("n", "dB", "lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))", opt) + keymap( + "n", + "dp", + "lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))", + opt + ) + keymap("n", "dr", "lua require'dap'.repl.open()", opt) + keymap("n", "dl", "lua require'dap'.run_last()", opt) -- nvim-dap-ui keymap("n", "ds", ':lua require("dapui").float_element(vim.Nil, { enter = true}) ', opt) @@ -124,7 +129,7 @@ M.setup = function() map("n", "ts", "Telescope toggletasks spawn", opt) -- nvimTree - map("n", "e", ":NvimTreeToggle", opt) + map("n", "e", "NvimTreeToggle", opt) -- set keybinds for both INSERT and VISUAL. vim.api.nvim_set_keymap("i", "", "luasnip-next-choice", {}) diff --git a/lua/kide/plugins/config/lualine.lua b/lua/kide/plugins/config/lualine.lua index d33e2438..29079a6c 100644 --- a/lua/kide/plugins/config/lualine.lua +++ b/lua/kide/plugins/config/lualine.lua @@ -30,7 +30,30 @@ local config = { "filename", -- "navic", }, - lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_x = { + { + require("noice").api.status.message.get_hl, + cond = require("noice").api.status.message.has, + }, + { + require("noice").api.status.command.get, + cond = require("noice").api.status.command.has, + color = { fg = "#fabd2f" }, + }, + { + require("noice").api.status.mode.get, + cond = require("noice").api.status.mode.has, + color = { fg = "#fabd2f" }, + }, + { + require("noice").api.status.search.get, + cond = require("noice").api.status.search.has, + color = { fg = "#fabd2f" }, + }, + "encoding", + "fileformat", + "filetype", + }, lualine_y = { "progress" }, lualine_z = { "location" }, }, diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 9cedebf5..ef43d53b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -513,6 +513,7 @@ require("lazy").setup({ render = "default", timeout = 3000, minimum_width = 50, + background_colour = "#000000", icons = { ERROR = "", WARN = "", @@ -525,6 +526,41 @@ require("lazy").setup({ vim.notify = notify end, }, + { + "folke/noice.nvim", + event = "VeryLazy", + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + config = function() + require("noice").setup({ + messages = { + enabled = true, -- enables the Noice messages UI + view = "notify", -- default view for messages + view_error = "notify", -- view for errors + view_warn = "notify", -- view for warnings + view_history = "messages", -- view for :messages + view_search = "virtualtext", -- view for search count messages. Set to `false` to disable + }, + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = false, + ["vim.lsp.util.stylize_markdown"] = false, + ["cmp.entry.get_documentation"] = false, + }, + hover = { + enabled = false, + }, + signature = { + enabled = false, + }, + }, + }) + require("kide.theme.gruvbox").load_noice_highlights() + require("telescope").load_extension("noice") + end, + }, -- 颜色显示 { @@ -790,21 +826,6 @@ require("lazy").setup({ end, }, - -- LSP 进度 - { - "j-hui/fidget.nvim", - lazy = true, - tag = "legacy", - event = "LspAttach", - config = function() - require("fidget").setup({ - text = { - done = "", - }, - }) - end, - }, - -- 查找替换 { "windwp/nvim-spectre", @@ -970,8 +991,7 @@ require("lazy").setup({ end end - return require("ufo") - .getFolds(bufnr, "lsp") + return require("ufo").getFolds(bufnr, "lsp") :catch(function(err) return handleFallbackException(err, "treesitter") end) diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index 750341b9..c24b939e 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -92,4 +92,24 @@ M.load_indent_blankline_highlights = function() }) end +M.load_noice_highlights = function() + M.load_highlights({ + NoiceCmdlinePopupBorderCmdline = { fg = colors.yellow, bg = nil }, + NoiceCmdlinePopupBorderFilter = { fg = colors.yellow, bg = nil }, + NoiceCmdlinePopupBorderHelp = { fg = colors.yellow, bg = nil }, + NoiceCmdlinePopupBorderInput = { fg = colors.yellow, bg = nil }, + NoiceCmdlinePopupBorderLua = { fg = colors.yellow, bg = nil }, + NoiceCmdlinePopupBorderSearch = { fg = colors.yellow, bg = nil }, + + NoiceCmdlinePopupTitle = { fg = colors.yellow, bg = nil }, + + NoiceCmdlineIconCmdline = { fg = colors.yellow, bg = nil }, + NoiceCmdlineIconFilter = { fg = colors.yellow, bg = nil }, + NoiceCmdlineIconHelp = { fg = colors.yellow, bg = nil }, + NoiceCmdlineIconInput = { fg = colors.yellow, bg = nil }, + NoiceCmdlineIconLua = { fg = colors.yellow, bg = nil }, + NoiceCmdlineIconSearch = { fg = colors.yellow, bg = nil }, + }) +end + return M From 75bf763a0eeda473c77756e0a39956597dab205e Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 15:49:23 +0800 Subject: [PATCH 219/708] keymap --- lua/kide/core/keybindings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 75a8c15a..fc4129e0 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -59,7 +59,7 @@ M.setup = function() -- map("t", "tt", ":ToggleTerm", opt) -- symbols-outline.nvim - map("n", "o", "SymbolsOutline", opt) + map("n", "o", "SymbolsOutline", opt) -- Telescope map("n", "ff", "Telescope find_files", opt) From cab76c8ef44ae955f912165694635023bcc908d2 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 15:59:02 +0800 Subject: [PATCH 220/708] flash.nvim --- lua/kide/plugins/lazy-nvim.lua | 55 ++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index ef43d53b..3b4d01c7 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -815,15 +815,52 @@ require("lazy").setup({ -- 快速跳转 { - "ggandor/leap.nvim", - lazy = true, - keys = { "s", "S" }, - config = function() - require("leap").add_default_mappings() - require("leap").opts.safe_labels = {} - vim.keymap.del({ "x", "o" }, "x") - vim.keymap.del({ "x", "o" }, "X") - end, + "folke/flash.nvim", + event = "VeryLazy", + opts = {}, + -- stylua: ignore + keys = { + { + "s", + mode = { "n", "x", "o" }, + function() + require("flash").jump() + end, + desc = "Flash", + }, + { + "S", + mode = { "n", "o", "x" }, + function() + require("flash").treesitter() + end, + desc = "Flash Treesitter", + }, + { + "r", + mode = "o", + function() + require("flash").remote() + end, + desc = "Remote Flash", + }, + { + "R", + mode = { "o", "x" }, + function() + require("flash").treesitter_search() + end, + desc = "Treesitter Search", + }, + { + "", + mode = { "c" }, + function() + require("flash").toggle() + end, + desc = "Toggle Flash Search", + }, + }, }, -- 查找替换 From 99b662932939d73e1b1c49e4064a6f1545976a52 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 16:05:39 +0800 Subject: [PATCH 221/708] Date --- lua/kide/core/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/kide/core/init.lua b/lua/kide/core/init.lua index ff1ebaad..73b616a2 100644 --- a/lua/kide/core/init.lua +++ b/lua/kide/core/init.lua @@ -5,4 +5,6 @@ vim.schedule(function() require("kide.core.utils.maven").setup() require("kide.core.utils.jdtls").setup() require("kide.core.utils.pandoc").setup() + + vim.api.nvim_create_user_command("Date", "lua print(os.date())", {}) end) From ed9c255c578a7151b97a35c2162df9baf41a9afa Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 16:17:22 +0800 Subject: [PATCH 222/708] NoiceConfirmBorder --- lua/kide/theme/gruvbox.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/kide/theme/gruvbox.lua b/lua/kide/theme/gruvbox.lua index c24b939e..6e476724 100644 --- a/lua/kide/theme/gruvbox.lua +++ b/lua/kide/theme/gruvbox.lua @@ -100,6 +100,7 @@ M.load_noice_highlights = function() NoiceCmdlinePopupBorderInput = { fg = colors.yellow, bg = nil }, NoiceCmdlinePopupBorderLua = { fg = colors.yellow, bg = nil }, NoiceCmdlinePopupBorderSearch = { fg = colors.yellow, bg = nil }, + NoiceConfirmBorder = { fg = colors.yellow, bg = nil }, NoiceCmdlinePopupTitle = { fg = colors.yellow, bg = nil }, From 4038c5a17c8e1d727a235283c25f21fd17ce5243 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 23 Jul 2023 20:28:13 +0800 Subject: [PATCH 223/708] bufferline --- lua/kide/plugins/config/bufferline.lua | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/lua/kide/plugins/config/bufferline.lua b/lua/kide/plugins/config/bufferline.lua index afcdcbd5..bfb6c347 100644 --- a/lua/kide/plugins/config/bufferline.lua +++ b/lua/kide/plugins/config/bufferline.lua @@ -1,5 +1,8 @@ -require("bufferline").setup({ +local bufferline = require("bufferline") +bufferline.setup({ options = { + mode = "buffers", + style_preset = bufferline.style_preset.minimal, -- 使用 nvim 内置lsp diagnostics = "nvim_lsp", diagnostics_indicator = function(count, level, diagnostics_dict, context) @@ -15,17 +18,6 @@ require("bufferline").setup({ { filetype = "NvimTree", text = function() - -- return "File Explorer" - -- git symbolic-ref --short -q HEAD - -- git --no-pager rev-parse --show-toplevel --absolute-git-dir --abbrev-ref HEAD - -- git --no-pager rev-parse --short HEAD - -- local b = vim.fn.trim(vim.fn.system("git symbolic-ref --short -q HEAD")) - -- if string.match(b, "fatal") then - -- b = "" - -- else - -- b = "  " .. b - -- end - -- return vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") .. b return "File Explorer" end, padding = 1, @@ -79,12 +71,11 @@ require("bufferline").setup({ text_align = "left", }, }, + indicator = { + style = "none", + }, color_icons = true, show_buffer_close_icons = true, - -- show_buffer_default_icon = true, show_close_icon = false, - show_tab_indicators = true, - -- separator_style = "slant" | "thick" | "thin" | { 'any', 'any' }, - -- separator_style = "slant", }, }) From 65aab26a8c97a74c95fedb0488f8f78d3e37fc89 Mon Sep 17 00:00:00 2001 From: luokai Date: Mon, 24 Jul 2023 15:57:07 +0800 Subject: [PATCH 224/708] jdt:// doc fmt --- lua/kide/lsp/lsp_ui.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/kide/lsp/lsp_ui.lua b/lua/kide/lsp/lsp_ui.lua index 0e6e2e37..ff2172bd 100644 --- a/lua/kide/lsp/lsp_ui.lua +++ b/lua/kide/lsp/lsp_ui.lua @@ -134,10 +134,10 @@ M.init = function() -- 文档格式化 local function markdown_format(input) if input then - input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@"]*)%]%(file:/[^%)]+%)', function(i1) + input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@<>]*)%]%(file:/[^%)]+%)', function(i1) return "`" .. i1 .. "`" end) - input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@"]*)%]%(jdt://[^%)]+%)', function(i1) + input = string.gsub(input, '%[([%a%$_]?[%.%w%(%)*"+,\\_%[%]%s :%-@<>]*)%]%(jdt://[^%)]+%)', function(i1) return "`" .. i1 .. "`" end) end From c63f2d77ac5ebe52afd833ea94b16d870b52cd1b Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 26 Jul 2023 11:40:58 +0800 Subject: [PATCH 225/708] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/core/keybindings.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index fc4129e0..68a57c25 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -78,12 +78,6 @@ M.setup = function() map("n", "fb", "Telescope buffers", opt) map("n", "fh", "Telescope help_tags", opt) - -- translate - map("n", "tz", "Translate ZH -source=EN -parse_after=window -output=floating", opt) - map("v", "tz", "Translate ZH -source=EN -parse_after=window -output=floating", opt) - map("n", "te", "Translate EN -source=ZH -parse_after=window -output=floating", opt) - map("v", "te", "Translate EN -source=ZH -parse_after=window -output=floating", opt) - -- camel_case require("kide.core.utils").camel_case_init() From 4d397d8e31b62c823fbacfe5b337f6145fb38478 Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 26 Jul 2023 11:41:42 +0800 Subject: [PATCH 226/708] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index dc0732ca..43aa3a80 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,6 @@ git clone https://github.com/JavaHello/nvim.git | Code Action | `Normal` | `ca` | | Debug | `Normal` | `F5` or `:DapContinue` | | 断点 | `Normal` | `db` | -| 翻译 en->zh | `Normal` or `Visual` | `tz` | -| 翻译 zh->en | `Normal` or `Visual` | `te` | | 内置终端 | `Command` | `:ToggleTerm` | | Tasks 列表 | `Normal` | `ts` | | 代码折叠 | `Normal` | `zc` | From 560a6eff839ad57de2909a5267be69d4aaa8e72f Mon Sep 17 00:00:00 2001 From: luokai Date: Wed, 26 Jul 2023 15:07:55 +0800 Subject: [PATCH 227/708] browse --- lua/kide/plugins/config/browse-nvim.lua | 12 ++++++++++++ lua/kide/plugins/lazy-nvim.lua | 1 + 2 files changed, 13 insertions(+) diff --git a/lua/kide/plugins/config/browse-nvim.lua b/lua/kide/plugins/config/browse-nvim.lua index bfa2d657..0ad53ad9 100644 --- a/lua/kide/plugins/config/browse-nvim.lua +++ b/lua/kide/plugins/config/browse-nvim.lua @@ -9,6 +9,18 @@ local bookmarks = { "https://docs.spring.io/spring-framework/docs/5.3.12/reference/html/", "https://github.com/", "https://stackoverflow.com/", + "https://mvnrepository.com/", + ["github"] = { + ["name"] = "search github from neovim", + ["code_search"] = "https://github.com/search?q=%s&type=code", + ["repo_search"] = "https://github.com/search?q=%s&type=repositories", + ["issues_search"] = "https://github.com/search?q=%s&type=issues", + ["pulls_search"] = "https://github.com/search?q=%s&type=pullrequests", + }, + ["maven"] = { + ["name"] = "search maven from neovim", + ["jar_search"] = "https://mvnrepository.com/search?q=%s", + }, } local function command(name, rhs, opts) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 3b4d01c7..044d99ae 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -917,6 +917,7 @@ require("lazy").setup({ { "lalitmee/browse.nvim", lazy = true, + event = { "VeryLazy" }, cmd = { "Browse", }, From c3cbc4fb51247abb805e5bda0bf4bb0bf7dd2d2e Mon Sep 17 00:00:00 2001 From: luokai Date: Fri, 28 Jul 2023 15:17:35 +0800 Subject: [PATCH 228/708] update icon --- lua/kide/plugins/lazy-nvim.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 044d99ae..14bf5208 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -1155,7 +1155,7 @@ require("lazy").setup({ }, { ui = { icons = { - task = " ", + task = "✓ ", }, }, }) From 14d1179dd8460f64c3a3601b689ea8d2f8bedacc Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 29 Jul 2023 13:17:15 +0800 Subject: [PATCH 229/708] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=B8=85=E7=90=86=20data=20=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/kide/lsp/java.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/kide/lsp/java.lua b/lua/kide/lsp/java.lua index ee7f2de7..d67f5e00 100644 --- a/lua/kide/lsp/java.lua +++ b/lua/kide/lsp/java.lua @@ -130,7 +130,8 @@ local function jdtls_launcher() if lombok_jar ~= nil then table.insert(cmd, "--jvm-arg=-javaagent:" .. lombok_jar) end - table.insert(cmd, "-data=" .. workspace_dir) + table.insert(cmd, "-data") + table.insert(cmd, workspace_dir) return cmd end From 9b9dc0fc5d556b655b2b96358e6b8b822fed7a85 Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 29 Jul 2023 21:59:59 +0800 Subject: [PATCH 230/708] flash config --- lua/kide/plugins/lazy-nvim.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 14bf5208..99ba7e4b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -817,7 +817,16 @@ require("lazy").setup({ { "folke/flash.nvim", event = "VeryLazy", - opts = {}, + opts = { + modes = { + search = { + enabled = false, + }, + char = { + enabled = false, + }, + }, + }, -- stylua: ignore keys = { { From b00438e24aa1e14eb16f603881354caf05e701df Mon Sep 17 00:00:00 2001 From: luokai Date: Sat, 29 Jul 2023 22:04:32 +0800 Subject: [PATCH 231/708] bdelete --- lua/kide/core/keybindings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/kide/core/keybindings.lua b/lua/kide/core/keybindings.lua index 68a57c25..0e54c719 100644 --- a/lua/kide/core/keybindings.lua +++ b/lua/kide/core/keybindings.lua @@ -37,7 +37,7 @@ M.setup = function() require("kide.core.utils").close_other_bufline() end, {}) map("n", "s", "write", opt) - map("n", "w", "Bdelete", opt) + map("n", "w", "bdelete", opt) map("n", "W", "%bd", opt) map("n", "q", "q", opt) -- buffer From 4aa1a479b31b7a3309a97759e97b83d6aafff4fc Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 30 Jul 2023 16:59:55 +0800 Subject: [PATCH 232/708] refactoring --- lua/kide/plugins/lazy-nvim.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 99ba7e4b..4f983b17 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -1123,6 +1123,29 @@ require("lazy").setup({ require("kide.plugins.config.flutter-tools") end, }, + { + "ThePrimeagen/refactoring.nvim", + lazy = true, + ft = { + "typescript", + "javascript", + "lua", + "c", + "cpp", + "go", + "python", + "java", + "php", + "ruby", + }, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("refactoring").setup({}) + end, + }, -- ui { From ee6888bfc09d7ac4e52be5e4cd870e4b3300fb86 Mon Sep 17 00:00:00 2001 From: luokai Date: Sun, 30 Jul 2023 17:29:45 +0800 Subject: [PATCH 233/708] copilot --- lua/kide/plugins/lazy-nvim.lua | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lua/kide/plugins/lazy-nvim.lua b/lua/kide/plugins/lazy-nvim.lua index 4f983b17..874eb42b 100644 --- a/lua/kide/plugins/lazy-nvim.lua +++ b/lua/kide/plugins/lazy-nvim.lua @@ -1175,13 +1175,27 @@ require("lazy").setup({ require("todo-comments").setup({}) end, }, - { - "zbirenbaum/copilot.lua", + -- { + -- "zbirenbaum/copilot.lua", + -- enabled = config.plugin.copilot.enable, + -- lazy = true, + -- cmd = "Copilot", + -- config = function() + -- require("copilot").setup({}) + -- end, + -- }, + { + "github/copilot.vim", enabled = config.plugin.copilot.enable, - lazy = true, - cmd = "Copilot", config = function() - require("copilot").setup({}) + vim.g.copilot_enabled = true + vim.g.copilot_no_tab_map = true + vim.cmd('imap