From 9e4a2c45165a6ba8160999513e256077173ef6d6 Mon Sep 17 00:00:00 2001 From: aaronsms Date: Thu, 29 Jul 2021 17:04:03 +0800 Subject: fix: change peekDefinition method location --- lua/lsp/keybinds.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lsp/keybinds.lua b/lua/lsp/keybinds.lua index 5722dab7..820ebce9 100644 --- a/lua/lsp/keybinds.lua +++ b/lua/lsp/keybinds.lua @@ -13,7 +13,7 @@ function M.setup() { noremap = true, silent = true } ) - vim.cmd "nnoremap gp lua require'lsp.utils'.PeekDefinition()" + vim.cmd "nnoremap gp lua require'lsp.service'.PeekDefinition()" vim.cmd "nnoremap K :lua vim.lsp.buf.hover()" vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" -- cgit v1.2.3 From 3eaf6d461c896ba9fadaf63af0ecbe3769653fa2 Mon Sep 17 00:00:00 2001 From: Pasi Bergman Date: Thu, 29 Jul 2021 16:03:03 +0300 Subject: fix: Use null-ls eslint diagnostics config with eslint_d exe (#1159) --- lua/lsp/null-ls.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index a231698a..6a31de26 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -13,15 +13,25 @@ local find_local_exe = function(exe) return local_exe end +-- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint +local get_normalized_exe = function(exe, type) + if type == "diagnostics" and exe == "eslint_d" then + return "eslint" + end + return exe +end + local function setup_ls(exe, type) if utils.has_value(local_executables, exe) then - local smart_executable = null_ls.builtins[type][exe] + local normalized_exe = get_normalized_exe(exe, type) + local smart_executable = null_ls.builtins[type][normalized_exe] local local_executable = find_local_exe(exe) if vim.fn.executable(local_executable) == 1 then smart_executable._opts.command = local_executable table.insert(sources, smart_executable) else if vim.fn.executable(exe) == 1 then + smart_executable._opts.command = exe table.insert(sources, smart_executable) end end -- cgit v1.2.3 From e6aceea12e2a685f458b0a351d4191fdb0ad21ef Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 29 Jul 2021 21:40:10 -0400 Subject: add packerstatus --- lua/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 9d4e7744..595e076e 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -97,6 +97,7 @@ M.config = function() i = { "PackerInstall", "Install" }, r = { "lua require('utils').reload_lv_config()", "Reload" }, s = { "PackerSync", "Sync" }, + S = { "PackerStatus", "Status" }, u = { "PackerUpdate", "Update" }, }, @@ -151,7 +152,6 @@ M.config = function() "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})", "Prev Diagnostic", }, - l = { "silent lua require('lint').try_lint()", "Lint" }, q = { "Telescope quickfix", "Quickfix" }, r = { "lua vim.lsp.buf.rename()", "Rename" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, -- cgit v1.2.3 From ce8c63c6bf99bc5d8be5fc6c8db6023318791ac2 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Fri, 30 Jul 2021 23:14:25 +0430 Subject: Fix the galaxyline null pointer issue (#1179) --- lua/core/galaxyline.lua | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index aafe99bc..cf7d35d0 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -200,19 +200,38 @@ table.insert(gls.right, { }, }) +-- TODO: this function doesn't need to be this complicated local function get_attached_provider_name(msg) msg = msg or "LSP Inactive" - local buf_ft = vim.bo.filetype local buf_clients = vim.lsp.buf_get_clients() if next(buf_clients) == nil then return msg end + + local utils = require "utils" + local config = require("null-ls.config").get() + local builtins = require "null-ls.builtins" + -- concat all the builtin formatters and linters from null-ls + local all_things = builtins.formatting + for k, v in pairs(builtins.diagnostics) do + all_things[k] = v + end + + -- if we open multiple filetypes in the same session + -- null-ls will register multiple formatter/linters + -- but only use the ones that support vim.bo.filetype + -- so we need to filter them local buf_client_names = {} for _, client in pairs(buf_clients) do if client.name == "null-ls" then - table.insert(buf_client_names, lvim.lang[buf_ft].linters[1]) - table.insert(buf_client_names, lvim.lang[buf_ft].formatter.exe) + -- for every registered formatter/linter in the current buffer + for _, v in pairs(config._names) do + -- show only the ones that are being used for the current filetype + if utils.has_value(all_things[v].filetypes, buf_ft) then + table.insert(buf_client_names, v) + end + end else table.insert(buf_client_names, client.name) end -- cgit v1.2.3 From 9d89929d9bb47d1f78c2d3945b761da2f24a5643 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 31 Jul 2021 06:06:08 +0200 Subject: Enable querying lang-server formatting capabilities (#1078) --- lua/core/galaxyline.lua | 30 +-- lua/default-config.lua | 521 ++++++++++++++++++++++++++++++------------------ lua/lsp/init.lua | 98 +++++---- lua/lsp/keybinds.lua | 67 ++++++- lua/lsp/null-ls.lua | 113 ++++++----- lua/lsp/service.lua | 122 ------------ lua/utils/init.lua | 6 + 7 files changed, 531 insertions(+), 426 deletions(-) delete mode 100644 lua/lsp/service.lua (limited to 'lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index cf7d35d0..2aae0242 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -6,6 +6,8 @@ if not status_ok then return end +local utils = require "utils" + -- NOTE: if someone defines colors but doesn't have them then this will break local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette") if not palette_status_ok then @@ -200,36 +202,22 @@ table.insert(gls.right, { }, }) --- TODO: this function doesn't need to be this complicated local function get_attached_provider_name(msg) msg = msg or "LSP Inactive" - local buf_ft = vim.bo.filetype local buf_clients = vim.lsp.buf_get_clients() if next(buf_clients) == nil then return msg end - - local utils = require "utils" - local config = require("null-ls.config").get() - local builtins = require "null-ls.builtins" - -- concat all the builtin formatters and linters from null-ls - local all_things = builtins.formatting - for k, v in pairs(builtins.diagnostics) do - all_things[k] = v - end - - -- if we open multiple filetypes in the same session - -- null-ls will register multiple formatter/linters - -- but only use the ones that support vim.bo.filetype - -- so we need to filter them + local buf_ft = vim.bo.filetype local buf_client_names = {} + local null_ls_providers = require("lsp.null-ls").requested_providers for _, client in pairs(buf_clients) do if client.name == "null-ls" then - -- for every registered formatter/linter in the current buffer - for _, v in pairs(config._names) do - -- show only the ones that are being used for the current filetype - if utils.has_value(all_things[v].filetypes, buf_ft) then - table.insert(buf_client_names, v) + for _, provider in pairs(null_ls_providers) do + if vim.tbl_contains(provider.filetypes, buf_ft) then + if not vim.tbl_contains(buf_client_names, provider.name) then + table.insert(buf_client_names, provider.name) + end end end else diff --git a/lua/default-config.lua b/lua/default-config.lua index 25c6dcef..41636757 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -47,6 +47,7 @@ lvim = { popup_border = "single", default_keybinds = true, on_attach_callback = nil, + on_init_callback = nil, }, plugins = { @@ -54,11 +55,13 @@ lvim = { }, autocommands = {}, + debug = false, } local schemas = nil -local common_on_attach = require("lsp.service").common_on_attach -local common_capabilities = require("lsp.service").common_capabilities() +local common_on_attach = require("lsp").common_on_attach +local common_capabilities = require("lsp").common_capabilities() +local common_on_init = require("lsp").common_on_init local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") if status_ok then schemas = jsonls_settings.get_default_schemas() @@ -67,9 +70,12 @@ end -- TODO move all of this into lang specific files, only require when using lvim.lang = { asm = { - formatter = { - exe = "asmfmt", - args = {}, + formatters = { + { + -- @usage can be asmfmt + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -78,9 +84,12 @@ lvim.lang = { }, }, beancount = { - formatter = { - exe = "bean_format", - args = {}, + formatters = { + { + -- @usage can be bean_format + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -88,19 +97,21 @@ lvim.lang = { setup = { cmd = { "beancount-langserver" }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, c = { - formatter = { - exe = "clang_format", - args = {}, - stdin = true, - }, - linters = { - "clangtidy", + formatters = { + { + -- @usage can be clang_format or uncrustify + exe = "", + args = {}, + stdin = true, + }, }, + linters = {}, lsp = { provider = "clangd", setup = { @@ -113,20 +124,21 @@ lvim.lang = { "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, cpp = { - formatter = { - exe = "clang_format", - args = {}, - stdin = true, - }, - linters = { - "cppcheck", - "clangtidy", + formatters = { + { + -- @usage can be clang_format or uncrustify + exe = "", + args = {}, + stdin = true, + }, }, + linters = {}, lsp = { provider = "clangd", setup = { @@ -139,14 +151,18 @@ lvim.lang = { "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, crystal = { - formatter = { - exe = "crystal_format", - args = {}, + formatters = { + { + -- @usage can be crystal_format + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -154,14 +170,18 @@ lvim.lang = { setup = { cmd = { "crystalline" }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, cs = { - formatter = { - exe = "clang_format", - args = {}, + formatters = { + { + -- @usage can be clang_format or uncrustify + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -174,14 +194,18 @@ lvim.lang = { tostring(vim.fn.getpid()), }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, cmake = { - formatter = { - exe = "cmake_format", - args = {}, + formatters = { + { + -- @usage can be cmake_format + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -192,15 +216,16 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, clojure = { - formatter = { + formatters = { { exe = "", args = {}, - }, + } }, linters = {}, lsp = { provider = "clojure_lsp", @@ -210,14 +235,18 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, css = { - formatter = { - exe = "prettier", - args = {}, + formatters = { + { + -- @usage can be prettier or prettierd + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -229,14 +258,18 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, d = { - formatter = { - exe = "dfmt", - args = {}, + formatters = { + { + -- @usage can be dfmt + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -244,15 +277,19 @@ lvim.lang = { setup = { cmd = { "serve-d" }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, dart = { - formatter = { - exe = "dart_format", - args = {}, - stdin = true, + formatters = { + { + -- @usage can be dart_format + exe = "", + args = {}, + stdin = true, + }, }, linters = {}, lsp = { @@ -264,14 +301,18 @@ lvim.lang = { "--lsp", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, docker = { - formatter = { - exe = "", - args = {}, + formatters = { + { + exe = "", + args = {}, + }, + -- @usage can be {"hadolint"} }, linters = {}, lsp = { @@ -282,15 +323,19 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, elixir = { - formatter = { - exe = "mix", - args = {}, - stdin = true, + formatters = { + { + -- @usage can be mix + exe = "", + args = {}, + stdin = true, + }, }, linters = {}, lsp = { @@ -300,15 +345,19 @@ lvim.lang = { DATA_PATH .. "/lspinstall/elixir/elixir-ls/language_server.sh", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, elm = { - formatter = { - exe = "elm_format", - args = {}, - stdin = true, + formatters = { + { + -- @usage can be elm_format + exe = "", + args = {}, + stdin = true, + }, }, linters = {}, lsp = { @@ -318,6 +367,7 @@ lvim.lang = { DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-language-server", }, on_attach = common_on_attach, + on_init = common_on_init, init_options = { elmAnalyseTrigger = "change", elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format", @@ -328,9 +378,12 @@ lvim.lang = { }, }, erlang = { - formatter = { - exe = "erlfmt", - args = {}, + formatters = { + { + -- @usage can be erlfmt + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -340,35 +393,40 @@ lvim.lang = { "erlang_ls", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, emmet = { active = false }, fish = { - formatter = { - exe = "fish_indent", - args = {}, + formatters = { + { + -- @usage can be fish_indent + exe = "", + args = {}, + }, }, linters = {}, lsp = { provider = "", setup = { on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, go = { - formatter = { - exe = "gofmt", - args = {}, - stdin = true, - }, - linters = { - "golangcilint", - "revive", + formatters = { + { + -- @usage can be gofmt or goimports or gofumpt + exe = "", + args = {}, + stdin = true, + }, }, + linters = {}, lsp = { provider = "gopls", setup = { @@ -376,15 +434,16 @@ lvim.lang = { DATA_PATH .. "/lspinstall/go/gopls", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, graphql = { - formatter = { + formatters = { { exe = "", args = {}, - }, + } }, linters = {}, lsp = { provider = "graphql", @@ -396,20 +455,20 @@ lvim.lang = { "stream", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, html = { - formatter = { - exe = "prettier", - args = {}, - }, - linters = { - "tidy", - -- https://docs.errata.ai/vale/scoping#html - "vale", + formatters = { + { + -- @usage can be prettier or prettierd + exe = "", + args = {}, + }, }, + linters = {}, lsp = { provider = "html", setup = { @@ -419,14 +478,18 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, java = { - formatter = { - exe = "prettier", - args = { "--stdin-filepath", vim.api.nvim_buf_get_name(0) }, + formatters = { + { + -- @usage can be clang_format or uncrustify + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -434,15 +497,19 @@ lvim.lang = { setup = { cmd = { DATA_PATH .. "/lspinstall/java/jdtls.sh" }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, json = { - formatter = { - exe = "json_tool", - args = {}, - stdin = true, + formatters = { + { + -- @usage can be json_tool or prettier or prettierd + exe = "", + args = {}, + stdin = true, + }, }, linters = {}, lsp = { @@ -454,6 +521,7 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, settings = { json = { @@ -477,10 +545,10 @@ lvim.lang = { }, }, julia = { - formatter = { + formatters = { { exe = "", args = {}, - }, + } }, linters = {}, lsp = { provider = "julials", @@ -493,15 +561,16 @@ lvim.lang = { CONFIG_PATH .. "/utils/julia/run.jl", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, kotlin = { - formatter = { + formatters = { { exe = "", args = {}, - }, + } }, linters = {}, lsp = { provider = "kotlin_language_server", @@ -510,6 +579,7 @@ lvim.lang = { DATA_PATH .. "/lspinstall/kotlin/server/bin/kotlin-language-server", }, on_attach = common_on_attach, + on_init = common_on_init, root_dir = function(fname) local util = require "lspconfig/util" @@ -530,11 +600,14 @@ lvim.lang = { }, }, lua = { - formatter = { - exe = "stylua", - args = {}, + formatters = { + { + -- @usage can be stylua or lua_format + exe = "stylua", + args = {}, + }, }, - linters = { "luacheck" }, + linters = {}, lsp = { provider = "sumneko_lua", setup = { @@ -543,7 +616,9 @@ lvim.lang = { "-E", DATA_PATH .. "/lspinstall/lua/main.lua", }, + capabilities = common_capabilities, on_attach = common_on_attach, + on_init = common_on_init, settings = { Lua = { runtime = { @@ -572,20 +647,26 @@ lvim.lang = { }, }, nginx = { - formatter = { - exe = "nginx_beautifier", - args = { - provider = "", - setup = {}, + formatters = { + { + -- @usage can be nginx_beautifier + exe = "", + args = { + provider = "", + setup = {}, + }, }, }, linters = {}, lsp = {}, }, perl = { - formatter = { - exe = "perltidy", - args = {}, + formatters = { + { + -- @usage can be perltidy + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -594,9 +675,12 @@ lvim.lang = { }, }, sql = { - formatter = { - exe = "sqlformat", - args = {}, + formatters = { + { + -- @usage can be sqlformat + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -607,9 +691,12 @@ lvim.lang = { }, }, php = { - formatter = { - exe = "phpcbf", - args = {}, + formatters = { + { + -- @usage can be phpcbf + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -620,6 +707,7 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, filetypes = { "php", "phtml" }, settings = { intelephense = { @@ -632,28 +720,30 @@ lvim.lang = { }, }, puppet = { - formatter = { + formatters = { { exe = "", args = {}, - }, + } }, linters = {}, lsp = { provider = "puppet", setup = { on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, javascript = { - -- @usage can be prettier or eslint - formatter = { - exe = "prettier", - args = {}, - }, - linters = { - "eslint", + -- @usage can be prettier or prettier_d_slim or prettierd + formatters = { + { + exe = "", + args = {}, + }, }, + -- @usage can be {"eslint"} or {"eslint_d"} + linters = {}, lsp = { provider = "tsserver", setup = { @@ -663,19 +753,21 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, javascriptreact = { - -- @usage can be prettier or eslint - formatter = { - exe = "prettier", - args = {}, - }, - linters = { - "eslint", + formatters = { + { + -- @usage can be prettier or prettier_d_slim or prettierd + exe = "", + args = {}, + }, }, + -- @usage can be {"eslint"} or {"eslint_d"} + linters = {}, lsp = { provider = "tsserver", setup = { @@ -685,21 +777,20 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, python = { - -- @usage can be flake8 or yapf - formatter = { - exe = "black", - args = {}, - }, - linters = { - "flake8", - "pylint", - "mypy", + formatters = { + { + -- @usage can be black or yapf or isort + exe = "", + args = {}, + }, }, + linters = {}, lsp = { provider = "pyright", setup = { @@ -708,6 +799,7 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, @@ -715,9 +807,12 @@ lvim.lang = { -- R -e 'install.packages("formatR",repos = "http://cran.us.r-project.org")' -- R -e 'install.packages("readr",repos = "http://cran.us.r-project.org")' r = { - formatter = { - exe = "format_r", - args = {}, + formatters = { + { + -- @usage can be format_r + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -730,16 +825,20 @@ lvim.lang = { "languageserver::run()", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, ruby = { - formatter = { - exe = "rufo", - args = {}, + formatters = { + { + -- @usage can be rufo + exe = "", + args = {}, + }, }, - linters = { "ruby" }, + linters = {}, lsp = { provider = "solargraph", setup = { @@ -748,14 +847,18 @@ lvim.lang = { "stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, rust = { - formatter = { - exe = "rustfmt", - args = {}, + formatters = { + { + -- @usage can be rustfmt + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -765,32 +868,38 @@ lvim.lang = { DATA_PATH .. "/lspinstall/rust/rust-analyzer", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, scala = { - formatter = { - exe = "scalafmt", - args = {}, + formatters = { + { + -- @usage can be scalafmt + exe = "", + args = {}, + }, }, linters = { "" }, lsp = { provider = "metals", setup = { on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, sh = { - -- @usage can be 'shfmt' - formatter = { - exe = "shfmt", - args = {}, + formatters = { + { + -- @usage can be shfmt + exe = "", + args = {}, + }, }, - -- @usage can be 'shellcheck' - linters = { "shellcheck" }, + linters = {}, lsp = { provider = "bashls", setup = { @@ -799,15 +908,16 @@ lvim.lang = { "start", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, svelte = { - formatter = { + formatters = { { exe = "", args = {}, - }, + } }, linters = {}, lsp = { provider = "svelte", @@ -817,14 +927,18 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, swift = { - formatter = { - exe = "swiftformat", - args = {}, + formatters = { + { + -- @usage can be swiftformat + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -835,6 +949,7 @@ lvim.lang = { "sourcekit-lsp", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, @@ -852,9 +967,12 @@ lvim.lang = { }, }, terraform = { - formatter = { - exe = "terraform_fmt", - args = {}, + formatters = { + { + -- @usage can be terraform_fmt + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -865,35 +983,41 @@ lvim.lang = { "serve", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, tex = { - formatter = { - exe = "latexindent", - args = {}, - stdin = false, + formatters = { + { + exe = "", + args = {}, + stdin = false, + }, + -- @usage can be chktex or vale }, - linters = { "chktex" }, + linters = {}, lsp = { provider = "texlab", setup = { cmd = { DATA_PATH .. "/lspinstall/latex/texlab" }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, typescript = { - -- @usage can be prettier or eslint - formatter = { - exe = "prettier", - args = {}, - }, - linters = { - "eslint", + formatters = { + { + -- @usage can be prettier or prettierd or prettier_d_slim + exe = "", + args = {}, + }, + -- @usage can be {"eslint"} or {"eslint_d"} }, + linters = {}, lsp = { provider = "tsserver", setup = { @@ -903,19 +1027,21 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, typescriptreact = { - -- @usage can be prettier or eslint - formatter = { - exe = "prettier", - args = {}, - }, - linters = { - "eslint", + formatters = { + { + -- @usage can be prettier or prettierd or prettier_d_slim + exe = "", + args = {}, + }, }, + -- @usage can be {"eslint"} or {"eslint_d"} + linters = {}, lsp = { provider = "tsserver", setup = { @@ -925,15 +1051,19 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, vim = { - formatter = { - exe = "", - args = {}, + formatters = { + { + exe = "", + args = {}, + }, }, + -- @usage can be {"vint"} linters = { "" }, lsp = { provider = "vimls", @@ -943,15 +1073,20 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, vue = { - formatter = { - exe = "prettier", - args = {}, + formatters = { + { + -- @usage can be prettier or prettierd or prettier_d_slim + exe = "", + args = {}, + }, }, + -- @usage can be {"eslint"} or {"eslint_d"} linters = {}, lsp = { provider = "vuels", @@ -960,14 +1095,18 @@ lvim.lang = { DATA_PATH .. "/lspinstall/vue/node_modules/.bin/vls", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, yaml = { - formatter = { - exe = "prettier", - args = {}, + formatters = { + { + -- @usage can be prettier or prettierd + exe = "", + args = {}, + }, }, linters = {}, lsp = { @@ -978,16 +1117,17 @@ lvim.lang = { "--stdio", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, }, zig = { - formatter = { + formatters = { { exe = "", args = {}, stdin = false, - }, + } }, linters = {}, lsp = { provider = "zls", @@ -996,6 +1136,7 @@ lvim.lang = { "zls", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 62c42fd8..67007e81 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,55 +1,79 @@ -local utils = require "utils" -local service = require "lsp.service" -local null_ls = require "lsp.null-ls" local M = {} - +local u = require "utils" function M.config() require("lsp.kind").setup() require("lsp.handlers").setup() require("lsp.signs").setup() - require("lsp.keybinds").setup() end -function M.setup(lang) - local lang_server = lvim.lang[lang].lsp - local provider = lang_server.provider - if utils.check_lsp_client_active(provider) then - return +local function lsp_highlight_document(client) + if lvim.lsp.document_highlight == false then + return -- we don't need further + end + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec( + [[ + hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]], + false + ) end +end - local overrides = lvim.lsp.override +local function formatter_handler(client) + local buffer_filetype = vim.bo.filetype + local ext_provider = lvim.lang[buffer_filetype].formatter.exe - if utils.is_table(overrides) then - if utils.has_value(overrides, lang) then - return - end + if ext_provider then + client.resolved_capabilities.document_formatting = false + u.lvim_log( + string.format("Overriding [%s] formatting if exists, Using provider [%s] instead", client.name, ext_provider) + ) end +end - if utils.is_string(overrides) then - if overrides == lang then - return - end +function M.common_capabilities() + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.textDocument.completion.completionItem.resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, + } + return capabilities +end + +function M.common_on_init(client, bufnr) + if lvim.lsp.on_init_callback then + lvim.lsp.on_init_callback(client, bufnr) + return end - local sources = null_ls.setup(lang) - - for _, source in pairs(sources) do - local method = source.method - local format_method = "NULL_LS_FORMATTING" - - if utils.is_table(method) then - if utils.has_value(method, format_method) then - lang_server.setup.on_attach = service.no_formatter_on_attach - end - end - - if utils.is_string(method) then - if method == format_method then - lang_server.setup.on_attach = service.no_formatter_on_attach - end - end + formatter_handler(client) +end + +function M.common_on_attach(client, bufnr) + if lvim.lsp.on_attach_callback then + lvim.lsp.on_attach_callback(client, bufnr) end + lsp_highlight_document(client) + require("lsp.keybinds").setup() + require("lsp.null-ls").setup(vim.bo.filetype) +end - if provider == "" or provider == nil then +function M.setup(lang) + local lang_server = lvim.lang[lang].lsp + local provider = lang_server.provider + if require("utils").check_lsp_client_active(provider) then return end diff --git a/lua/lsp/keybinds.lua b/lua/lsp/keybinds.lua index 820ebce9..cc0d4ec9 100644 --- a/lua/lsp/keybinds.lua +++ b/lua/lsp/keybinds.lua @@ -1,5 +1,70 @@ local M = {} +-- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/ +function M.preview_location(location, context, before_context) + -- location may be LocationLink or Location (more useful for the former) + context = context or 15 + before_context = before_context or 0 + local uri = location.targetUri or location.uri + if uri == nil then + return + end + local bufnr = vim.uri_to_bufnr(uri) + if not vim.api.nvim_buf_is_loaded(bufnr) then + vim.fn.bufload(bufnr) + end + + local range = location.targetRange or location.range + local contents = vim.api.nvim_buf_get_lines( + bufnr, + range.start.line - before_context, + range["end"].line + 1 + context, + false + ) + local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") + return vim.lsp.util.open_floating_preview(contents, filetype, { border = lvim.lsp.popup_border }) +end + +function M.preview_location_callback(_, method, result) + local context = 15 + if result == nil or vim.tbl_isempty(result) then + print("No location found: " .. method) + return nil + end + if vim.tbl_islist(result) then + M.floating_buf, M.floating_win = M.preview_location(result[1], context) + else + M.floating_buf, M.floating_win = M.preview_location(result, context) + end +end + +function M.PeekDefinition() + if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then + vim.api.nvim_set_current_win(M.floating_win) + else + local params = vim.lsp.util.make_position_params() + return vim.lsp.buf_request(0, "textDocument/definition", params, M.preview_location_callback) + end +end + +function M.PeekTypeDefinition() + if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then + vim.api.nvim_set_current_win(M.floating_win) + else + local params = vim.lsp.util.make_position_params() + return vim.lsp.buf_request(0, "textDocument/typeDefinition", params, M.preview_location_callback) + end +end + +function M.PeekImplementation() + if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then + vim.api.nvim_set_current_win(M.floating_win) + else + local params = vim.lsp.util.make_position_params() + return vim.lsp.buf_request(0, "textDocument/implementation", params, M.preview_location_callback) + end +end + function M.setup() if lvim.lsp.default_keybinds then vim.cmd "nnoremap gd lua vim.lsp.buf.definition()" @@ -13,7 +78,7 @@ function M.setup() { noremap = true, silent = true } ) - vim.cmd "nnoremap gp lua require'lsp.service'.PeekDefinition()" + vim.cmd "nnoremap gp lua require'lsp.keybinds'.PeekDefinition()" vim.cmd "nnoremap K :lua vim.lsp.buf.hover()" vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 6a31de26..d2222602 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -1,76 +1,79 @@ local M = {} +local u = require "utils" +local null_ls = require "null-ls" -local _, null_ls = pcall(require, "null-ls") -local utils = require "utils" -local sources = {} +local nodejs_local_providers = { "prettier", "prettierd", "prettier_d_slim", "eslint_d", "eslint" } -local local_executables = { "prettier", "prettierd", "prettier_d_slim", "eslint_d", "eslint" } +M.requested_providers = {} -local find_local_exe = function(exe) - vim.cmd "let root_dir = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "root_dir" - local local_exe = root_dir .. "/node_modules/.bin/" .. exe - return local_exe +local function is_nodejs_provider(provider) + for _, local_provider in ipairs(nodejs_local_providers) do + if local_provider == provider.exe then + return true + end + end + return false end --- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint -local get_normalized_exe = function(exe, type) - if type == "diagnostics" and exe == "eslint_d" then - return "eslint" +local function is_provider_found(provider) + -- special case: fallback to "eslint" + -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint + provider._opts.command = provider._opts.command == "eslint_d" and "eslint" or provider._opts.command + + local retval = { is_local = false, path = nil } + if vim.fn.executable(provider._opts.command) == 1 then + return false, provider._opts.command end - return exe + if is_nodejs_provider(provider) then + vim.cmd "let root_dir = FindRootDirectory()" + local root_dir = vim.api.nvim_get_var "root_dir" + local local_provider_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command + if vim.fn.executable(local_provider_command) == 1 then + retval.is_local = true + retval.path = local_provider_command + end + end + return retval.is_local, retval.path end -local function setup_ls(exe, type) - if utils.has_value(local_executables, exe) then - local normalized_exe = get_normalized_exe(exe, type) - local smart_executable = null_ls.builtins[type][normalized_exe] - local local_executable = find_local_exe(exe) - if vim.fn.executable(local_executable) == 1 then - smart_executable._opts.command = local_executable - table.insert(sources, smart_executable) - else - if vim.fn.executable(exe) == 1 then - smart_executable._opts.command = exe - table.insert(sources, smart_executable) - end - end - else - if null_ls.builtins[type][exe] and vim.fn.executable(null_ls.builtins[type][exe]._opts.command) then - table.insert(sources, null_ls.builtins[type][exe]) - end +local function validate_provider(provider) + local is_local, provider_path = is_provider_found(provider) + if not provider_path then + u.lvim_log(string.format("Unable to find the path for: [%s]", provider)) + return false end - null_ls.register { sources = sources } + if is_local then + provider._opts.command = provider_path + end + return true end -- TODO: for linters and formatters with spaces and '-' replace with '_' -local function setup(filetype, type) - local executables = nil - if type == "diagnostics" then - executables = lvim.lang[filetype].linters +function M.setup(filetype) + for _, formatter in pairs(lvim.lang[filetype].formatters) do + local builtin_formatter = null_ls.builtins.formatting[formatter.exe] + -- FIXME: why doesn't this work? + -- builtin_formatter._opts.args = formatter.args or builtin_formatter._opts.args + -- builtin_formatter._opts.to_stdin = formatter.stdin or builtin_formatter._opts.to_stdin + table.insert(M.requested_providers, builtin_formatter) + u.lvim_log(string.format("Using format provider: [%s]", formatter.exe)) end - if type == "formatting" then - executables = lvim.lang[filetype].formatter.exe + + for _, linter in pairs(lvim.lang[filetype].linters) do + local builtin_diagnoser = null_ls.builtins.diagnostics[linter.exe] + -- FIXME: why doesn't this work? + -- builtin_diagnoser._opts.args = linter.args or builtin_diagnoser._opts.args + -- builtin_diagnoser._opts.to_stdin = linter.stdin or builtin_diagnoser._opts.to_stdin + table.insert(M.requested_providers, builtin_diagnoser) + u.lvim_log(string.format("Using linter provider: [%s]", linter.exe)) end - if utils.is_table(executables) then - for _, exe in pairs(executables) do - if exe ~= "" then - setup_ls(exe, type) - end + for idx, provider in pairs(M.requested_providers) do + if not validate_provider(provider) then + table.remove(M.requested_providers, idx) end end - if utils.is_string(executables) and executables ~= "" then - setup_ls(executables, type) - end -end - --- TODO: return the formatter if one was registered, then turn off the builtin formatter -function M.setup(filetype) - setup(filetype, "formatting") - setup(filetype, "diagnostics") - lvim.sources = sources - return sources + null_ls.register { sources = M.requested_providers } end return M diff --git a/lua/lsp/service.lua b/lua/lsp/service.lua deleted file mode 100644 index 0c49bacd..00000000 --- a/lua/lsp/service.lua +++ /dev/null @@ -1,122 +0,0 @@ -local M = {} - -local function lsp_highlight_document(client) - if lvim.lsp.document_highlight == false then - return -- we don't need further - end - -- Set autocommands conditional on server_capabilities - if client.resolved_capabilities.document_highlight then - vim.api.nvim_exec( - [[ - hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 - hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 - hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 - augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]], - false - ) - end -end - -function M.lsp_highlight_document(client) - lsp_highlight_document(client) -end - --- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/ -function M.preview_location(location, context, before_context) - -- location may be LocationLink or Location (more useful for the former) - context = context or 15 - before_context = before_context or 0 - local uri = location.targetUri or location.uri - if uri == nil then - return - end - local bufnr = vim.uri_to_bufnr(uri) - if not vim.api.nvim_buf_is_loaded(bufnr) then - vim.fn.bufload(bufnr) - end - - local range = location.targetRange or location.range - local contents = vim.api.nvim_buf_get_lines( - bufnr, - range.start.line - before_context, - range["end"].line + 1 + context, - false - ) - local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") - return vim.lsp.util.open_floating_preview(contents, filetype, { border = lvim.lsp.popup_border }) -end - -function M.preview_location_callback(_, method, result) - local context = 15 - if result == nil or vim.tbl_isempty(result) then - print("No location found: " .. method) - return nil - end - if vim.tbl_islist(result) then - M.floating_buf, M.floating_win = M.preview_location(result[1], context) - else - M.floating_buf, M.floating_win = M.preview_location(result, context) - end -end - -function M.PeekDefinition() - if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then - vim.api.nvim_set_current_win(M.floating_win) - else - local params = vim.lsp.util.make_position_params() - return vim.lsp.buf_request(0, "textDocument/definition", params, M.preview_location_callback) - end -end - -function M.PeekTypeDefinition() - if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then - vim.api.nvim_set_current_win(M.floating_win) - else - local params = vim.lsp.util.make_position_params() - return vim.lsp.buf_request(0, "textDocument/typeDefinition", params, M.preview_location_callback) - end -end - -function M.PeekImplementation() - if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then - vim.api.nvim_set_current_win(M.floating_win) - else - local params = vim.lsp.util.make_position_params() - return vim.lsp.buf_request(0, "textDocument/implementation", params, M.preview_location_callback) - end -end - -function M.common_on_attach(client, bufnr) - if lvim.lsp.on_attach_callback then - lvim.lsp.on_attach_callback(client, bufnr) - end - lsp_highlight_document(client) -end - -function M.no_formatter_on_attach(client, bufnr) - if lvim.lsp.on_attach_callback then - lvim.lsp.on_attach_callback(client, bufnr) - end - lsp_highlight_document(client) - client.resolved_capabilities.document_formatting = false -end - -function M.common_capabilities() - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities.textDocument.completion.completionItem.resolveSupport = { - properties = { - "documentation", - "detail", - "additionalTextEdits", - }, - } - return capabilities -end - -return M diff --git a/lua/utils/init.lua b/lua/utils/init.lua index fe1e09aa..a41bfc10 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -162,6 +162,12 @@ function utils.gsub_args(args) return args end +function utils.lvim_log(msg) + if lvim.debug then + vim.notify(msg, vim.log.levels.DEBUG) + end +end + return utils -- TODO: find a new home for these autocommands -- cgit v1.2.3 From 5646462a50c9e537952fba6c2faca518c3f04139 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 31 Jul 2021 00:07:47 -0400 Subject: fix format_handler --- lua/lsp/init.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lua') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 67007e81..b24d62f2 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -29,13 +29,12 @@ local function lsp_highlight_document(client) end local function formatter_handler(client) - local buffer_filetype = vim.bo.filetype - local ext_provider = lvim.lang[buffer_filetype].formatter.exe - - if ext_provider then + local formatter_exe = lvim.lang[vim.bo.filetype].formatters[1].exe + if formatter_exe and formatter_exe ~= "" then client.resolved_capabilities.document_formatting = false + __FORMATTER_OVERRIDE = true u.lvim_log( - string.format("Overriding [%s] formatting if exists, Using provider [%s] instead", client.name, ext_provider) + string.format("Overriding [%s] formatting if exists, Using provider [%s] instead", client.name, formatter_exe) ) end end -- cgit v1.2.3 From bfb85f96207f5f83427f466ed55a45a69f25a6d3 Mon Sep 17 00:00:00 2001 From: "MengChen. Huang" Date: Sat, 31 Jul 2021 06:22:25 +0200 Subject: add gdscript lsp support (#1164) --- lua/default-config.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 41636757..0ef666aa 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -1141,6 +1141,22 @@ lvim.lang = { }, }, }, + gdscript = { + formatter = {}, + linters = {}, + lsp = { + provider = "gdscript", + setup = { + cmd = { + "nc", + "localhost", + "6008", + }, + on_attach = common_on_attach, + capabilities = common_capabilities, + }, + }, + }, } require("core.which-key").config() -- cgit v1.2.3 From 997acc5720348182fe45309e94ac3fa7cfd28ef6 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 31 Jul 2021 00:32:41 -0400 Subject: add on init to gdscript --- lua/default-config.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 0ef666aa..8623bc4b 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -1153,6 +1153,7 @@ lvim.lang = { "6008", }, on_attach = common_on_attach, + on_init = common_on_init, capabilities = common_capabilities, }, }, -- cgit v1.2.3 From b9ca4a157e5b2f2b34ca3800c79fc5b0f993e7d1 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sat, 31 Jul 2021 09:03:23 +0430 Subject: make telescope keybindings more sane (#1154) --- lua/core/telescope.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lua') diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index 65760d6c..37d59982 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -40,11 +40,11 @@ M.config = function() -- buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, mappings = { i = { - [""] = actions.cycle_history_next, - [""] = actions.cycle_history_prev, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, [""] = actions.close, - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, [""] = actions.smart_send_to_qflist + actions.open_qflist, [""] = actions.select_default + actions.center, -- To disable a keymap, put [map] = false -- cgit v1.2.3 From 2db171eee417de8916237c053244d7a44deac5c1 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sat, 31 Jul 2021 12:15:01 +0430 Subject: fix luacheck issues (#1184) --- lua/core/galaxyline.lua | 2 -- lua/lsp/init.lua | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index 2aae0242..63cffcf9 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -6,8 +6,6 @@ if not status_ok then return end -local utils = require "utils" - -- NOTE: if someone defines colors but doesn't have them then this will break local palette_status_ok, colors = pcall(require, lvim.colorscheme .. ".palette") if not palette_status_ok then diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index b24d62f2..d7109ac3 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -32,7 +32,8 @@ local function formatter_handler(client) local formatter_exe = lvim.lang[vim.bo.filetype].formatters[1].exe if formatter_exe and formatter_exe ~= "" then client.resolved_capabilities.document_formatting = false - __FORMATTER_OVERRIDE = true + -- NOTE: do we still need __FORMATTER_OVERRIDE? + -- __FORMATTER_OVERRIDE = true u.lvim_log( string.format("Overriding [%s] formatting if exists, Using provider [%s] instead", client.name, formatter_exe) ) -- cgit v1.2.3 From d977e7384e8ad449e1ffc039618910a9c780e0cf Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 31 Jul 2021 10:19:57 +0200 Subject: cleanup formatting handler (#1185) --- lua/lsp/init.lua | 8 +++----- lua/utils/init.lua | 10 ---------- 2 files changed, 3 insertions(+), 15 deletions(-) (limited to 'lua') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index d7109ac3..1488aec0 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -29,13 +29,11 @@ local function lsp_highlight_document(client) end local function formatter_handler(client) - local formatter_exe = lvim.lang[vim.bo.filetype].formatters[1].exe - if formatter_exe and formatter_exe ~= "" then + local formatters = lvim.lang[vim.bo.filetype].formatters + if not vim.tbl_isempty(formatters) then client.resolved_capabilities.document_formatting = false - -- NOTE: do we still need __FORMATTER_OVERRIDE? - -- __FORMATTER_OVERRIDE = true u.lvim_log( - string.format("Overriding [%s] formatting if exists, Using provider [%s] instead", client.name, formatter_exe) + string.format("Overriding [%s] formatting if exists, Using provider [%s] instead", client.name, formatters[1].exe) ) end end diff --git a/lua/utils/init.lua b/lua/utils/init.lua index a41bfc10..b4c5fca1 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -110,16 +110,6 @@ function utils.is_string(t) return type(t) == "string" end -function utils.has_value(tab, val) - for _, value in ipairs(tab) do - if value == val then - return true - end - end - - return false -end - function utils.add_keymap(mode, opts, keymaps) for _, keymap in ipairs(keymaps) do vim.api.nvim_set_keymap(mode, keymap[1], keymap[2], opts) -- cgit v1.2.3 From 679b8b69fb0ee8c5249a416845054a1734815d43 Mon Sep 17 00:00:00 2001 From: Luc Sinet Date: Sat, 31 Jul 2021 14:47:31 +0200 Subject: [Refactor] Define keymapppings helpers in utils.keymap (#1176) --- lua/keymappings.lua | 44 +++++++++++++------------------------------- lua/utils/init.lua | 26 -------------------------- lua/utils/keymap.lua | 31 +++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 57 deletions(-) create mode 100644 lua/utils/keymap.lua (limited to 'lua') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 9c0ad217..3cbe797a 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,14 +1,12 @@ -local utils = require "utils" - local opts = { - nnoremap = { noremap = true, silent = true }, - inoremap = { noremap = true, silent = true }, - vnoremap = { noremap = true, silent = true }, - xnoremap = { noremap = true, silent = true }, - generic = { silent = true }, + insert_mode = { noremap = true, silent = true }, + normal_mode = { noremap = true, silent = true }, + visual_mode = { noremap = true, silent = true }, + visual_block_mode = { noremap = true, silent = true }, + term_mode = { silent = true }, } -local default_keys = { +local keymaps = { insert_mode = { -- I hate escape { "jk", "" }, @@ -83,33 +81,17 @@ local default_keys = { if vim.fn.has "mac" == 1 then -- TODO: fix this - default_keys.normal_mode[5][1] = "" - default_keys.normal_mode[6][1] = "" - default_keys.normal_mode[7][1] = "" - default_keys.normal_mode[8][1] = "" -end - -if lvim.leader == " " or lvim.leader == "space" then - vim.g.mapleader = " " -else - vim.g.mapleader = lvim.leader + keymaps.normal_mode[5][1] = "" + keymaps.normal_mode[6][1] = "" + keymaps.normal_mode[7][1] = "" + keymaps.normal_mode[8][1] = "" end -local function get_user_keys(mode) - if lvim.keys[mode] == nil then - return default_keys[mode] - else - return lvim.keys[mode] - end -end - -utils.add_keymap_normal_mode(opts.nnoremap, get_user_keys "normal_mode") -utils.add_keymap_insert_mode(opts.inoremap, get_user_keys "insert_mode") -utils.add_keymap_visual_mode(opts.vnoremap, get_user_keys "visual_mode") -utils.add_keymap_visual_block_mode(opts.xnoremap, get_user_keys "visual_block_mode") -utils.add_keymap_term_mode(opts.generic, get_user_keys "term_mode") +vim.g.mapleader = lvim.leader == "space" and " " or lvim.leader -- navigate tab completion with and -- runs conditionally vim.cmd 'inoremap pumvisible() ? "\\" : "\\"' vim.cmd 'inoremap pumvisible() ? "\\" : "\\"' + +return { keymaps = keymaps, opts = opts } diff --git a/lua/utils/init.lua b/lua/utils/init.lua index b4c5fca1..9eb29ad8 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -110,32 +110,6 @@ function utils.is_string(t) return type(t) == "string" end -function utils.add_keymap(mode, opts, keymaps) - for _, keymap in ipairs(keymaps) do - vim.api.nvim_set_keymap(mode, keymap[1], keymap[2], opts) - end -end - -function utils.add_keymap_normal_mode(opts, keymaps) - utils.add_keymap("n", opts, keymaps) -end - -function utils.add_keymap_visual_mode(opts, keymaps) - utils.add_keymap("v", opts, keymaps) -end - -function utils.add_keymap_visual_block_mode(opts, keymaps) - utils.add_keymap("x", opts, keymaps) -end - -function utils.add_keymap_insert_mode(opts, keymaps) - utils.add_keymap("i", opts, keymaps) -end - -function utils.add_keymap_term_mode(opts, keymaps) - utils.add_keymap("t", opts, keymaps) -end - function utils.unrequire(m) package.loaded[m] = nil _G[m] = nil diff --git a/lua/utils/keymap.lua b/lua/utils/keymap.lua new file mode 100644 index 00000000..121a4888 --- /dev/null +++ b/lua/utils/keymap.lua @@ -0,0 +1,31 @@ +local M = {} + +local mode_adapters = { + insert_mode = "i", + normal_mode = "n", + term_mode = "t", + visual_mode = "v", + visual_block_mode = "x", +} + +-- Load key mappings for a given mode +-- @param mode The keymap mode, can be one of the keys of mode_adapters +-- @param keymaps The list of key mappings +-- @param opts The mapping options +M.load_mode = function(mode, keymaps, opts) + mode = mode_adapters[mode] and mode_adapters[mode] or mode + for _, keymap in ipairs(keymaps) do + vim.api.nvim_set_keymap(mode, keymap[1], keymap[2], opts) + end +end + +-- Load key mappings for all provided modes +-- @param keymaps A list of key mappings for each mode +-- @param opts The mapping options for each mode +M.load = function(keymaps, opts) + for mode, mapping in pairs(keymaps) do + M.load_mode(mode, mapping, opts[mode]) + end +end + +return M -- cgit v1.2.3 From f36082da0dccf4cfc50dd3fec271b7a5cd41aaea Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 31 Jul 2021 14:52:25 +0200 Subject: feat: add diagnostics source name (#1147) --- lua/default-config.lua | 1 + lua/lsp/handlers.lua | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 8623bc4b..4e849688 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -41,6 +41,7 @@ lvim = { }, signs = true, underline = true, + severity_sort = true, }, override = {}, document_highlight = true, diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua index d3a487ae..3a467d42 100644 --- a/lua/lsp/handlers.lua +++ b/lua/lsp/handlers.lua @@ -9,6 +9,40 @@ function M.setup() underline = lvim.lsp.document_highlight, }) + vim.lsp.handlers["textDocument/publishDiagnostics"] = function(_, _, params, client_id, _) + local config = { -- your config + virtual_text = lvim.lsp.diagnostics.virtual_text, + signs = lvim.lsp.diagnostics.signs, + underline = lvim.lsp.diagnostics.underline, + update_in_insert = lvim.lsp.diagnostics.update_in_insert, + severity_sort = lvim.lsp.diagnostics.severity_sort, + } + local uri = params.uri + local bufnr = vim.uri_to_bufnr(uri) + + if not bufnr then + return + end + + local diagnostics = params.diagnostics + + for i, v in ipairs(diagnostics) do + diagnostics[i].message = string.format("%s: %s", v.source, v.message) + + if vim.tbl_contains(vim.tbl_keys(v), "code") then + diagnostics[i].message = diagnostics[i].message .. string.format(" [%s]", v.code) + end + end + + vim.lsp.diagnostic.save(diagnostics, bufnr, client_id) + + if not vim.api.nvim_buf_is_loaded(bufnr) then + return + end + + vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config) + end + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = lvim.lsp.popup_border, }) -- cgit v1.2.3 From 8157f50d1308f42f3db1c7f69c226eb2e5c0b796 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sat, 31 Jul 2021 15:04:22 +0200 Subject: feat: get null-ls registered providers by filetype (#1186) --- lua/core/galaxyline.lua | 14 ++++---------- lua/lsp/null-ls.lua | 11 +++++++++++ lua/utils/init.lua | 26 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 10 deletions(-) (limited to 'lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index 63cffcf9..b2325b19 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -203,25 +203,19 @@ table.insert(gls.right, { local function get_attached_provider_name(msg) msg = msg or "LSP Inactive" local buf_clients = vim.lsp.buf_get_clients() + local utils = require "utils" if next(buf_clients) == nil then return msg end local buf_ft = vim.bo.filetype local buf_client_names = {} - local null_ls_providers = require("lsp.null-ls").requested_providers + local null_ls_providers = require("lsp.null-ls").get_registered_providers_by_filetype(buf_ft) for _, client in pairs(buf_clients) do - if client.name == "null-ls" then - for _, provider in pairs(null_ls_providers) do - if vim.tbl_contains(provider.filetypes, buf_ft) then - if not vim.tbl_contains(buf_client_names, provider.name) then - table.insert(buf_client_names, provider.name) - end - end - end - else + if client.name ~= "null-ls" then table.insert(buf_client_names, client.name) end end + utils.list_extend_unique(buf_client_names, null_ls_providers) return table.concat(buf_client_names, ", ") end diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index d2222602..468d12a6 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -6,6 +6,17 @@ local nodejs_local_providers = { "prettier", "prettierd", "prettier_d_slim", "es M.requested_providers = {} +function M.get_registered_providers_by_filetype(ft) + local matches = {} + for _, provider in pairs(M.requested_providers) do + if vim.tbl_contains(provider.filetypes, ft) then + table.insert(matches, provider.name) + end + end + + return matches +end + local function is_nodejs_provider(provider) for _, local_provider in ipairs(nodejs_local_providers) do if local_provider == provider.exe then diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 9eb29ad8..1685c1ca 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -110,6 +110,32 @@ function utils.is_string(t) return type(t) == "string" end +--- Extends a list-like table with the unique values of another list-like table. +--- +--- NOTE: This mutates dst! +--- +--@see |vim.tbl_extend()| +--- +--@param dst list which will be modified and appended to. +--@param src list from which values will be inserted. +--@param start Start index on src. defaults to 1 +--@param finish Final index on src. defaults to #src +--@returns dst +function utils.list_extend_unique(dst, src, start, finish) + vim.validate { + dst = { dst, "t" }, + src = { src, "t" }, + start = { start, "n", true }, + finish = { finish, "n", true }, + } + for i = start or 1, finish or #src do + if not vim.tbl_contains(dst, src[i]) then + table.insert(dst, src[i]) + end + end + return dst +end + function utils.unrequire(m) package.loaded[m] = nil _G[m] = nil -- cgit v1.2.3 From cf16a2e826774e89d1bfe5812b6f73c3dd049db2 Mon Sep 17 00:00:00 2001 From: Geet Sethi <65440103+sethigeet@users.noreply.github.com> Date: Sat, 31 Jul 2021 19:14:08 +0530 Subject: Add the better peek functions (#1172) --- lua/core/which-key.lua | 6 +++ lua/lsp/keybinds.lua | 67 +---------------------- lua/lsp/peek.lua | 140 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 66 deletions(-) create mode 100644 lua/lsp/peek.lua (limited to 'lua') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 595e076e..17995e87 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -152,6 +152,12 @@ M.config = function() "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})", "Prev Diagnostic", }, + p = { + name = "Peek", + d = { "lua require('lsp.peek').Peek('definition')", "Definition" }, + t = { "lua require('lsp.peek').Peek('typeDefinition')", "Type Definition" }, + i = { "lua require('lsp.peek').Peek('implementation')", "Implementation" }, + }, q = { "Telescope quickfix", "Quickfix" }, r = { "lua vim.lsp.buf.rename()", "Rename" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, diff --git a/lua/lsp/keybinds.lua b/lua/lsp/keybinds.lua index cc0d4ec9..21f29994 100644 --- a/lua/lsp/keybinds.lua +++ b/lua/lsp/keybinds.lua @@ -1,70 +1,5 @@ local M = {} --- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/ -function M.preview_location(location, context, before_context) - -- location may be LocationLink or Location (more useful for the former) - context = context or 15 - before_context = before_context or 0 - local uri = location.targetUri or location.uri - if uri == nil then - return - end - local bufnr = vim.uri_to_bufnr(uri) - if not vim.api.nvim_buf_is_loaded(bufnr) then - vim.fn.bufload(bufnr) - end - - local range = location.targetRange or location.range - local contents = vim.api.nvim_buf_get_lines( - bufnr, - range.start.line - before_context, - range["end"].line + 1 + context, - false - ) - local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") - return vim.lsp.util.open_floating_preview(contents, filetype, { border = lvim.lsp.popup_border }) -end - -function M.preview_location_callback(_, method, result) - local context = 15 - if result == nil or vim.tbl_isempty(result) then - print("No location found: " .. method) - return nil - end - if vim.tbl_islist(result) then - M.floating_buf, M.floating_win = M.preview_location(result[1], context) - else - M.floating_buf, M.floating_win = M.preview_location(result, context) - end -end - -function M.PeekDefinition() - if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then - vim.api.nvim_set_current_win(M.floating_win) - else - local params = vim.lsp.util.make_position_params() - return vim.lsp.buf_request(0, "textDocument/definition", params, M.preview_location_callback) - end -end - -function M.PeekTypeDefinition() - if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then - vim.api.nvim_set_current_win(M.floating_win) - else - local params = vim.lsp.util.make_position_params() - return vim.lsp.buf_request(0, "textDocument/typeDefinition", params, M.preview_location_callback) - end -end - -function M.PeekImplementation() - if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then - vim.api.nvim_set_current_win(M.floating_win) - else - local params = vim.lsp.util.make_position_params() - return vim.lsp.buf_request(0, "textDocument/implementation", params, M.preview_location_callback) - end -end - function M.setup() if lvim.lsp.default_keybinds then vim.cmd "nnoremap gd lua vim.lsp.buf.definition()" @@ -78,7 +13,7 @@ function M.setup() { noremap = true, silent = true } ) - vim.cmd "nnoremap gp lua require'lsp.keybinds'.PeekDefinition()" + vim.cmd "nnoremap gp lua require'lsp.peek'.Peek('definition')" vim.cmd "nnoremap K :lua vim.lsp.buf.hover()" vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" diff --git a/lua/lsp/peek.lua b/lua/lsp/peek.lua new file mode 100644 index 00000000..e512eee0 --- /dev/null +++ b/lua/lsp/peek.lua @@ -0,0 +1,140 @@ +local M = { + floating_buf = nil, + floating_win = nil, + prev_result = nil, +} + +local function create_floating_file(location, opts) + vim.validate { + location = { location, "t" }, + opts = { opts, "t", true }, + } + + -- Set some defaults + opts = opts or {} + local close_events = opts.close_events or { "CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre" } + + -- location may be LocationLink or Location + local uri = location.targetUri or location.uri + if uri == nil then + return + end + local bufnr = vim.uri_to_bufnr(uri) + if not vim.api.nvim_buf_is_loaded(bufnr) then + vim.fn.bufload(bufnr) + end + + local range = location.targetRange or location.range + + local contents = vim.api.nvim_buf_get_lines( + bufnr, + range.start.line, + math.min(range["end"].line + 1 + (opts.context or 10), range.start.line + (opts.max_height or 15)), -- Don't let the window be more that 15 lines long(height) + false + ) + local width, height = vim.lsp.util._make_floating_popup_size(contents, opts) + opts = vim.lsp.util.make_floating_popup_options(width, height, opts) + -- Don't make it minimal as it is meant to be fully featured + opts["style"] = nil + + vim.api.nvim_buf_set_option(bufnr, "bufhidden", "wipe") + + local winnr = vim.api.nvim_open_win(bufnr, false, opts) + vim.api.nvim_win_set_option(winnr, "winblend", 0) + + vim.api.nvim_buf_set_var(bufnr, "lsp_floating_window", winnr) + + -- Set some autocmds to close the window + vim.api.nvim_command( + "autocmd QuitPre ++nested ++once lua pcall(vim.api.nvim_win_close, " .. winnr .. ", true)" + ) + vim.lsp.util.close_preview_autocmd(close_events, winnr) + + return bufnr, winnr +end + +local function preview_location_callback(_, method, result) + if result == nil or vim.tbl_isempty(result) then + print("peek: No location found: " .. method) + return nil + end + + local opts = { + border = "rounded", + context = 10, + } + + if vim.tbl_islist(result) then + M.prev_result = result[1] + M.floating_buf, M.floating_win = create_floating_file(result[1], opts) + else + M.prev_result = result + M.floating_buf, M.floating_win = create_floating_file(result, opts) + end +end + +function M.open_file() + -- Get the file currently open in the floating window + local filepath = vim.fn.expand "%:." + + if not filepath then + print "peek: Unable to open the file!" + return + end + + -- Close the floating window + pcall(vim.api.nvim_win_close, M.floating_win, true) + + -- Edit the file + vim.cmd("edit " .. filepath) + + local winnr = vim.api.nvim_get_current_win() + + -- Set the cursor at the right position + M.set_cursor_to_prev_pos(winnr) +end + +function M.set_cursor_to_prev_pos(winnr) + -- Get position of the thing to peek at + local location = M.prev_result + local range = location.targetRange or location.range + local cursor_pos = { range.start.line + 1, range.start.character } + + -- Set the winnr to the floting window if none was passed in + winnr = winnr or M.floating_win + -- Set the cursor at the correct position in the floating window + vim.api.nvim_win_set_cursor(winnr, cursor_pos) +end + +function M.Peek(what) + -- If a window already exists, focus it at the right position! + if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then + local success_1, _ = pcall(vim.api.nvim_set_current_win, M.floating_win) + if not success_1 then + print "peek: You cannot edit the current file in a preview!" + return + end + + -- Set the cursor at the correct position in the floating window + M.set_cursor_to_prev_pos() + + vim.api.nvim_buf_set_keymap( + M.floating_buf, + "n", + "", + ":lua require('lsp.peek').open_file()", + { noremap = true, silent = true } + ) + else + -- Make a new request and then create the new window in the callback + local params = vim.lsp.util.make_position_params() + local success, _ = pcall(vim.lsp.buf_request, 0, "textDocument/" .. what, params, preview_location_callback) + if not success then + print( + 'peek: Error calling LSP method "textDocument/' .. what .. '". The current language lsp might not support it.' + ) + end + end +end + +return M -- cgit v1.2.3 From fe5daa722fb75ad85c24936cbb645018bb9d655b Mon Sep 17 00:00:00 2001 From: Luc Sinet Date: Sat, 31 Jul 2021 16:12:29 +0200 Subject: [Feature] Expose lsp config (#1156) --- lua/default-config.lua | 47 ++++++++++++++++++++++++++++++++++++++++++----- lua/keymappings.lua | 12 ++++++++++++ lua/lsp/handlers.lua | 2 +- lua/lsp/init.lua | 35 +++++++++++++++++------------------ lua/lsp/keybinds.lua | 27 --------------------------- lua/lsp/kind.lua | 33 --------------------------------- lua/lsp/signs.lua | 20 -------------------- lua/utils/init.lua | 8 -------- 8 files changed, 72 insertions(+), 112 deletions(-) delete mode 100644 lua/lsp/keybinds.lua delete mode 100644 lua/lsp/kind.lua delete mode 100644 lua/lsp/signs.lua (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 4e849688..6527ad77 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -34,19 +34,55 @@ lvim = { }, lsp = { + completion = { + item_kind = { + "  (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)", + }, + }, diagnostics = { + signs = { + active = true, + values = { + { name = "LspDiagnosticsSignError", text = "" }, + { name = "LspDiagnosticsSignWarning", text = "" }, + { name = "LspDiagnosticsSignHint", text = "" }, + { name = "LspDiagnosticsSignInformation", text = "" }, + }, + }, virtual_text = { prefix = "", spacing = 0, }, - signs = true, underline = true, severity_sort = true, }, override = {}, document_highlight = true, popup_border = "single", - default_keybinds = true, on_attach_callback = nil, on_init_callback = nil, }, @@ -60,9 +96,10 @@ lvim = { } local schemas = nil -local common_on_attach = require("lsp").common_on_attach -local common_capabilities = require("lsp").common_capabilities() -local common_on_init = require("lsp").common_on_init +local lsp = require "lsp" +local common_on_attach = lsp.common_on_attach +local common_capabilities = lsp.common_capabilities() +local common_on_init = lsp.common_on_init local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") if status_ok then schemas = jsonls_settings.get_default_schemas() diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 3cbe797a..34116023 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -49,6 +49,18 @@ local keymaps = { { "", ":call QuickFixToggle()" }, -- {'', 'compe#complete()', {noremap = true, silent = true, expr = true}}, + + -- LSP + { "gd", "lua vim.lsp.buf.definition()" }, + { "gD", "lua vim.lsp.buf.declaration()" }, + { "gr", "lua vim.lsp.buf.references()" }, + { "gi", "lua vim.lsp.buf.implementation()" }, + { "gl", "lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })" }, + { "gp", "lua require'lsp.peek'.Peek('definition')" }, + { "K", "lua vim.lsp.buf.hover()" }, + { "", "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" }, + { "", "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" }, + -- { "", "lua vim.lsp.buf.signature_help()" }, }, term_mode = { diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua index 3a467d42..a25db3c1 100644 --- a/lua/lsp/handlers.lua +++ b/lua/lsp/handlers.lua @@ -5,7 +5,7 @@ local M = {} function M.setup() vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = lvim.lsp.diagnostics.virtual_text, - signs = lvim.lsp.diagnostics.signs, + signs = lvim.lsp.diagnostics.signs.active, underline = lvim.lsp.document_highlight, }) diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 1488aec0..13b64dac 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,9 +1,14 @@ local M = {} local u = require "utils" + function M.config() - require("lsp.kind").setup() + vim.lsp.protocol.CompletionItemKind = lvim.lsp.completion.item_kind + + for _, sign in ipairs(lvim.lsp.diagnostics.signs.values) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name }) + end + require("lsp.handlers").setup() - require("lsp.signs").setup() end local function lsp_highlight_document(client) @@ -28,16 +33,6 @@ local function lsp_highlight_document(client) end end -local function formatter_handler(client) - local formatters = lvim.lang[vim.bo.filetype].formatters - if not vim.tbl_isempty(formatters) then - client.resolved_capabilities.document_formatting = false - u.lvim_log( - string.format("Overriding [%s] formatting if exists, Using provider [%s] instead", client.name, formatters[1].exe) - ) - end -end - function M.common_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true @@ -56,7 +51,12 @@ function M.common_on_init(client, bufnr) lvim.lsp.on_init_callback(client, bufnr) return end - formatter_handler(client) + + local formatters = lvim.lang[vim.bo.filetype].formatters + if not vim.tbl_isempty(formatters) then + client.resolved_capabilities.document_formatting = false + u.lvim_log(string.format("Overriding [%s] formatter with [%s]", client.name, formatters[1].exe)) + end end function M.common_on_attach(client, bufnr) @@ -64,18 +64,17 @@ function M.common_on_attach(client, bufnr) lvim.lsp.on_attach_callback(client, bufnr) end lsp_highlight_document(client) - require("lsp.keybinds").setup() require("lsp.null-ls").setup(vim.bo.filetype) end function M.setup(lang) - local lang_server = lvim.lang[lang].lsp - local provider = lang_server.provider - if require("utils").check_lsp_client_active(provider) then + local lsp = lvim.lang[lang].lsp + if require("utils").check_lsp_client_active(lsp.provider) then return end - require("lspconfig")[provider].setup(lang_server.setup) + local lspconfig = require "lspconfig" + lspconfig[lsp.provider].setup(lsp.setup) end return M diff --git a/lua/lsp/keybinds.lua b/lua/lsp/keybinds.lua deleted file mode 100644 index 21f29994..00000000 --- a/lua/lsp/keybinds.lua +++ /dev/null @@ -1,27 +0,0 @@ -local M = {} - -function M.setup() - if lvim.lsp.default_keybinds then - vim.cmd "nnoremap gd lua vim.lsp.buf.definition()" - vim.cmd "nnoremap gD lua vim.lsp.buf.declaration()" - vim.cmd "nnoremap gr lua vim.lsp.buf.references()" - vim.cmd "nnoremap gi lua vim.lsp.buf.implementation()" - vim.api.nvim_set_keymap( - "n", - "gl", - 'lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = "single" })', - { noremap = true, silent = true } - ) - - vim.cmd "nnoremap gp lua require'lsp.peek'.Peek('definition')" - vim.cmd "nnoremap K :lua vim.lsp.buf.hover()" - vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" - vim.cmd "nnoremap :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" - -- vim.cmd "nnoremap gs lua vim.lsp.buf.signature_help()" - -- scroll down hover doc or scroll in definition preview - -- scroll up hover doc - -- vim.cmd 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()' - end -end - -return M diff --git a/lua/lsp/kind.lua b/lua/lsp/kind.lua deleted file mode 100644 index e3b95ecb..00000000 --- a/lua/lsp/kind.lua +++ /dev/null @@ -1,33 +0,0 @@ -local M = {} - -function M.setup() - vim.lsp.protocol.CompletionItemKind = { - -- symbols for autocomplete - "  (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)", - } -end -return M diff --git a/lua/lsp/signs.lua b/lua/lsp/signs.lua deleted file mode 100644 index fab6d302..00000000 --- a/lua/lsp/signs.lua +++ /dev/null @@ -1,20 +0,0 @@ -local M = {} -function M.setup() - vim.fn.sign_define( - "LspDiagnosticsSignError", - { texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError" } - ) - vim.fn.sign_define( - "LspDiagnosticsSignWarning", - { texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning" } - ) - vim.fn.sign_define( - "LspDiagnosticsSignHint", - { texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint" } - ) - vim.fn.sign_define( - "LspDiagnosticsSignInformation", - { texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation" } - ) -end -return M diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 1685c1ca..a404254b 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -102,14 +102,6 @@ function utils.check_lsp_client_active(name) return false end -function utils.is_table(t) - return type(t) == "table" -end - -function utils.is_string(t) - return type(t) == "string" -end - --- Extends a list-like table with the unique values of another list-like table. --- --- NOTE: This mutates dst! -- cgit v1.2.3 From c1ace3715447448c42837dac4851ddae90c65e56 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 31 Jul 2021 10:46:34 -0400 Subject: gs for signature help --- lua/keymappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 34116023..3a509c69 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -56,11 +56,11 @@ local keymaps = { { "gr", "lua vim.lsp.buf.references()" }, { "gi", "lua vim.lsp.buf.implementation()" }, { "gl", "lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })" }, + { "gs", "lua vim.lsp.buf.signature_help()" }, { "gp", "lua require'lsp.peek'.Peek('definition')" }, { "K", "lua vim.lsp.buf.hover()" }, { "", "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" }, { "", "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" }, - -- { "", "lua vim.lsp.buf.signature_help()" }, }, term_mode = { -- cgit v1.2.3 From de200da87d22c0a6e6505c3618fa64a53f9bf4c1 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sat, 31 Jul 2021 19:59:52 +0430 Subject: fix eslint_d issue (#1189) --- lua/lsp/null-ls.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 468d12a6..2098ea9e 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -27,10 +27,6 @@ local function is_nodejs_provider(provider) end local function is_provider_found(provider) - -- special case: fallback to "eslint" - -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint - provider._opts.command = provider._opts.command == "eslint_d" and "eslint" or provider._opts.command - local retval = { is_local = false, path = nil } if vim.fn.executable(provider._opts.command) == 1 then return false, provider._opts.command @@ -76,6 +72,11 @@ function M.setup(filetype) -- builtin_diagnoser._opts.args = linter.args or builtin_diagnoser._opts.args -- builtin_diagnoser._opts.to_stdin = linter.stdin or builtin_diagnoser._opts.to_stdin table.insert(M.requested_providers, builtin_diagnoser) + -- special case: fallback to "eslint" + -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint + if linter.exe == "eslint_d" then + table.insert(M.requested_providers, null_ls.builtins.diagnostics.eslint.with { command = "eslint_d" }) + end u.lvim_log(string.format("Using linter provider: [%s]", linter.exe)) end -- cgit v1.2.3 From d700a706b1c524197c3638d8d084b907db2cd623 Mon Sep 17 00:00:00 2001 From: rebuilt Date: Sat, 31 Jul 2021 17:32:02 +0200 Subject: Wraps the logic in parenthesis so it works correctly (#1190) --- lua/keymappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 3a509c69..937a5e8b 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -99,7 +99,7 @@ if vim.fn.has "mac" == 1 then keymaps.normal_mode[8][1] = "" end -vim.g.mapleader = lvim.leader == "space" and " " or lvim.leader +vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader -- navigate tab completion with and -- runs conditionally -- cgit v1.2.3 From c4bff33745eb765ba49b170db2776284f5d015ef Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sat, 31 Jul 2021 20:12:12 +0430 Subject: show the actual command (#1191) --- lua/lsp/null-ls.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 2098ea9e..fde6c5bd 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -10,7 +10,7 @@ function M.get_registered_providers_by_filetype(ft) local matches = {} for _, provider in pairs(M.requested_providers) do if vim.tbl_contains(provider.filetypes, ft) then - table.insert(matches, provider.name) + table.insert(matches, provider._opts.command) end end -- cgit v1.2.3 From 2badb25f361ddeae32fcd482384cccdab96f8e68 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sat, 31 Jul 2021 20:26:25 +0430 Subject: why is eslint_d so bad (#1192) --- lua/lsp/null-ls.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index fde6c5bd..1d9f1ec1 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -10,7 +10,13 @@ function M.get_registered_providers_by_filetype(ft) local matches = {} for _, provider in pairs(M.requested_providers) do if vim.tbl_contains(provider.filetypes, ft) then - table.insert(matches, provider._opts.command) + local provider_name = provider.name + -- special case: show "eslint_d" instead of eslint + -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint + if string.find(provider._opts.command, "eslint_d") then + provider_name = "eslint_d" + end + table.insert(matches, provider_name) end end @@ -19,7 +25,7 @@ end local function is_nodejs_provider(provider) for _, local_provider in ipairs(nodejs_local_providers) do - if local_provider == provider.exe then + if local_provider == provider._opts.command then return true end end @@ -46,7 +52,7 @@ end local function validate_provider(provider) local is_local, provider_path = is_provider_found(provider) if not provider_path then - u.lvim_log(string.format("Unable to find the path for: [%s]", provider)) + u.lvim_log(string.format("Unable to find the path for: [%s]", vim.inspect(provider))) return false end if is_local then -- cgit v1.2.3 From 213e3961fa637e4dbe4ef1ea5fceadcb372e020e Mon Sep 17 00:00:00 2001 From: chaeing Date: Sat, 31 Jul 2021 11:28:59 -0700 Subject: [Feature] Rename lv-config.lua to config.lua (#1193) * Rename example config files * Update user config path in installer * Update user config path with a variable * Update default user config file to config.lua * Add fallback to lv-config if config.lua not found * Add global variable USER_CONFIG_PATH --- lua/core/autocmds.lua | 2 +- lua/core/dashboard.lua | 3 +-- lua/core/terminal.lua | 2 +- lua/default-config.lua | 2 +- lua/utils/init.lua | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) (limited to 'lua') diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index 89590454..1bc49d37 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -27,7 +27,7 @@ lvim.autocommands = { "*", "setlocal formatoptions-=c formatoptions-=r formatoptions-=o", }, - { "BufWritePost", "lv-config.lua", "lua require('utils').reload_lv_config()" }, + { "BufWritePost", USER_CONFIG_PATH, "lua require('utils').reload_lv_config()" }, { "FileType", "qf", diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index 8d196458..2f14b9f1 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -43,8 +43,7 @@ M.config = function() }, d = { description = { " Settings " }, - -- command = ":e " .. CONFIG_PATH .. "/lv-config.lua", - command = ":e ~/.config/lvim/lv-config.lua", + command = ":e " .. USER_CONFIG_PATH, }, }, diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index 015341df..bd7815aa 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -32,7 +32,7 @@ M.config = function() background = "Normal", }, }, - -- Add executables on the lv-config file + -- Add executables on the config.lua -- { exec, keymap, name} -- lvim.builtin.terminal.execs = {{}} to overwrite -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} diff --git a/lua/default-config.lua b/lua/default-config.lua index 6527ad77..d6063671 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -88,7 +88,7 @@ lvim = { }, plugins = { - -- use lv-config.lua for this not put here + -- use config.lua for this not put here }, autocommands = {}, diff --git a/lua/utils/init.lua b/lua/utils/init.lua index a404254b..b81ff4f4 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -81,7 +81,7 @@ end function utils.reload_lv_config() vim.cmd "source ~/.local/share/lunarvim/lvim/lua/settings.lua" - vim.cmd "source ~/.config/lvim/lv-config.lua" + vim.cmd("source " .. USER_CONFIG_PATH) vim.cmd "source ~/.local/share/lunarvim/lvim/lua/plugins.lua" local plugins = require "plugins" local plugin_loader = require("plugin-loader").init() -- cgit v1.2.3 From d7595fbb6a1eeef1edb56589cc376ba17ce175b9 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 31 Jul 2021 15:22:15 -0400 Subject: tab complete is more consistent --- lua/core/compe.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lua') diff --git a/lua/core/compe.lua b/lua/core/compe.lua index 801e2dd8..82d27717 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -58,6 +58,12 @@ M.setup = function() end end + local remap = vim.api.nvim_set_keymap + + remap("i", "", 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true }) + + remap("i", "", 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true }) + -- Use (s-)tab to: --- move to prev/next item in completion menuone --- jump to prev/next snippet's placeholder @@ -101,11 +107,11 @@ end M.set_tab_keybindings = function() local file_type = vim.fn.expand "%:e" - if is_excluded(file_type) == false then - vim.api.nvim_buf_set_keymap(0, "i", "", "v:lua.tab_complete()", { expr = true }) - vim.api.nvim_buf_set_keymap(0, "s", "", "v:lua.tab_complete()", { expr = true }) - vim.api.nvim_buf_set_keymap(0, "i", "", "v:lua.s_tab_complete()", { expr = true }) - vim.api.nvim_buf_set_keymap(0, "s", "", "v:lua.s_tab_complete()", { expr = true }) - end + -- if is_excluded(file_type) == false then + -- vim.api.nvim_buf_set_keymap(0, "i", "", "v:lua.tab_complete()", { expr = true }) + -- vim.api.nvim_buf_set_keymap(0, "s", "", "v:lua.tab_complete()", { expr = true }) + -- vim.api.nvim_buf_set_keymap(0, "i", "", "v:lua.s_tab_complete()", { expr = true }) + -- vim.api.nvim_buf_set_keymap(0, "s", "", "v:lua.s_tab_complete()", { expr = true }) + -- end end return M -- cgit v1.2.3 From db9adf2fb880a012bb3b8aac3c53eb75f204a050 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 31 Jul 2021 15:47:08 -0400 Subject: borders on docs --- lua/core/compe.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/compe.lua b/lua/core/compe.lua index 82d27717..dc83ff09 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -12,7 +12,11 @@ M.config = function() max_abbr_width = 100, max_kind_width = 100, max_menu_width = 100, - documentation = true, + documentation = { + border = "single", + winhighlight = "NormalFloat:CompeDocumentation,FloatBorder:CompeDocumentationBorder", + }, + -- documentation = true, source = { path = { kind = "  (Path)" }, -- cgit v1.2.3 From 2b09dbf0984e836255a294d746159a68bdeb9be8 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 31 Jul 2021 15:53:00 -0400 Subject: cleanup old tab filetype specific code --- lua/core/autocmds.lua | 3 --- lua/core/compe.lua | 20 -------------------- 2 files changed, 23 deletions(-) (limited to 'lua') diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index 1bc49d37..d9884073 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -55,9 +55,6 @@ lvim.autocommands = { { "FileType", "markdown", "setlocal wrap" }, { "FileType", "markdown", "setlocal spell" }, }, - _tab_bindings = { - { "FileType", "*", "lua require'core.compe'.set_tab_keybindings()" }, - }, _buffer_bindings = { { "FileType", "floaterm", "nnoremap q :q" }, }, diff --git a/lua/core/compe.lua b/lua/core/compe.lua index dc83ff09..08d8b8bd 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -34,8 +34,6 @@ M.config = function() emoji = { kind = " ﲃ (Emoji)", filetypes = { "markdown", "text" } }, -- for emoji press : (idk if that in compe tho) }, - -- FileTypes in this list won't trigger auto-complete when TAB is pressed. Hitting TAB will insert a tab character - exclude_filetypes = { "md", "markdown", "mdown", "mkd", "mkdn", "mdwn", "text", "txt" }, } end @@ -100,22 +98,4 @@ M.setup = function() vim.api.nvim_set_keymap("i", "", "compe#scroll({ 'delta': -4 })", { noremap = true, silent = true, expr = true }) end -local is_excluded = function(file_type) - for _, type in ipairs(lvim.builtin.compe.exclude_filetypes) do - if type == file_type then - return true - end - end - return false -end - -M.set_tab_keybindings = function() - local file_type = vim.fn.expand "%:e" - -- if is_excluded(file_type) == false then - -- vim.api.nvim_buf_set_keymap(0, "i", "", "v:lua.tab_complete()", { expr = true }) - -- vim.api.nvim_buf_set_keymap(0, "s", "", "v:lua.tab_complete()", { expr = true }) - -- vim.api.nvim_buf_set_keymap(0, "i", "", "v:lua.s_tab_complete()", { expr = true }) - -- vim.api.nvim_buf_set_keymap(0, "s", "", "v:lua.s_tab_complete()", { expr = true }) - -- end -end return M -- cgit v1.2.3 From 915603ed074bf5fe784b95508ad80a81eee24028 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Sat, 31 Jul 2021 18:36:51 -0400 Subject: udpate colorscheme --- lua/spacegray/Git.lua | 14 ++-- lua/spacegray/LSP.lua | 185 +++++++++++++++++++++-------------------- lua/spacegray/Treesitter.lua | 106 ++++++++++++------------ lua/spacegray/Whichkey.lua | 12 +-- lua/spacegray/config.lua | 26 +++--- lua/spacegray/highlights.lua | 192 +++++++++++++++++++++---------------------- lua/spacegray/init.lua | 52 +++++++----- lua/spacegray/markdown.lua | 48 +++++------ lua/spacegray/palette.lua | 67 ++++++++------- lua/spacegray/util.lua | 27 +++--- 10 files changed, 377 insertions(+), 352 deletions(-) (limited to 'lua') diff --git a/lua/spacegray/Git.lua b/lua/spacegray/Git.lua index b47ccf23..f1a2ed39 100644 --- a/lua/spacegray/Git.lua +++ b/lua/spacegray/Git.lua @@ -1,10 +1,10 @@ local Git = { - SignAdd = { fg = C.sign_add }, - SignChange = { fg = C.sign_change }, - SignDelete = { fg = C.sign_delete }, - GitSignsAdd = { fg = C.sign_add }, - GitSignsChange = { fg = C.sign_change }, - GitSignsDelete = { fg = C.sign_delete }, + SignAdd = {fg = C.sign_add, }, + SignChange = {fg = C.sign_change, }, + SignDelete = {fg = C.sign_delete, }, + GitSignsAdd = {fg = C.sign_add, }, + GitSignsChange = {fg = C.sign_change, }, + GitSignsDelete = {fg = C.sign_delete, }, } -return Git +return Git \ No newline at end of file diff --git a/lua/spacegray/LSP.lua b/lua/spacegray/LSP.lua index 2dfa07ff..5e6ac1c9 100644 --- a/lua/spacegray/LSP.lua +++ b/lua/spacegray/LSP.lua @@ -1,92 +1,99 @@ local LSP = { - LspDiagnosticsDefaultError = { fg = C.error_red }, - LspDiagnosticsDefaultWarning = { fg = C.warning_orange }, - LspDiagnosticsDefaultInformation = { fg = C.info_yellow }, - LspDiagnosticsDefaultHint = { fg = C.hint_blue }, - LspDiagnosticsVirtualTextError = { fg = C.error_red }, - LspDiagnosticsVirtualTextWarning = { fg = C.warning_orange }, - LspDiagnosticsVirtualTextInformation = { fg = C.info_yellow }, - LspDiagnosticsVirtualTextHint = { fg = C.hint_blue }, - LspDiagnosticsFloatingError = { fg = C.error_red }, - LspDiagnosticsFloatingWarning = { fg = C.warning_orange }, - LspDiagnosticsFloatingInformation = { fg = C.info_yellow }, - LspDiagnosticsFloatingHint = { fg = C.hint_blue }, - LspDiagnosticsSignError = { fg = C.error_red }, - LspDiagnosticsSignWarning = { fg = C.warning_orange }, - LspDiagnosticsSignInformation = { fg = C.info_yellow }, - LspDiagnosticsSignHint = { fg = C.hint_blue }, - LspDiagnosticsError = { fg = C.error_red }, - LspDiagnosticsWarning = { fg = C.warning_orange }, - LspDiagnosticsInformation = { fg = C.info_yellow }, - LspDiagnosticsHint = { fg = C.hint_blue }, - LspDiagnosticsUnderlineError = { fg = C.error_red }, - LspDiagnosticsUnderlineWarning = { fg = C.warning_orange }, - LspDiagnosticsUnderlineInformation = { fg = C.info_yellow }, - LspDiagnosticsUnderlineHint = { fg = C.hint_blue }, - QuickScopePrimary = { fg = C.cyan_test, style = "underline" }, - QuickScopeSecondary = { fg = C.purple_test, style = "underline" }, - TelescopeSelection = { fg = C.hint_blue }, - TelescopeMatching = { fg = C.info_yellow, style = "bold" }, - TelescopeBorder = { fg = C.cyan, bg = C.bg }, - NvimTreeFolderIcon = { fg = C.blue }, - NvimTreeIndentMarker = { fg = C.gray }, - NvimTreeNormal = { fg = C.light_gray, bg = C.alt_bg }, - NvimTreeVertSplit = { fg = C.alt_bg, bg = C.alt_bg }, - NvimTreeFolderName = { fg = C.blue }, - NvimTreeOpenedFolderName = { fg = C.cyan, style = "italic" }, - NvimTreeImageFile = { fg = C.purple }, - NvimTreeSpecialFile = { fg = C.orange }, - NvimTreeGitStaged = { fg = C.sign_add }, - NvimTreeGitNew = { fg = C.sign_add }, - NvimTreeGitDirty = { fg = C.sign_add }, - NvimTreeGitDeleted = { fg = C.sign_delete }, - NvimTreeGitMerge = { fg = C.sign_change }, - NvimTreeGitRenamed = { fg = C.sign_change }, - NvimTreeSymlink = { fg = C.cyan }, - NvimTreeRootFolder = { fg = C.fg, style = "bold" }, - NvimTreeExecFile = { fg = C.green }, - BufferCurrent = { fg = C.fg, bg = C.bg }, - BufferCurrentIndex = { fg = C.fg, bg = C.bg }, - BufferCurrentMod = { fg = C.info_yellow, bg = C.bg }, - BufferCurrentSign = { fg = C.hint_blue, bg = C.bg }, - BufferCurrentTarget = { fg = C.red, bg = C.bg, style = "bold" }, - BufferVisible = { fg = C.fg, bg = C.bg }, - BufferVisibleIndex = { fg = C.fg, bg = C.bg }, - BufferVisibleMod = { fg = C.info_yellow, bg = C.bg }, - BufferVisibleSign = { fg = C.hint_blue, bg = C.bg }, - BufferVisibleTarget = { fg = C.red, bg = C.bg, style = "bold" }, - BufferInactive = { fg = C.gray, bg = C.alt_bg }, - BufferInactiveIndex = { fg = C.gray, bg = C.alt_bg }, - BufferInactiveMod = { fg = C.info_yellow, bg = C.alt_bg }, - BufferInactiveSign = { fg = C.gray, bg = C.alt_bg }, - BufferInactiveTarget = { fg = C.red, bg = C.alt_bg, style = "bold" }, - StatusLine = { fg = C.alt_bg }, - StatusLineNC = { fg = C.alt_bg }, - StatusLineSeparator = { fg = C.alt_bg }, - StatusLineTerm = { fg = C.alt_bg }, - StatusLineTermNC = { fg = C.alt_bg }, - CodiVirtualText = { fg = C.pale_purple }, - IndentBlanklineContextChar = { fg = C.accent }, - DashboardHeader = { fg = C.blue }, - DashboardCenter = { fg = C.purple }, - DashboardFooter = { fg = C.cyan }, - CompeDocumentation = { bg = C.alt_bg }, - DiffViewNormal = { fg = C.gray, bg = C.alt_bg }, - DiffviewStatusAdded = { fg = C.sign_add }, - DiffviewStatusModified = { fg = C.sign_change }, - DiffviewStatusRenamed = { fg = C.sign_change }, - DiffviewStatusDeleted = { fg = C.sign_delete }, - DiffviewFilePanelInsertion = { fg = C.sign_add }, - DiffviewFilePanelDeletion = { fg = C.sign_delete }, - DiffviewVertSplit = { bg = C.bg }, - diffAdded = { fg = C.sign_add }, - diffRemoved = { fg = C.sign_delete }, - diffFileId = { fg = C.blue, style = "bold,reverse" }, - diffFile = { fg = C.alt_bg }, - diffNewFile = { fg = C.green }, - diffOldFile = { fg = C.red }, - debugPc = { bg = C.cyan }, - debugBreakpoint = { fg = C.red, style = "reverse" }, + LspDiagnosticsDefaultError = {fg = C.error_red, }, + LspDiagnosticsDefaultWarning = {fg = C.warning_orange, }, + LspDiagnosticsDefaultInformation = {fg = C.info_yellow, }, + LspDiagnosticsDefaultHint = {fg = C.hint_blue, }, + LspDiagnosticsVirtualTextError = {fg = C.error_red, }, + LspDiagnosticsVirtualTextWarning = {fg = C.warning_orange, }, + LspDiagnosticsVirtualTextInformation = {fg = C.info_yellow, }, + LspDiagnosticsVirtualTextHint = {fg = C.hint_blue, }, + LspDiagnosticsFloatingError = {fg = C.error_red, }, + LspDiagnosticsFloatingWarning = {fg = C.warning_orange, }, + LspDiagnosticsFloatingInformation = {fg = C.info_yellow, }, + LspDiagnosticsFloatingHint = {fg = C.hint_blue, }, + LspDiagnosticsSignError = {fg = C.error_red, }, + LspDiagnosticsSignWarning = {fg = C.warning_orange, }, + LspDiagnosticsSignInformation = {fg = C.info_yellow, }, + LspDiagnosticsSignHint = {fg = C.hint_blue, }, + LspDiagnosticsError = {fg = C.error_red, }, + LspDiagnosticsWarning = {fg = C.warning_orange, }, + LspDiagnosticsInformation = {fg = C.info_yellow, }, + LspDiagnosticsHint = {fg = C.hint_blue, }, + LspDiagnosticsUnderlineError = {style = "underline", }, + LspDiagnosticsUnderlineWarning = {style = "underline", }, + LspDiagnosticsUnderlineInformation = {style = "underline", }, + LspDiagnosticsUnderlineHint = {style = "underline", }, + QuickScopePrimary = {fg = C.purple_test, style = "underline", }, + QuickScopeSecondary = {fg = C.cyan_test, style = "underline", }, + TelescopeSelection = {fg = C.hint_blue, }, + TelescopeMatching = {fg = C.info_yellow, style = "bold", }, + TelescopeBorder = {fg = C.cyan, bg = Config.transparent_background and "NONE" or C.bg, }, + NvimTreeFolderIcon = {fg = C.blue, }, + NvimTreeIndentMarker = {fg = C.gray, }, + NvimTreeNormal = {fg = C.light_gray, bg = C.alt_bg, }, + NvimTreeVertSplit = {fg = C.alt_bg, bg = C.alt_bg, }, + NvimTreeFolderName = {fg = C.blue, }, + NvimTreeOpenedFolderName = {fg = C.cyan, style = "italic", }, + NvimTreeImageFile = {fg = C.purple, }, + NvimTreeSpecialFile = {fg = C.orange, }, + NvimTreeGitStaged = {fg = C.sign_add, }, + NvimTreeGitNew = {fg = C.sign_add, }, + NvimTreeGitDirty = {fg = C.sign_add, }, + NvimTreeGitDeleted = {fg = C.sign_delete, }, + NvimTreeGitMerge = {fg = C.sign_change, }, + NvimTreeGitRenamed = {fg = C.sign_change, }, + NvimTreeSymlink = {fg = C.cyan, }, + NvimTreeRootFolder = {fg = C.fg, style = "bold", }, + NvimTreeExecFile = {fg = C.green, }, + LirFloatNormal = {fg = C.light_gray, bg = C.alt_bg, }, + LirDir = {fg = C.blue, }, + LirSymLink = {fg = C.cyan, }, + LirEmptyDirText = {fg = C.blue, }, + BufferCurrent = {fg = C.fg, bg = C.bg, }, + BufferCurrentIndex = {fg = C.fg, bg = C.bg, }, + BufferCurrentMod = {fg = C.info_yellow, bg = C.bg, }, + BufferCurrentSign = {fg = C.hint_blue, bg = C.bg, }, + BufferCurrentTarget = {fg = C.red, bg = C.bg, style = "bold", }, + BufferVisible = {fg = C.fg, bg = C.bg, }, + BufferVisibleIndex = {fg = C.fg, bg = C.bg, }, + BufferVisibleMod = {fg = C.info_yellow, bg = C.bg, }, + BufferVisibleSign = {fg = C.gray, bg = C.bg, }, + BufferVisibleTarget = {fg = C.red, bg = C.bg, style = "bold", }, + BufferInactive = {fg = C.gray, bg = C.alt_bg, }, + BufferInactiveIndex = {fg = C.gray, bg = C.alt_bg, }, + BufferInactiveMod = {fg = C.info_yellow, bg = C.alt_bg, }, + BufferInactiveSign = {fg = C.gray, bg = C.alt_bg, }, + BufferInactiveTarget = {fg = C.red, bg = C.alt_bg, style = "bold", }, + StatusLine = {fg = C.alt_bg, }, + StatusLineNC = {fg = C.alt_bg, }, + StatusLineSeparator = {fg = C.alt_bg, }, + StatusLineTerm = {fg = C.alt_bg, }, + StatusLineTermNC = {fg = C.alt_bg, }, + CodiVirtualText = {fg = C.hint_blue, }, + IndentBlanklineContextChar = {fg = C.accent, }, + DashboardHeader = {fg = C.blue, }, + DashboardCenter = {fg = C.purple, }, + DashboardFooter = {fg = C.cyan, }, + xmlTag = {fg = C.cyan, }, + xmlTagName = {fg = C.cyan, }, + xmlEndTag = {fg = C.cyan, }, + CompeDocumentation = {bg = C.alt_bg, }, + DiffViewNormal = {fg = C.gray, bg = C.alt_bg, }, + DiffviewStatusAdded = {fg = C.sign_add, }, + DiffviewStatusModified = {fg = C.sign_change, }, + DiffviewStatusRenamed = {fg = C.sign_change, }, + DiffviewStatusDeleted = {fg = C.sign_delete, }, + DiffviewFilePanelInsertion = {fg = C.sign_add, }, + DiffviewFilePanelDeletion = {fg = C.sign_delete, }, + DiffviewVertSplit = {bg = C.bg, }, + diffAdded = {fg = C.sign_add, }, + diffRemoved = {fg = C.sign_delete, }, + diffFileId = {fg = C.blue, style = "bold,reverse", }, + diffFile = {fg = C.alt_bg, }, + diffNewFile = {fg = C.green, }, + diffOldFile = {fg = C.red, }, + debugPc = {bg = C.cyan, }, + debugBreakpoint = {fg = C.red, style = "reverse", }, } -return LSP +return LSP \ No newline at end of file diff --git a/lua/spacegray/Treesitter.lua b/lua/spacegray/Treesitter.lua index 01dfacb5..e680669a 100644 --- a/lua/spacegray/Treesitter.lua +++ b/lua/spacegray/Treesitter.lua @@ -1,56 +1,56 @@ local Treesitter = { - TSComment = { fg = C.gray }, - TSAnnotation = { fg = C.purple }, - TSAttribute = { fg = C.cyan }, - TSConstructor = { fg = C.purple }, - TSType = { fg = C.purple }, - TSTypeBuiltin = { fg = C.purple }, - TSConditional = { fg = C.blue }, - TSException = { fg = C.blue }, - TSInclude = { fg = C.blue }, - TSKeyword = { fg = C.blue }, - TSKeywordFunction = { fg = C.blue }, - TSLabel = { fg = C.blue }, - TSNamespace = { fg = C.blue }, - TSRepeat = { fg = C.blue }, - TSConstant = { fg = C.orange }, - TSConstBuiltin = { fg = C.orange }, - TSFloat = { fg = C.red }, - TSNumber = { fg = C.red }, - TSBoolean = { fg = C.red }, - TSCharacter = { fg = C.light_green }, - TSError = { fg = C.error_red }, - TSFunction = { fg = C.yellow }, - TSFuncBuiltin = { fg = C.yellow }, - TSMethod = { fg = C.yellow }, - TSConstMacro = { fg = C.cyan }, - TSFuncMacro = { fg = C.cyan }, - TSVariable = { fg = C.white }, - TSVariableBuiltin = { fg = C.cyan }, - TSProperty = { fg = C.cyan }, - TSOperator = { fg = C.gray_blue }, - TSField = { fg = C.white }, - TSParameter = { fg = C.white }, - TSParameterReference = { fg = C.white }, - TSSymbol = { fg = C.white }, - TSText = { fg = C.fg }, - TSPunctDelimiter = { fg = C.gray }, - TSTagDelimiter = { fg = C.gray }, - TSPunctBracket = { fg = C.gray }, - TSPunctSpecial = { fg = C.gray }, - TSString = { fg = C.green }, - TSStringRegex = { fg = C.light_green }, - TSStringEscape = { fg = C.light_green }, - TSTag = { fg = C.blue }, - TSEmphasis = { style = "italic" }, - TSUnderline = { style = "underline" }, - TSTitle = { fg = C.blue, style = "bold" }, - TSLiteral = { fg = C.green }, - TSURI = { fg = C.cyan, style = "underline" }, - TSKeywordOperator = { fg = C.blue }, - TSStructure = { fg = C.purple_test }, - TSStrong = { fg = C.yellow }, - TSQueryLinterError = { fg = C.warning_orange }, + TSComment = {fg = C.gray, }, + TSAnnotation = {fg = C.purple, }, + TSAttribute = {fg = C.cyan, }, + TSConstructor = {fg = C.purple, }, + TSType = {fg = C.purple, }, + TSTypeBuiltin = {fg = C.purple, }, + TSConditional = {fg = C.blue, }, + TSException = {fg = C.blue, }, + TSInclude = {fg = C.blue, }, + TSKeyword = {fg = C.blue, }, + TSKeywordFunction = {fg = C.blue, }, + TSLabel = {fg = C.blue, }, + TSNamespace = {fg = C.blue, }, + TSRepeat = {fg = C.blue, }, + TSConstant = {fg = C.orange, }, + TSConstBuiltin = {fg = C.red, }, + TSFloat = {fg = C.red, }, + TSNumber = {fg = C.red, }, + TSBoolean = {fg = C.red, }, + TSCharacter = {fg = C.light_green, }, + TSError = {fg = C.error_red, }, + TSFunction = {fg = C.yellow, }, + TSFuncBuiltin = {fg = C.yellow, }, + TSMethod = {fg = C.yellow, }, + TSConstMacro = {fg = C.cyan, }, + TSFuncMacro = {fg = C.yellow, }, + TSVariable = {fg = C.light_blue, }, + TSVariableBuiltin = {fg = C.light_blue, }, + TSProperty = {fg = C.light_blue, }, + TSOperator = {fg = C.gray, }, + TSField = {fg = C.light_blue, }, + TSParameter = {fg = C.light_blue, }, + TSParameterReference = {fg = C.light_blue, }, + TSSymbol = {fg = C.light_blue, }, + TSText = {fg = C.fg, }, + TSPunctDelimiter = {fg = C.gray, }, + TSTagDelimiter = {fg = C.gray, }, + TSPunctBracket = {fg = C.gray, }, + TSPunctSpecial = {fg = C.gray, }, + TSString = {fg = C.green, }, + TSStringRegex = {fg = C.yellow_orange, }, + TSStringEscape = {fg = C.yellow_orange, }, + TSTag = {fg = C.blue, }, + TSEmphasis = {style = "italic", }, + TSUnderline = {style = "underline", }, + TSTitle = {fg = C.blue, style = "bold", }, + TSLiteral = {fg = C.yellow_orange, }, + TSURI = {fg = C.yellow_orange, style = "underline", }, + TSKeywordOperator = {fg = C.blue, }, + TSStructure = {fg = C.light_blue, }, + TSStrong = {fg = C.yellow_orange, }, + TSQueryLinterError = {fg = C.warning_orange, }, } -return Treesitter +return Treesitter \ No newline at end of file diff --git a/lua/spacegray/Whichkey.lua b/lua/spacegray/Whichkey.lua index f382d784..7b2a11a0 100644 --- a/lua/spacegray/Whichkey.lua +++ b/lua/spacegray/Whichkey.lua @@ -1,9 +1,9 @@ local Whichkey = { - WhichKey = { fg = C.purple }, - WhichKeySeperator = { fg = C.green }, - WhichKeyGroup = { fg = C.blue }, - WhichKeyDesc = { fg = C.cyan }, - WhichKeyFloat = { bg = C.alt_bg }, + WhichKey = {fg = C.purple, }, + WhichKeySeperator = {fg = C.green, }, + WhichKeyGroup = {fg = C.blue, }, + WhichKeyDesc = {fg = C.light_blue, }, + WhichKeyFloat = {bg = C.dark, }, } -return Whichkey +return Whichkey \ No newline at end of file diff --git a/lua/spacegray/config.lua b/lua/spacegray/config.lua index ebac7109..f9c10951 100644 --- a/lua/spacegray/config.lua +++ b/lua/spacegray/config.lua @@ -3,21 +3,21 @@ local config vim = vim or { g = {}, o = {} } local function opt(key, default) - if vim.g[key] == nil then - return default - end - if vim.g[key] == 0 then - return false - end - return vim.g[key] + if vim.g[key] == nil then + return default + end + if vim.g[key] == 0 then + return false + end + return vim.g[key] end config = { - transparent_background = opt("transparent_background", false), - italic_comments = opt("italic_keywords", true) and "italic" or "NONE", - italic_keywords = opt("italic_keywords", true) and "italic" or "NONE", - italic_functions = opt("italic_function", false) and "italic" or "NONE", - italic_variables = opt("italic_variables", true) and "italic" or "NONE", + transparent_background = opt("transparent_background", false), + italic_comments = opt("italic_keywords", true) and "italic" or "NONE", + italic_keywords = opt("italic_keywords", true) and "italic" or "NONE", + italic_functions = opt("italic_function", false) and "italic" or "NONE", + italic_variables = opt("italic_variables", true) and "italic" or "NONE", } -return config +return config \ No newline at end of file diff --git a/lua/spacegray/highlights.lua b/lua/spacegray/highlights.lua index e8700d8f..06e34be0 100644 --- a/lua/spacegray/highlights.lua +++ b/lua/spacegray/highlights.lua @@ -1,99 +1,99 @@ local highlights = { - Normal = { fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg }, - SignColumn = { bg = C.bg }, - MsgArea = { fg = C.fg, bg = C.bg }, - ModeMsg = { fg = C.fg, bg = C.bg }, - MsgSeparator = { fg = C.fg, bg = C.bg }, - SpellBad = { fg = C.error_red, style = "underline" }, - SpellCap = { fg = C.yellow, style = "underline" }, - SpellLocal = { fg = C.green, style = "underline" }, - SpellRare = { fg = C.purple, style = "underline" }, - NormalNC = { fg = C.fg, bg = C.bg }, - Pmenu = { fg = C.white, bg = C.accent }, - PmenuSel = { fg = C.alt_bg, bg = C.blue }, - WildMenu = { fg = C.alt_bg, bg = C.blue }, - CursorLineNr = { fg = C.light_gray, style = "bold" }, - Comment = { fg = C.gray, style = "italic" }, - Folded = { fg = C.accent, bg = C.alt_bg }, - FoldColumn = { fg = C.accent, bg = C.alt_bg }, - LineNr = { fg = C.gray }, - FloatBorder = { fg = C.gray, bg = C.alt_bg }, - Whitespace = { fg = C.gray }, - VertSplit = { fg = C.bg, bg = C.accent }, - CursorLine = { bg = C.alt_bg }, - CursorColumn = { bg = C.alt_bg }, - ColorColumn = { bg = C.alt_bg }, - NormalFloat = { bg = C.alt_bg }, - Visual = { bg = C.alt_bg }, - VisualNOS = { bg = C.alt_bg }, - WarningMsg = { fg = C.warning_orange, bg = C.bg }, - DiffAdd = { fg = C.alt_bg, bg = C.sign_add }, - DiffChange = { fg = C.alt_bg, bg = C.sign_change, style = "underline" }, - DiffDelete = { fg = C.alt_bg, bg = C.sign_delete }, - QuickFixLine = { bg = C.accent }, - PmenuSbar = { bg = C.alt_bg }, - PmenuThumb = { bg = C.white }, - MatchWord = { style = "underline" }, - MatchParen = { fg = C.pale_purple, bg = C.bg, style = "underline" }, - MatchWordCur = { style = "underline" }, - MatchParenCur = { style = "underline" }, - Cursor = { fg = C.cursor_fg, bg = C.cursor_bg }, - lCursor = { fg = C.cursor_fg, bg = C.cursor_bg }, - CursorIM = { fg = C.cursor_fg, bg = C.cursor_bg }, - TermCursor = { fg = C.cursor_fg, bg = C.cursor_bg }, - TermCursorNC = { fg = C.cursor_fg, bg = C.cursor_bg }, - Conceal = { fg = C.accent }, - Directory = { fg = C.blue }, - SpecialKey = { fg = C.blue, style = "bold" }, - Title = { fg = C.blue, style = "bold" }, - ErrorMsg = { fg = C.error_red, bg = C.bg, style = "bold" }, - Search = { fg = C.hint_blue, bg = C.alt_bg }, - IncSearch = { fg = C.hint_blue, bg = C.alt_bg }, - Substitute = { fg = C.alt_bg, bg = C.gray_blue }, - MoreMsg = { fg = C.cyan }, - Question = { fg = C.cyan }, - EndOfBuffer = { fg = C.bg }, - NonText = { fg = C.bg }, - Variable = { fg = C.white }, - String = { fg = C.green }, - Character = { fg = C.light_green }, - Constant = { fg = C.orange }, - Number = { fg = C.red }, - Boolean = { fg = C.red }, - Float = { fg = C.red }, - Identifier = { fg = C.white }, - Function = { fg = C.yellow }, - Operator = { fg = C.gray_blue }, - Type = { fg = C.purple }, - StorageClass = { fg = C.purple }, - Structure = { fg = C.purple }, - Typedef = { fg = C.purple }, - Keyword = { fg = C.blue }, - Statement = { fg = C.blue }, - Conditional = { fg = C.blue }, - Repeat = { fg = C.blue }, - Label = { fg = C.blue }, - Exception = { fg = C.blue }, - Include = { fg = C.blue }, - PreProc = { fg = C.cyan }, - Define = { fg = C.cyan }, - Macro = { fg = C.cyan }, - PreCondit = { fg = C.cyan }, - Special = { fg = C.orange }, - SpecialChar = { fg = C.orange }, - Tag = { fg = C.blue }, - Debug = { fg = C.red }, - Delimiter = { fg = C.gray }, - SpecialComment = { fg = C.gray }, - Underlined = { style = "underline" }, - Bold = { style = "bold" }, - Italic = { style = "italic" }, - Ignore = { fg = C.cyan, bg = C.bg, style = "bold" }, - Todo = { fg = C.red, bg = C.bg, style = "bold" }, - Error = { fg = C.error_red, bg = C.bg, style = "bold" }, - TabLine = { fg = C.white, bg = C.alt_bg }, - TabLineSel = { fg = C.white, bg = C.alt_bg }, - TabLineFill = { fg = C.white, bg = C.alt_bg }, + Normal = {fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg, }, + SignColumn = {bg = C.bg, }, + MsgArea = {fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg, }, + ModeMsg = {fg = C.fg, bg = C.bg, }, + MsgSeparator = {fg = C.fg, bg = C.bg, }, + SpellBad = {fg = C.error_red, style = "underline", }, + SpellCap = {fg = C.yellow, style = "underline", }, + SpellLocal = {fg = C.green, style = "underline", }, + SpellRare = {fg = C.purple, style = "underline", }, + NormalNC = {fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg, }, + Pmenu = {fg = C.light_gray, bg = C.popup_back, }, + PmenuSel = {fg = C.alt_bg, bg = C.blue, }, + WildMenu = {fg = C.alt_bg, bg = C.blue, }, + CursorLineNr = {fg = C.light_gray, style = "bold", }, + Comment = {fg = C.gray, style = "italic", }, + Folded = {fg = C.accent, bg = C.alt_bg, }, + FoldColumn = {fg = C.accent, bg = C.alt_bg, }, + LineNr = {fg = C.gray, }, + FloatBoder = {fg = C.gray, bg = C.alt_bg, }, + Whitespace = {fg = C.bg, }, + VertSplit = {fg = C.bg, bg = C.fg, }, + CursorLine = {bg = C.dark, }, + CursorColumn = {bg = C.dark, }, + ColorColumn = {bg = C.dark, }, + NormalFloat = {bg = C.dark, }, + Visual = {bg = C.ui_blue, }, + VisualNOS = {bg = C.alt_bg, }, + WarningMsg = {fg = C.error_red, bg = C.bg, }, + DiffAdd = {fg = C.alt_bg, bg = C.sign_add, }, + DiffChange = {fg = C.alt_bg, bg = C.sign_change, style = "underline", }, + DiffDelete = {fg = C.alt_bg, bg = C.sign_delete, }, + QuickFixLine = {bg = C.accent, }, + PmenuSbar = {bg = C.alt_bg, }, + PmenuThumb = {bg = C.gray, }, + MatchWord = {style = "underline", }, + MatchParen = {fg = C.hint_blue, bg = C.bg, style = "underline", }, + MatchWordCur = {style = "underline", }, + MatchParenCur = {style = "underline", }, + Cursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, + lCursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, + CursorIM = {fg = C.cursor_fg, bg = C.cursor_bg, }, + TermCursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, + TermCursorNC = {fg = C.cursor_fg, bg = C.cursor_bg, }, + Conceal = {fg = C.accent, }, + Directory = {fg = C.blue, }, + SpecialKey = {fg = C.blue, style = "bold", }, + Title = {fg = C.blue, style = "bold", }, + ErrorMsg = {fg = C.error_red, bg = C.bg, style = "bold", }, + Search = {fg = C.light_gray, bg = C.search_blue, }, + IncSearch = {fg = C.light_gray, bg = C.search_blue, }, + Substitute = {fg = C.light_gray, bg = C.search_orange, }, + MoreMsg = {fg = C.orange, }, + Question = {fg = C.orange, }, + EndOfBuffer = {fg = C.bg, }, + NonText = {fg = C.bg, }, + Variable = {fg = C.light_blue, }, + String = {fg = C.green, }, + Character = {fg = C.light_green, }, + Constant = {fg = C.blue, }, + Number = {fg = C.red, }, + Boolean = {fg = C.red, }, + Float = {fg = C.red, }, + Identifier = {fg = C.light_blue, }, + Function = {fg = C.yellow, }, + Operator = {fg = C.gray, }, + Type = {fg = C.purple, }, + StorageClass = {fg = C.purple, }, + Structure = {fg = C.purple, }, + Typedef = {fg = C.purple, }, + Keyword = {fg = C.blue, }, + Statement = {fg = C.blue, }, + Conditional = {fg = C.blue, }, + Repeat = {fg = C.blue, }, + Label = {fg = C.blue, }, + Exception = {fg = C.blue, }, + Include = {fg = C.blue, }, + PreProc = {fg = C.purple, }, + Define = {fg = C.purple, }, + Macro = {fg = C.purple, }, + PreCondit = {fg = C.purple, }, + Special = {fg = C.orange, }, + SpecialChar = {fg = C.white, }, + Tag = {fg = C.blue, }, + Debug = {fg = C.red, }, + Delimiter = {fg = C.gray, }, + SpecialComment = {fg = C.gray, }, + Underlined = {style = "underline", }, + Bold = {style = "bold", }, + Italic = {style = "italic", }, + Ignore = {fg = C.cyan, bg = C.bg, style = "bold", }, + Todo = {fg = C.red, bg = C.bg, style = "bold", }, + Error = {fg = C.error_red, bg = C.bg, style = "bold", }, + TabLine = {fg = C.light_gray, bg = C.alt_bg, }, + TabLineSel = {fg = C.white, bg = C.alt_bg, }, + TabLineFill = {fg = C.white, bg = C.alt_bg, }, } -return highlights +return highlights \ No newline at end of file diff --git a/lua/spacegray/init.lua b/lua/spacegray/init.lua index 8da13a06..70d57bda 100644 --- a/lua/spacegray/init.lua +++ b/lua/spacegray/init.lua @@ -1,30 +1,44 @@ -vim.api.nvim_command "hi clear" -if vim.fn.exists "syntax_on" then - vim.api.nvim_command "syntax reset" +vim.api.nvim_command("hi clear") +if vim.fn.exists("syntax_on") then + vim.api.nvim_command("syntax reset") end vim.o.background = "dark" vim.o.termguicolors = true vim.g.colors_name = "spacegray" -local util = require "spacegray.util" -Config = require "spacegray.config" -C = require "spacegray.palette" -local highlights = require "spacegray.highlights" -local Treesitter = require "spacegray.Treesitter" -local markdown = require "spacegray.markdown" -local Whichkey = require "spacegray.Whichkey" -local Git = require "spacegray.Git" -local LSP = require "spacegray.LSP" +local util = require("spacegray.util") +Config = require("spacegray.config") +C = require("spacegray.palette") + +local async +async = vim.loop.new_async(vim.schedule_wrap(function () + + + local skeletons = { + + } + + for _, skeleton in ipairs(skeletons) do + util.initialise(skeleton) + end + + async:close() +end)) + +local highlights = require("spacegray.highlights") +local Treesitter = require("spacegray.Treesitter") +local markdown = require("spacegray.markdown") +local Whichkey = require("spacegray.Whichkey") +local Git = require("spacegray.Git") +local LSP = require("spacegray.LSP") + local skeletons = { - highlights, - Treesitter, - markdown, - Whichkey, - Git, - LSP, + highlights, Treesitter, markdown, Whichkey, Git, LSP } for _, skeleton in ipairs(skeletons) do - util.initialise(skeleton) + util.initialise(skeleton) end + +async:send() \ No newline at end of file diff --git a/lua/spacegray/markdown.lua b/lua/spacegray/markdown.lua index 2b83e056..19863dc8 100644 --- a/lua/spacegray/markdown.lua +++ b/lua/spacegray/markdown.lua @@ -1,27 +1,27 @@ local markdown = { - markdownBlockquote = { fg = C.accent }, - markdownBold = { fg = C.yellow, style = "bold" }, - markdownCode = { fg = C.green }, - markdownCodeBlock = { fg = C.green }, - markdownCodeDelimiter = { fg = C.green }, - markdownH1 = { fg = C.blue }, - markdownH2 = { fg = C.blue }, - markdownH3 = { fg = C.blue }, - markdownH4 = { fg = C.blue }, - markdownH5 = { fg = C.blue }, - markdownH6 = { fg = C.blue }, - markdownHeadingDelimiter = { fg = C.red }, - markdownHeadingRule = { fg = C.accent }, - markdownId = { fg = C.purple }, - markdownIdDeclaration = { fg = C.blue }, - markdownIdDelimiter = { fg = C.light_gray }, - markdownLinkDelimiter = { fg = C.light_gray }, - markdownItalic = { style = "italic" }, - markdownLinkText = { fg = C.blue }, - markdownListMarker = { fg = C.red }, - markdownOrderedListMarker = { fg = C.red }, - markdownRule = { fg = C.accent }, - markdownUrl = { fg = C.cyan, style = "underline" }, + markdownBlockquote = {fg = C.accent, }, + markdownBold = {fg = C.yellow, style = "bold", }, + markdownCode = {fg = C.green, }, + markdownCodeBlock = {fg = C.green, }, + markdownCodeDelimiter = {fg = C.green, }, + markdownH1 = {fg = C.blue, }, + markdownH2 = {fg = C.blue, }, + markdownH3 = {fg = C.blue, }, + markdownH4 = {fg = C.blue, }, + markdownH5 = {fg = C.blue, }, + markdownH6 = {fg = C.blue, }, + markdownHeadingDelimiter = {fg = C.red, }, + markdownHeadingRule = {fg = C.accent, }, + markdownId = {fg = C.purple, }, + markdownIdDeclaration = {fg = C.blue, }, + markdownIdDelimiter = {fg = C.light_gray, }, + markdownLinkDelimiter = {fg = C.light_gray, }, + markdownItalic = {style = "italic", }, + markdownLinkText = {fg = C.blue, }, + markdownListMarker = {fg = C.red, }, + markdownOrderedListMarker = {fg = C.red, }, + markdownRule = {fg = C.accent, }, + markdownUrl = {fg = C.cyan, style = "underline", }, } -return markdown +return markdown \ No newline at end of file diff --git a/lua/spacegray/palette.lua b/lua/spacegray/palette.lua index 49e429e5..df764c81 100644 --- a/lua/spacegray/palette.lua +++ b/lua/spacegray/palette.lua @@ -1,33 +1,40 @@ local colors = { - fg = "#c8c9d1", - bg = "#212121", - alt_bg = "#2a2a2a", - accent = "#383d45", - white = "#c8c9d1", - gray = "#858585", - light_gray = "#c8c9c1", - blue = "#5486c0", - gray_blue = "#66899d", - cyan = "#65a7c5", - red = "#b04b57", - green = "#87b379", - light_green = "#b2d77c", - yellow = "#eeba5a", - orange = "#c6735a", - purple = "#bf83c1", - pale_purple = "#7199ee", - magenta = "#D16D9E", - cursor_fg = "#515052", - cursor_bg = "#AEAFAD", - sign_add = "#587c0c", - sign_change = "#0c7d9d", - sign_delete = "#94151b", - error_red = "#F44747", - warning_orange = "#ff8800", - info_yellow = "#FFCC66", - hint_blue = "#4FC1FF", - purple_test = "#ff00ff", - cyan_test = "#00ffff", + fg = "#ABB2BF", + bg = "#202020", + alt_bg = "#262626", + dark = "#222222", + accent = "#AAAAAA", + popup_back = "#2D2D30", + search_orange = "#613214", + search_blue = "#5e81ac", + white = "#D8DEE9", + gray = "#9BA1AB", + light_gray = "#c8c9c1", + blue = "#5f8ccd", + dark_blue = "#223E55", + light_blue = "#8dc0d5", + green = "#73aa7b", + cyan = "#4EC9B0", + light_green = "#B5CEA8", + red = "#D16969", + orange = "#D1866B", + light_red = "#CA535F", + yellow = "#ECCC8E", + yellow_orange = "#D7BA7D", + purple = "#BF82B4", + magenta = "#D16D9E", + cursor_fg = "#515052", + cursor_bg = "#AEAFAD", + sign_add = "#587c0c", + sign_change = "#0c7d9d", + sign_delete = "#94151b", + error_red = "#F44747", + warning_orange = "#ff8800", + info_yellow = "#FFCC66", + hint_blue = "#4FC1FF", + purple_test = "#ff007c", + cyan_test = "#00dfff", + ui_blue = "#264F78", } -return colors +return colors \ No newline at end of file diff --git a/lua/spacegray/util.lua b/lua/spacegray/util.lua index dbac18a2..1cc5a009 100644 --- a/lua/spacegray/util.lua +++ b/lua/spacegray/util.lua @@ -1,25 +1,22 @@ local M = {} local function highlight(group, properties) - local bg = properties.bg == nil and "" or "guibg=" .. properties.bg - local fg = properties.fg == nil and "" or "guifg=" .. properties.fg - local style = properties.style == nil and "" or "gui=" .. properties.style + local bg = properties.bg == nil and "" or "guibg=" .. properties.bg + local fg = properties.fg == nil and "" or "guifg=" .. properties.fg + local style = properties.style == nil and "" or "gui=" .. properties.style - local cmd = table.concat({ - "highlight", - group, - bg, - fg, - style, - }, " ") + local cmd = table.concat({ + "highlight", group, bg, fg, style + }, " ") - vim.api.nvim_command(cmd) + vim.api.nvim_command(cmd) end + function M.initialise(skeleton) - for group, properties in pairs(skeleton) do - highlight(group, properties) - end + for group, properties in pairs(skeleton) do + highlight(group, properties) + end end -return M +return M \ No newline at end of file -- cgit v1.2.3 From 8ee070833e17efede8b01c81ff9d8439ec52fdb8 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Sat, 31 Jul 2021 19:45:42 -0400 Subject: fix linter present when executable not found --- lua/lsp/null-ls.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 1d9f1ec1..798c02ee 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -77,7 +77,10 @@ function M.setup(filetype) -- FIXME: why doesn't this work? -- builtin_diagnoser._opts.args = linter.args or builtin_diagnoser._opts.args -- builtin_diagnoser._opts.to_stdin = linter.stdin or builtin_diagnoser._opts.to_stdin - table.insert(M.requested_providers, builtin_diagnoser) + -- NOTE: validate before inserting to table + if validate_provider(builtin_diagnoser) then + table.insert(M.requested_providers, builtin_diagnoser) + end -- special case: fallback to "eslint" -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint if linter.exe == "eslint_d" then @@ -86,6 +89,7 @@ function M.setup(filetype) u.lvim_log(string.format("Using linter provider: [%s]", linter.exe)) end + -- FIXME: why would we need to remove if we never add? for idx, provider in pairs(M.requested_providers) do if not validate_provider(provider) then table.remove(M.requested_providers, idx) -- cgit v1.2.3 From 326ac090453b302b35b5747ab9a66f86c70acfbe Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Sat, 31 Jul 2021 20:18:29 -0400 Subject: don't use the elm stuff provided in lspinstall path --- lua/default-config.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index d6063671..41a42171 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -406,12 +406,12 @@ lvim.lang = { }, on_attach = common_on_attach, on_init = common_on_init, - init_options = { - elmAnalyseTrigger = "change", - elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format", - elmPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/", - elmTestPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-test", - }, + -- init_options = { + -- elmAnalyseTrigger = "change", + -- elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format", + -- elmPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/", + -- elmTestPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-test", + -- }, }, }, }, -- cgit v1.2.3 From 30ad4b81f5dbccb6d49eb28ffdd33cefcb758ee5 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 1 Aug 2021 14:27:15 +0430 Subject: Hotfix/eslint d (#1198) --- lua/lsp/handlers.lua | 6 +++++- lua/lsp/null-ls.lua | 23 ++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'lua') diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua index a25db3c1..849d2a03 100644 --- a/lua/lsp/handlers.lua +++ b/lua/lsp/handlers.lua @@ -27,7 +27,11 @@ function M.setup() local diagnostics = params.diagnostics for i, v in ipairs(diagnostics) do - diagnostics[i].message = string.format("%s: %s", v.source, v.message) + local source = v.source + if string.find(v.source, "/") then + source = string.sub(v.source, string.find(v.source, "([%w-_]+)$")) + end + diagnostics[i].message = string.format("%s: %s", source, v.message) if vim.tbl_contains(vim.tbl_keys(v), "code") then diagnostics[i].message = diagnostics[i].message .. string.format(" [%s]", v.code) diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 798c02ee..b8f9bfe6 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -34,18 +34,17 @@ end local function is_provider_found(provider) local retval = { is_local = false, path = nil } - if vim.fn.executable(provider._opts.command) == 1 then - return false, provider._opts.command - end if is_nodejs_provider(provider) then vim.cmd "let root_dir = FindRootDirectory()" local root_dir = vim.api.nvim_get_var "root_dir" local local_provider_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command if vim.fn.executable(local_provider_command) == 1 then - retval.is_local = true - retval.path = local_provider_command + return true, local_provider_command end end + if vim.fn.executable(provider._opts.command) == 1 then + return false, provider._opts.command + end return retval.is_local, retval.path end @@ -78,23 +77,17 @@ function M.setup(filetype) -- builtin_diagnoser._opts.args = linter.args or builtin_diagnoser._opts.args -- builtin_diagnoser._opts.to_stdin = linter.stdin or builtin_diagnoser._opts.to_stdin -- NOTE: validate before inserting to table - if validate_provider(builtin_diagnoser) then - table.insert(M.requested_providers, builtin_diagnoser) - end -- special case: fallback to "eslint" -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint if linter.exe == "eslint_d" then - table.insert(M.requested_providers, null_ls.builtins.diagnostics.eslint.with { command = "eslint_d" }) + builtin_diagnoser = null_ls.builtins.diagnostics.eslint.with { command = "eslint_d" } + end + if validate_provider(builtin_diagnoser) then + table.insert(M.requested_providers, builtin_diagnoser) end u.lvim_log(string.format("Using linter provider: [%s]", linter.exe)) end - -- FIXME: why would we need to remove if we never add? - for idx, provider in pairs(M.requested_providers) do - if not validate_provider(provider) then - table.remove(M.requested_providers, idx) - end - end null_ls.register { sources = M.requested_providers } end -- cgit v1.2.3 From e2dd993ce753f8d28e6c32c4697ba51cc8ace2bb Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 1 Aug 2021 12:02:10 +0200 Subject: refactor null-ls (#1202) --- lua/lsp/null-ls.lua | 67 +++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index b8f9bfe6..51fab00b 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -23,40 +23,37 @@ function M.get_registered_providers_by_filetype(ft) return matches end -local function is_nodejs_provider(provider) - for _, local_provider in ipairs(nodejs_local_providers) do - if local_provider == provider._opts.command then - return true - end +local function validate_nodejs_provider(requests, provider) + vim.cmd "let root_dir = FindRootDirectory()" + local root_dir = vim.api.nvim_get_var "root_dir" + local local_nodejs_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command + u.lvim_log(string.format("checking for local node module: [%s]", vim.inspect(provider))) + if vim.fn.executable(local_nodejs_command) == 1 then + provider._opts.command = local_nodejs_command + table.insert(requests, provider) + elseif vim.fn.executable(provider._opts.command) == 1 then + u.lvim_log(string.format("checking in global path instead for node module: [%s]", provider._opts.command)) + table.insert(requests, provider) + else + u.lvim_log(string.format("Unable to find node module: [%s]", provider._opts.command)) + return false end - return false + return true end -local function is_provider_found(provider) - local retval = { is_local = false, path = nil } - if is_nodejs_provider(provider) then - vim.cmd "let root_dir = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "root_dir" - local local_provider_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command - if vim.fn.executable(local_provider_command) == 1 then - return true, local_provider_command - end +local function validate_provider_request(requests, provider) + if provider == "" or provider == nil then + return false end - if vim.fn.executable(provider._opts.command) == 1 then - return false, provider._opts.command + -- NOTE: we can't use provider.name because eslint_d uses eslint name + if vim.tbl_contains(nodejs_local_providers, provider._opts.command) then + return validate_nodejs_provider(requests, provider) end - return retval.is_local, retval.path -end - -local function validate_provider(provider) - local is_local, provider_path = is_provider_found(provider) - if not provider_path then + if vim.fn.executable(provider._opts.command) ~= 1 then u.lvim_log(string.format("Unable to find the path for: [%s]", vim.inspect(provider))) return false end - if is_local then - provider._opts.command = provider_path - end + table.insert(requests, provider) return true end @@ -67,25 +64,25 @@ function M.setup(filetype) -- FIXME: why doesn't this work? -- builtin_formatter._opts.args = formatter.args or builtin_formatter._opts.args -- builtin_formatter._opts.to_stdin = formatter.stdin or builtin_formatter._opts.to_stdin - table.insert(M.requested_providers, builtin_formatter) - u.lvim_log(string.format("Using format provider: [%s]", formatter.exe)) + if validate_provider_request(M.requested_providers, builtin_formatter) then + u.lvim_log(string.format("Using format provider: [%s]", formatter.exe)) + end end for _, linter in pairs(lvim.lang[filetype].linters) do local builtin_diagnoser = null_ls.builtins.diagnostics[linter.exe] - -- FIXME: why doesn't this work? - -- builtin_diagnoser._opts.args = linter.args or builtin_diagnoser._opts.args - -- builtin_diagnoser._opts.to_stdin = linter.stdin or builtin_diagnoser._opts.to_stdin - -- NOTE: validate before inserting to table -- special case: fallback to "eslint" -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint + -- if provider.exe if linter.exe == "eslint_d" then builtin_diagnoser = null_ls.builtins.diagnostics.eslint.with { command = "eslint_d" } end - if validate_provider(builtin_diagnoser) then - table.insert(M.requested_providers, builtin_diagnoser) + -- FIXME: why doesn't this work? + -- builtin_diagnoser._opts.args = linter.args or builtin_diagnoser._opts.args + -- builtin_diagnoser._opts.to_stdin = linter.stdin or builtin_diagnoser._opts.to_stdin + if validate_provider_request(M.requested_providers, builtin_diagnoser) then + u.lvim_log(string.format("Using linter provider: [%s]", linter.exe)) end - u.lvim_log(string.format("Using linter provider: [%s]", linter.exe)) end null_ls.register { sources = M.requested_providers } -- cgit v1.2.3 From 341a17daa60562f553e41c4c6792a6c917d8d9ef Mon Sep 17 00:00:00 2001 From: Luc Sinet Date: Sun, 1 Aug 2021 12:02:19 +0200 Subject: Fix formatting issues (#1200) --- lua/default-config.lua | 8 +- lua/spacegray/Git.lua | 14 ++-- lua/spacegray/LSP.lua | 192 +++++++++++++++++++++---------------------- lua/spacegray/Treesitter.lua | 106 ++++++++++++------------ lua/spacegray/Whichkey.lua | 12 +-- lua/spacegray/config.lua | 26 +++--- lua/spacegray/highlights.lua | 192 +++++++++++++++++++++---------------------- lua/spacegray/init.lua | 53 ++++++------ lua/spacegray/markdown.lua | 48 +++++------ lua/spacegray/palette.lua | 74 ++++++++--------- lua/spacegray/util.lua | 27 +++--- 11 files changed, 377 insertions(+), 375 deletions(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 41a42171..739612af 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -407,10 +407,10 @@ lvim.lang = { on_attach = common_on_attach, on_init = common_on_init, -- init_options = { - -- elmAnalyseTrigger = "change", - -- elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format", - -- elmPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/", - -- elmTestPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-test", + -- elmAnalyseTrigger = "change", + -- elmFormatPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-format", + -- elmPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/", + -- elmTestPath = DATA_PATH .. "/lspinstall/elm/node_modules/.bin/elm-test", -- }, }, }, diff --git a/lua/spacegray/Git.lua b/lua/spacegray/Git.lua index f1a2ed39..b47ccf23 100644 --- a/lua/spacegray/Git.lua +++ b/lua/spacegray/Git.lua @@ -1,10 +1,10 @@ local Git = { - SignAdd = {fg = C.sign_add, }, - SignChange = {fg = C.sign_change, }, - SignDelete = {fg = C.sign_delete, }, - GitSignsAdd = {fg = C.sign_add, }, - GitSignsChange = {fg = C.sign_change, }, - GitSignsDelete = {fg = C.sign_delete, }, + SignAdd = { fg = C.sign_add }, + SignChange = { fg = C.sign_change }, + SignDelete = { fg = C.sign_delete }, + GitSignsAdd = { fg = C.sign_add }, + GitSignsChange = { fg = C.sign_change }, + GitSignsDelete = { fg = C.sign_delete }, } -return Git \ No newline at end of file +return Git diff --git a/lua/spacegray/LSP.lua b/lua/spacegray/LSP.lua index 5e6ac1c9..dd3d77ac 100644 --- a/lua/spacegray/LSP.lua +++ b/lua/spacegray/LSP.lua @@ -1,99 +1,99 @@ local LSP = { - LspDiagnosticsDefaultError = {fg = C.error_red, }, - LspDiagnosticsDefaultWarning = {fg = C.warning_orange, }, - LspDiagnosticsDefaultInformation = {fg = C.info_yellow, }, - LspDiagnosticsDefaultHint = {fg = C.hint_blue, }, - LspDiagnosticsVirtualTextError = {fg = C.error_red, }, - LspDiagnosticsVirtualTextWarning = {fg = C.warning_orange, }, - LspDiagnosticsVirtualTextInformation = {fg = C.info_yellow, }, - LspDiagnosticsVirtualTextHint = {fg = C.hint_blue, }, - LspDiagnosticsFloatingError = {fg = C.error_red, }, - LspDiagnosticsFloatingWarning = {fg = C.warning_orange, }, - LspDiagnosticsFloatingInformation = {fg = C.info_yellow, }, - LspDiagnosticsFloatingHint = {fg = C.hint_blue, }, - LspDiagnosticsSignError = {fg = C.error_red, }, - LspDiagnosticsSignWarning = {fg = C.warning_orange, }, - LspDiagnosticsSignInformation = {fg = C.info_yellow, }, - LspDiagnosticsSignHint = {fg = C.hint_blue, }, - LspDiagnosticsError = {fg = C.error_red, }, - LspDiagnosticsWarning = {fg = C.warning_orange, }, - LspDiagnosticsInformation = {fg = C.info_yellow, }, - LspDiagnosticsHint = {fg = C.hint_blue, }, - LspDiagnosticsUnderlineError = {style = "underline", }, - LspDiagnosticsUnderlineWarning = {style = "underline", }, - LspDiagnosticsUnderlineInformation = {style = "underline", }, - LspDiagnosticsUnderlineHint = {style = "underline", }, - QuickScopePrimary = {fg = C.purple_test, style = "underline", }, - QuickScopeSecondary = {fg = C.cyan_test, style = "underline", }, - TelescopeSelection = {fg = C.hint_blue, }, - TelescopeMatching = {fg = C.info_yellow, style = "bold", }, - TelescopeBorder = {fg = C.cyan, bg = Config.transparent_background and "NONE" or C.bg, }, - NvimTreeFolderIcon = {fg = C.blue, }, - NvimTreeIndentMarker = {fg = C.gray, }, - NvimTreeNormal = {fg = C.light_gray, bg = C.alt_bg, }, - NvimTreeVertSplit = {fg = C.alt_bg, bg = C.alt_bg, }, - NvimTreeFolderName = {fg = C.blue, }, - NvimTreeOpenedFolderName = {fg = C.cyan, style = "italic", }, - NvimTreeImageFile = {fg = C.purple, }, - NvimTreeSpecialFile = {fg = C.orange, }, - NvimTreeGitStaged = {fg = C.sign_add, }, - NvimTreeGitNew = {fg = C.sign_add, }, - NvimTreeGitDirty = {fg = C.sign_add, }, - NvimTreeGitDeleted = {fg = C.sign_delete, }, - NvimTreeGitMerge = {fg = C.sign_change, }, - NvimTreeGitRenamed = {fg = C.sign_change, }, - NvimTreeSymlink = {fg = C.cyan, }, - NvimTreeRootFolder = {fg = C.fg, style = "bold", }, - NvimTreeExecFile = {fg = C.green, }, - LirFloatNormal = {fg = C.light_gray, bg = C.alt_bg, }, - LirDir = {fg = C.blue, }, - LirSymLink = {fg = C.cyan, }, - LirEmptyDirText = {fg = C.blue, }, - BufferCurrent = {fg = C.fg, bg = C.bg, }, - BufferCurrentIndex = {fg = C.fg, bg = C.bg, }, - BufferCurrentMod = {fg = C.info_yellow, bg = C.bg, }, - BufferCurrentSign = {fg = C.hint_blue, bg = C.bg, }, - BufferCurrentTarget = {fg = C.red, bg = C.bg, style = "bold", }, - BufferVisible = {fg = C.fg, bg = C.bg, }, - BufferVisibleIndex = {fg = C.fg, bg = C.bg, }, - BufferVisibleMod = {fg = C.info_yellow, bg = C.bg, }, - BufferVisibleSign = {fg = C.gray, bg = C.bg, }, - BufferVisibleTarget = {fg = C.red, bg = C.bg, style = "bold", }, - BufferInactive = {fg = C.gray, bg = C.alt_bg, }, - BufferInactiveIndex = {fg = C.gray, bg = C.alt_bg, }, - BufferInactiveMod = {fg = C.info_yellow, bg = C.alt_bg, }, - BufferInactiveSign = {fg = C.gray, bg = C.alt_bg, }, - BufferInactiveTarget = {fg = C.red, bg = C.alt_bg, style = "bold", }, - StatusLine = {fg = C.alt_bg, }, - StatusLineNC = {fg = C.alt_bg, }, - StatusLineSeparator = {fg = C.alt_bg, }, - StatusLineTerm = {fg = C.alt_bg, }, - StatusLineTermNC = {fg = C.alt_bg, }, - CodiVirtualText = {fg = C.hint_blue, }, - IndentBlanklineContextChar = {fg = C.accent, }, - DashboardHeader = {fg = C.blue, }, - DashboardCenter = {fg = C.purple, }, - DashboardFooter = {fg = C.cyan, }, - xmlTag = {fg = C.cyan, }, - xmlTagName = {fg = C.cyan, }, - xmlEndTag = {fg = C.cyan, }, - CompeDocumentation = {bg = C.alt_bg, }, - DiffViewNormal = {fg = C.gray, bg = C.alt_bg, }, - DiffviewStatusAdded = {fg = C.sign_add, }, - DiffviewStatusModified = {fg = C.sign_change, }, - DiffviewStatusRenamed = {fg = C.sign_change, }, - DiffviewStatusDeleted = {fg = C.sign_delete, }, - DiffviewFilePanelInsertion = {fg = C.sign_add, }, - DiffviewFilePanelDeletion = {fg = C.sign_delete, }, - DiffviewVertSplit = {bg = C.bg, }, - diffAdded = {fg = C.sign_add, }, - diffRemoved = {fg = C.sign_delete, }, - diffFileId = {fg = C.blue, style = "bold,reverse", }, - diffFile = {fg = C.alt_bg, }, - diffNewFile = {fg = C.green, }, - diffOldFile = {fg = C.red, }, - debugPc = {bg = C.cyan, }, - debugBreakpoint = {fg = C.red, style = "reverse", }, + LspDiagnosticsDefaultError = { fg = C.error_red }, + LspDiagnosticsDefaultWarning = { fg = C.warning_orange }, + LspDiagnosticsDefaultInformation = { fg = C.info_yellow }, + LspDiagnosticsDefaultHint = { fg = C.hint_blue }, + LspDiagnosticsVirtualTextError = { fg = C.error_red }, + LspDiagnosticsVirtualTextWarning = { fg = C.warning_orange }, + LspDiagnosticsVirtualTextInformation = { fg = C.info_yellow }, + LspDiagnosticsVirtualTextHint = { fg = C.hint_blue }, + LspDiagnosticsFloatingError = { fg = C.error_red }, + LspDiagnosticsFloatingWarning = { fg = C.warning_orange }, + LspDiagnosticsFloatingInformation = { fg = C.info_yellow }, + LspDiagnosticsFloatingHint = { fg = C.hint_blue }, + LspDiagnosticsSignError = { fg = C.error_red }, + LspDiagnosticsSignWarning = { fg = C.warning_orange }, + LspDiagnosticsSignInformation = { fg = C.info_yellow }, + LspDiagnosticsSignHint = { fg = C.hint_blue }, + LspDiagnosticsError = { fg = C.error_red }, + LspDiagnosticsWarning = { fg = C.warning_orange }, + LspDiagnosticsInformation = { fg = C.info_yellow }, + LspDiagnosticsHint = { fg = C.hint_blue }, + LspDiagnosticsUnderlineError = { style = "underline" }, + LspDiagnosticsUnderlineWarning = { style = "underline" }, + LspDiagnosticsUnderlineInformation = { style = "underline" }, + LspDiagnosticsUnderlineHint = { style = "underline" }, + QuickScopePrimary = { fg = C.purple_test, style = "underline" }, + QuickScopeSecondary = { fg = C.cyan_test, style = "underline" }, + TelescopeSelection = { fg = C.hint_blue }, + TelescopeMatching = { fg = C.info_yellow, style = "bold" }, + TelescopeBorder = { fg = C.cyan, bg = Config.transparent_background and "NONE" or C.bg }, + NvimTreeFolderIcon = { fg = C.blue }, + NvimTreeIndentMarker = { fg = C.gray }, + NvimTreeNormal = { fg = C.light_gray, bg = C.alt_bg }, + NvimTreeVertSplit = { fg = C.alt_bg, bg = C.alt_bg }, + NvimTreeFolderName = { fg = C.blue }, + NvimTreeOpenedFolderName = { fg = C.cyan, style = "italic" }, + NvimTreeImageFile = { fg = C.purple }, + NvimTreeSpecialFile = { fg = C.orange }, + NvimTreeGitStaged = { fg = C.sign_add }, + NvimTreeGitNew = { fg = C.sign_add }, + NvimTreeGitDirty = { fg = C.sign_add }, + NvimTreeGitDeleted = { fg = C.sign_delete }, + NvimTreeGitMerge = { fg = C.sign_change }, + NvimTreeGitRenamed = { fg = C.sign_change }, + NvimTreeSymlink = { fg = C.cyan }, + NvimTreeRootFolder = { fg = C.fg, style = "bold" }, + NvimTreeExecFile = { fg = C.green }, + LirFloatNormal = { fg = C.light_gray, bg = C.alt_bg }, + LirDir = { fg = C.blue }, + LirSymLink = { fg = C.cyan }, + LirEmptyDirText = { fg = C.blue }, + BufferCurrent = { fg = C.fg, bg = C.bg }, + BufferCurrentIndex = { fg = C.fg, bg = C.bg }, + BufferCurrentMod = { fg = C.info_yellow, bg = C.bg }, + BufferCurrentSign = { fg = C.hint_blue, bg = C.bg }, + BufferCurrentTarget = { fg = C.red, bg = C.bg, style = "bold" }, + BufferVisible = { fg = C.fg, bg = C.bg }, + BufferVisibleIndex = { fg = C.fg, bg = C.bg }, + BufferVisibleMod = { fg = C.info_yellow, bg = C.bg }, + BufferVisibleSign = { fg = C.gray, bg = C.bg }, + BufferVisibleTarget = { fg = C.red, bg = C.bg, style = "bold" }, + BufferInactive = { fg = C.gray, bg = C.alt_bg }, + BufferInactiveIndex = { fg = C.gray, bg = C.alt_bg }, + BufferInactiveMod = { fg = C.info_yellow, bg = C.alt_bg }, + BufferInactiveSign = { fg = C.gray, bg = C.alt_bg }, + BufferInactiveTarget = { fg = C.red, bg = C.alt_bg, style = "bold" }, + StatusLine = { fg = C.alt_bg }, + StatusLineNC = { fg = C.alt_bg }, + StatusLineSeparator = { fg = C.alt_bg }, + StatusLineTerm = { fg = C.alt_bg }, + StatusLineTermNC = { fg = C.alt_bg }, + CodiVirtualText = { fg = C.hint_blue }, + IndentBlanklineContextChar = { fg = C.accent }, + DashboardHeader = { fg = C.blue }, + DashboardCenter = { fg = C.purple }, + DashboardFooter = { fg = C.cyan }, + xmlTag = { fg = C.cyan }, + xmlTagName = { fg = C.cyan }, + xmlEndTag = { fg = C.cyan }, + CompeDocumentation = { bg = C.alt_bg }, + DiffViewNormal = { fg = C.gray, bg = C.alt_bg }, + DiffviewStatusAdded = { fg = C.sign_add }, + DiffviewStatusModified = { fg = C.sign_change }, + DiffviewStatusRenamed = { fg = C.sign_change }, + DiffviewStatusDeleted = { fg = C.sign_delete }, + DiffviewFilePanelInsertion = { fg = C.sign_add }, + DiffviewFilePanelDeletion = { fg = C.sign_delete }, + DiffviewVertSplit = { bg = C.bg }, + diffAdded = { fg = C.sign_add }, + diffRemoved = { fg = C.sign_delete }, + diffFileId = { fg = C.blue, style = "bold,reverse" }, + diffFile = { fg = C.alt_bg }, + diffNewFile = { fg = C.green }, + diffOldFile = { fg = C.red }, + debugPc = { bg = C.cyan }, + debugBreakpoint = { fg = C.red, style = "reverse" }, } -return LSP \ No newline at end of file +return LSP diff --git a/lua/spacegray/Treesitter.lua b/lua/spacegray/Treesitter.lua index e680669a..4e5ce16e 100644 --- a/lua/spacegray/Treesitter.lua +++ b/lua/spacegray/Treesitter.lua @@ -1,56 +1,56 @@ local Treesitter = { - TSComment = {fg = C.gray, }, - TSAnnotation = {fg = C.purple, }, - TSAttribute = {fg = C.cyan, }, - TSConstructor = {fg = C.purple, }, - TSType = {fg = C.purple, }, - TSTypeBuiltin = {fg = C.purple, }, - TSConditional = {fg = C.blue, }, - TSException = {fg = C.blue, }, - TSInclude = {fg = C.blue, }, - TSKeyword = {fg = C.blue, }, - TSKeywordFunction = {fg = C.blue, }, - TSLabel = {fg = C.blue, }, - TSNamespace = {fg = C.blue, }, - TSRepeat = {fg = C.blue, }, - TSConstant = {fg = C.orange, }, - TSConstBuiltin = {fg = C.red, }, - TSFloat = {fg = C.red, }, - TSNumber = {fg = C.red, }, - TSBoolean = {fg = C.red, }, - TSCharacter = {fg = C.light_green, }, - TSError = {fg = C.error_red, }, - TSFunction = {fg = C.yellow, }, - TSFuncBuiltin = {fg = C.yellow, }, - TSMethod = {fg = C.yellow, }, - TSConstMacro = {fg = C.cyan, }, - TSFuncMacro = {fg = C.yellow, }, - TSVariable = {fg = C.light_blue, }, - TSVariableBuiltin = {fg = C.light_blue, }, - TSProperty = {fg = C.light_blue, }, - TSOperator = {fg = C.gray, }, - TSField = {fg = C.light_blue, }, - TSParameter = {fg = C.light_blue, }, - TSParameterReference = {fg = C.light_blue, }, - TSSymbol = {fg = C.light_blue, }, - TSText = {fg = C.fg, }, - TSPunctDelimiter = {fg = C.gray, }, - TSTagDelimiter = {fg = C.gray, }, - TSPunctBracket = {fg = C.gray, }, - TSPunctSpecial = {fg = C.gray, }, - TSString = {fg = C.green, }, - TSStringRegex = {fg = C.yellow_orange, }, - TSStringEscape = {fg = C.yellow_orange, }, - TSTag = {fg = C.blue, }, - TSEmphasis = {style = "italic", }, - TSUnderline = {style = "underline", }, - TSTitle = {fg = C.blue, style = "bold", }, - TSLiteral = {fg = C.yellow_orange, }, - TSURI = {fg = C.yellow_orange, style = "underline", }, - TSKeywordOperator = {fg = C.blue, }, - TSStructure = {fg = C.light_blue, }, - TSStrong = {fg = C.yellow_orange, }, - TSQueryLinterError = {fg = C.warning_orange, }, + TSComment = { fg = C.gray }, + TSAnnotation = { fg = C.purple }, + TSAttribute = { fg = C.cyan }, + TSConstructor = { fg = C.purple }, + TSType = { fg = C.purple }, + TSTypeBuiltin = { fg = C.purple }, + TSConditional = { fg = C.blue }, + TSException = { fg = C.blue }, + TSInclude = { fg = C.blue }, + TSKeyword = { fg = C.blue }, + TSKeywordFunction = { fg = C.blue }, + TSLabel = { fg = C.blue }, + TSNamespace = { fg = C.blue }, + TSRepeat = { fg = C.blue }, + TSConstant = { fg = C.orange }, + TSConstBuiltin = { fg = C.red }, + TSFloat = { fg = C.red }, + TSNumber = { fg = C.red }, + TSBoolean = { fg = C.red }, + TSCharacter = { fg = C.light_green }, + TSError = { fg = C.error_red }, + TSFunction = { fg = C.yellow }, + TSFuncBuiltin = { fg = C.yellow }, + TSMethod = { fg = C.yellow }, + TSConstMacro = { fg = C.cyan }, + TSFuncMacro = { fg = C.yellow }, + TSVariable = { fg = C.light_blue }, + TSVariableBuiltin = { fg = C.light_blue }, + TSProperty = { fg = C.light_blue }, + TSOperator = { fg = C.gray }, + TSField = { fg = C.light_blue }, + TSParameter = { fg = C.light_blue }, + TSParameterReference = { fg = C.light_blue }, + TSSymbol = { fg = C.light_blue }, + TSText = { fg = C.fg }, + TSPunctDelimiter = { fg = C.gray }, + TSTagDelimiter = { fg = C.gray }, + TSPunctBracket = { fg = C.gray }, + TSPunctSpecial = { fg = C.gray }, + TSString = { fg = C.green }, + TSStringRegex = { fg = C.yellow_orange }, + TSStringEscape = { fg = C.yellow_orange }, + TSTag = { fg = C.blue }, + TSEmphasis = { style = "italic" }, + TSUnderline = { style = "underline" }, + TSTitle = { fg = C.blue, style = "bold" }, + TSLiteral = { fg = C.yellow_orange }, + TSURI = { fg = C.yellow_orange, style = "underline" }, + TSKeywordOperator = { fg = C.blue }, + TSStructure = { fg = C.light_blue }, + TSStrong = { fg = C.yellow_orange }, + TSQueryLinterError = { fg = C.warning_orange }, } -return Treesitter \ No newline at end of file +return Treesitter diff --git a/lua/spacegray/Whichkey.lua b/lua/spacegray/Whichkey.lua index 7b2a11a0..5d1ae7ce 100644 --- a/lua/spacegray/Whichkey.lua +++ b/lua/spacegray/Whichkey.lua @@ -1,9 +1,9 @@ local Whichkey = { - WhichKey = {fg = C.purple, }, - WhichKeySeperator = {fg = C.green, }, - WhichKeyGroup = {fg = C.blue, }, - WhichKeyDesc = {fg = C.light_blue, }, - WhichKeyFloat = {bg = C.dark, }, + WhichKey = { fg = C.purple }, + WhichKeySeperator = { fg = C.green }, + WhichKeyGroup = { fg = C.blue }, + WhichKeyDesc = { fg = C.light_blue }, + WhichKeyFloat = { bg = C.dark }, } -return Whichkey \ No newline at end of file +return Whichkey diff --git a/lua/spacegray/config.lua b/lua/spacegray/config.lua index f9c10951..ebac7109 100644 --- a/lua/spacegray/config.lua +++ b/lua/spacegray/config.lua @@ -3,21 +3,21 @@ local config vim = vim or { g = {}, o = {} } local function opt(key, default) - if vim.g[key] == nil then - return default - end - if vim.g[key] == 0 then - return false - end - return vim.g[key] + if vim.g[key] == nil then + return default + end + if vim.g[key] == 0 then + return false + end + return vim.g[key] end config = { - transparent_background = opt("transparent_background", false), - italic_comments = opt("italic_keywords", true) and "italic" or "NONE", - italic_keywords = opt("italic_keywords", true) and "italic" or "NONE", - italic_functions = opt("italic_function", false) and "italic" or "NONE", - italic_variables = opt("italic_variables", true) and "italic" or "NONE", + transparent_background = opt("transparent_background", false), + italic_comments = opt("italic_keywords", true) and "italic" or "NONE", + italic_keywords = opt("italic_keywords", true) and "italic" or "NONE", + italic_functions = opt("italic_function", false) and "italic" or "NONE", + italic_variables = opt("italic_variables", true) and "italic" or "NONE", } -return config \ No newline at end of file +return config diff --git a/lua/spacegray/highlights.lua b/lua/spacegray/highlights.lua index 06e34be0..208c2c62 100644 --- a/lua/spacegray/highlights.lua +++ b/lua/spacegray/highlights.lua @@ -1,99 +1,99 @@ local highlights = { - Normal = {fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg, }, - SignColumn = {bg = C.bg, }, - MsgArea = {fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg, }, - ModeMsg = {fg = C.fg, bg = C.bg, }, - MsgSeparator = {fg = C.fg, bg = C.bg, }, - SpellBad = {fg = C.error_red, style = "underline", }, - SpellCap = {fg = C.yellow, style = "underline", }, - SpellLocal = {fg = C.green, style = "underline", }, - SpellRare = {fg = C.purple, style = "underline", }, - NormalNC = {fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg, }, - Pmenu = {fg = C.light_gray, bg = C.popup_back, }, - PmenuSel = {fg = C.alt_bg, bg = C.blue, }, - WildMenu = {fg = C.alt_bg, bg = C.blue, }, - CursorLineNr = {fg = C.light_gray, style = "bold", }, - Comment = {fg = C.gray, style = "italic", }, - Folded = {fg = C.accent, bg = C.alt_bg, }, - FoldColumn = {fg = C.accent, bg = C.alt_bg, }, - LineNr = {fg = C.gray, }, - FloatBoder = {fg = C.gray, bg = C.alt_bg, }, - Whitespace = {fg = C.bg, }, - VertSplit = {fg = C.bg, bg = C.fg, }, - CursorLine = {bg = C.dark, }, - CursorColumn = {bg = C.dark, }, - ColorColumn = {bg = C.dark, }, - NormalFloat = {bg = C.dark, }, - Visual = {bg = C.ui_blue, }, - VisualNOS = {bg = C.alt_bg, }, - WarningMsg = {fg = C.error_red, bg = C.bg, }, - DiffAdd = {fg = C.alt_bg, bg = C.sign_add, }, - DiffChange = {fg = C.alt_bg, bg = C.sign_change, style = "underline", }, - DiffDelete = {fg = C.alt_bg, bg = C.sign_delete, }, - QuickFixLine = {bg = C.accent, }, - PmenuSbar = {bg = C.alt_bg, }, - PmenuThumb = {bg = C.gray, }, - MatchWord = {style = "underline", }, - MatchParen = {fg = C.hint_blue, bg = C.bg, style = "underline", }, - MatchWordCur = {style = "underline", }, - MatchParenCur = {style = "underline", }, - Cursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, - lCursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, - CursorIM = {fg = C.cursor_fg, bg = C.cursor_bg, }, - TermCursor = {fg = C.cursor_fg, bg = C.cursor_bg, }, - TermCursorNC = {fg = C.cursor_fg, bg = C.cursor_bg, }, - Conceal = {fg = C.accent, }, - Directory = {fg = C.blue, }, - SpecialKey = {fg = C.blue, style = "bold", }, - Title = {fg = C.blue, style = "bold", }, - ErrorMsg = {fg = C.error_red, bg = C.bg, style = "bold", }, - Search = {fg = C.light_gray, bg = C.search_blue, }, - IncSearch = {fg = C.light_gray, bg = C.search_blue, }, - Substitute = {fg = C.light_gray, bg = C.search_orange, }, - MoreMsg = {fg = C.orange, }, - Question = {fg = C.orange, }, - EndOfBuffer = {fg = C.bg, }, - NonText = {fg = C.bg, }, - Variable = {fg = C.light_blue, }, - String = {fg = C.green, }, - Character = {fg = C.light_green, }, - Constant = {fg = C.blue, }, - Number = {fg = C.red, }, - Boolean = {fg = C.red, }, - Float = {fg = C.red, }, - Identifier = {fg = C.light_blue, }, - Function = {fg = C.yellow, }, - Operator = {fg = C.gray, }, - Type = {fg = C.purple, }, - StorageClass = {fg = C.purple, }, - Structure = {fg = C.purple, }, - Typedef = {fg = C.purple, }, - Keyword = {fg = C.blue, }, - Statement = {fg = C.blue, }, - Conditional = {fg = C.blue, }, - Repeat = {fg = C.blue, }, - Label = {fg = C.blue, }, - Exception = {fg = C.blue, }, - Include = {fg = C.blue, }, - PreProc = {fg = C.purple, }, - Define = {fg = C.purple, }, - Macro = {fg = C.purple, }, - PreCondit = {fg = C.purple, }, - Special = {fg = C.orange, }, - SpecialChar = {fg = C.white, }, - Tag = {fg = C.blue, }, - Debug = {fg = C.red, }, - Delimiter = {fg = C.gray, }, - SpecialComment = {fg = C.gray, }, - Underlined = {style = "underline", }, - Bold = {style = "bold", }, - Italic = {style = "italic", }, - Ignore = {fg = C.cyan, bg = C.bg, style = "bold", }, - Todo = {fg = C.red, bg = C.bg, style = "bold", }, - Error = {fg = C.error_red, bg = C.bg, style = "bold", }, - TabLine = {fg = C.light_gray, bg = C.alt_bg, }, - TabLineSel = {fg = C.white, bg = C.alt_bg, }, - TabLineFill = {fg = C.white, bg = C.alt_bg, }, + Normal = { fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg }, + SignColumn = { bg = C.bg }, + MsgArea = { fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg }, + ModeMsg = { fg = C.fg, bg = C.bg }, + MsgSeparator = { fg = C.fg, bg = C.bg }, + SpellBad = { fg = C.error_red, style = "underline" }, + SpellCap = { fg = C.yellow, style = "underline" }, + SpellLocal = { fg = C.green, style = "underline" }, + SpellRare = { fg = C.purple, style = "underline" }, + NormalNC = { fg = C.fg, bg = Config.transparent_background and "NONE" or C.bg }, + Pmenu = { fg = C.light_gray, bg = C.popup_back }, + PmenuSel = { fg = C.alt_bg, bg = C.blue }, + WildMenu = { fg = C.alt_bg, bg = C.blue }, + CursorLineNr = { fg = C.light_gray, style = "bold" }, + Comment = { fg = C.gray, style = "italic" }, + Folded = { fg = C.accent, bg = C.alt_bg }, + FoldColumn = { fg = C.accent, bg = C.alt_bg }, + LineNr = { fg = C.gray }, + FloatBoder = { fg = C.gray, bg = C.alt_bg }, + Whitespace = { fg = C.bg }, + VertSplit = { fg = C.bg, bg = C.fg }, + CursorLine = { bg = C.dark }, + CursorColumn = { bg = C.dark }, + ColorColumn = { bg = C.dark }, + NormalFloat = { bg = C.dark }, + Visual = { bg = C.ui_blue }, + VisualNOS = { bg = C.alt_bg }, + WarningMsg = { fg = C.error_red, bg = C.bg }, + DiffAdd = { fg = C.alt_bg, bg = C.sign_add }, + DiffChange = { fg = C.alt_bg, bg = C.sign_change, style = "underline" }, + DiffDelete = { fg = C.alt_bg, bg = C.sign_delete }, + QuickFixLine = { bg = C.accent }, + PmenuSbar = { bg = C.alt_bg }, + PmenuThumb = { bg = C.gray }, + MatchWord = { style = "underline" }, + MatchParen = { fg = C.hint_blue, bg = C.bg, style = "underline" }, + MatchWordCur = { style = "underline" }, + MatchParenCur = { style = "underline" }, + Cursor = { fg = C.cursor_fg, bg = C.cursor_bg }, + lCursor = { fg = C.cursor_fg, bg = C.cursor_bg }, + CursorIM = { fg = C.cursor_fg, bg = C.cursor_bg }, + TermCursor = { fg = C.cursor_fg, bg = C.cursor_bg }, + TermCursorNC = { fg = C.cursor_fg, bg = C.cursor_bg }, + Conceal = { fg = C.accent }, + Directory = { fg = C.blue }, + SpecialKey = { fg = C.blue, style = "bold" }, + Title = { fg = C.blue, style = "bold" }, + ErrorMsg = { fg = C.error_red, bg = C.bg, style = "bold" }, + Search = { fg = C.light_gray, bg = C.search_blue }, + IncSearch = { fg = C.light_gray, bg = C.search_blue }, + Substitute = { fg = C.light_gray, bg = C.search_orange }, + MoreMsg = { fg = C.orange }, + Question = { fg = C.orange }, + EndOfBuffer = { fg = C.bg }, + NonText = { fg = C.bg }, + Variable = { fg = C.light_blue }, + String = { fg = C.green }, + Character = { fg = C.light_green }, + Constant = { fg = C.blue }, + Number = { fg = C.red }, + Boolean = { fg = C.red }, + Float = { fg = C.red }, + Identifier = { fg = C.light_blue }, + Function = { fg = C.yellow }, + Operator = { fg = C.gray }, + Type = { fg = C.purple }, + StorageClass = { fg = C.purple }, + Structure = { fg = C.purple }, + Typedef = { fg = C.purple }, + Keyword = { fg = C.blue }, + Statement = { fg = C.blue }, + Conditional = { fg = C.blue }, + Repeat = { fg = C.blue }, + Label = { fg = C.blue }, + Exception = { fg = C.blue }, + Include = { fg = C.blue }, + PreProc = { fg = C.purple }, + Define = { fg = C.purple }, + Macro = { fg = C.purple }, + PreCondit = { fg = C.purple }, + Special = { fg = C.orange }, + SpecialChar = { fg = C.white }, + Tag = { fg = C.blue }, + Debug = { fg = C.red }, + Delimiter = { fg = C.gray }, + SpecialComment = { fg = C.gray }, + Underlined = { style = "underline" }, + Bold = { style = "bold" }, + Italic = { style = "italic" }, + Ignore = { fg = C.cyan, bg = C.bg, style = "bold" }, + Todo = { fg = C.red, bg = C.bg, style = "bold" }, + Error = { fg = C.error_red, bg = C.bg, style = "bold" }, + TabLine = { fg = C.light_gray, bg = C.alt_bg }, + TabLineSel = { fg = C.white, bg = C.alt_bg }, + TabLineFill = { fg = C.white, bg = C.alt_bg }, } -return highlights \ No newline at end of file +return highlights diff --git a/lua/spacegray/init.lua b/lua/spacegray/init.lua index 70d57bda..9ae24dbb 100644 --- a/lua/spacegray/init.lua +++ b/lua/spacegray/init.lua @@ -1,44 +1,43 @@ -vim.api.nvim_command("hi clear") -if vim.fn.exists("syntax_on") then - vim.api.nvim_command("syntax reset") +vim.api.nvim_command "hi clear" +if vim.fn.exists "syntax_on" then + vim.api.nvim_command "syntax reset" end vim.o.background = "dark" vim.o.termguicolors = true vim.g.colors_name = "spacegray" -local util = require("spacegray.util") -Config = require("spacegray.config") -C = require("spacegray.palette") +local util = require "spacegray.util" +Config = require "spacegray.config" +C = require "spacegray.palette" local async -async = vim.loop.new_async(vim.schedule_wrap(function () - - - local skeletons = { - - } - - for _, skeleton in ipairs(skeletons) do - util.initialise(skeleton) - end +async = vim.loop.new_async(vim.schedule_wrap(function() + local skeletons = {} + for _, skeleton in ipairs(skeletons) do + util.initialise(skeleton) + end - async:close() + async:close() end)) -local highlights = require("spacegray.highlights") -local Treesitter = require("spacegray.Treesitter") -local markdown = require("spacegray.markdown") -local Whichkey = require("spacegray.Whichkey") -local Git = require("spacegray.Git") -local LSP = require("spacegray.LSP") - +local highlights = require "spacegray.highlights" +local Treesitter = require "spacegray.Treesitter" +local markdown = require "spacegray.markdown" +local Whichkey = require "spacegray.Whichkey" +local Git = require "spacegray.Git" +local LSP = require "spacegray.LSP" local skeletons = { - highlights, Treesitter, markdown, Whichkey, Git, LSP + highlights, + Treesitter, + markdown, + Whichkey, + Git, + LSP, } for _, skeleton in ipairs(skeletons) do - util.initialise(skeleton) + util.initialise(skeleton) end -async:send() \ No newline at end of file +async:send() diff --git a/lua/spacegray/markdown.lua b/lua/spacegray/markdown.lua index 19863dc8..2b83e056 100644 --- a/lua/spacegray/markdown.lua +++ b/lua/spacegray/markdown.lua @@ -1,27 +1,27 @@ local markdown = { - markdownBlockquote = {fg = C.accent, }, - markdownBold = {fg = C.yellow, style = "bold", }, - markdownCode = {fg = C.green, }, - markdownCodeBlock = {fg = C.green, }, - markdownCodeDelimiter = {fg = C.green, }, - markdownH1 = {fg = C.blue, }, - markdownH2 = {fg = C.blue, }, - markdownH3 = {fg = C.blue, }, - markdownH4 = {fg = C.blue, }, - markdownH5 = {fg = C.blue, }, - markdownH6 = {fg = C.blue, }, - markdownHeadingDelimiter = {fg = C.red, }, - markdownHeadingRule = {fg = C.accent, }, - markdownId = {fg = C.purple, }, - markdownIdDeclaration = {fg = C.blue, }, - markdownIdDelimiter = {fg = C.light_gray, }, - markdownLinkDelimiter = {fg = C.light_gray, }, - markdownItalic = {style = "italic", }, - markdownLinkText = {fg = C.blue, }, - markdownListMarker = {fg = C.red, }, - markdownOrderedListMarker = {fg = C.red, }, - markdownRule = {fg = C.accent, }, - markdownUrl = {fg = C.cyan, style = "underline", }, + markdownBlockquote = { fg = C.accent }, + markdownBold = { fg = C.yellow, style = "bold" }, + markdownCode = { fg = C.green }, + markdownCodeBlock = { fg = C.green }, + markdownCodeDelimiter = { fg = C.green }, + markdownH1 = { fg = C.blue }, + markdownH2 = { fg = C.blue }, + markdownH3 = { fg = C.blue }, + markdownH4 = { fg = C.blue }, + markdownH5 = { fg = C.blue }, + markdownH6 = { fg = C.blue }, + markdownHeadingDelimiter = { fg = C.red }, + markdownHeadingRule = { fg = C.accent }, + markdownId = { fg = C.purple }, + markdownIdDeclaration = { fg = C.blue }, + markdownIdDelimiter = { fg = C.light_gray }, + markdownLinkDelimiter = { fg = C.light_gray }, + markdownItalic = { style = "italic" }, + markdownLinkText = { fg = C.blue }, + markdownListMarker = { fg = C.red }, + markdownOrderedListMarker = { fg = C.red }, + markdownRule = { fg = C.accent }, + markdownUrl = { fg = C.cyan, style = "underline" }, } -return markdown \ No newline at end of file +return markdown diff --git a/lua/spacegray/palette.lua b/lua/spacegray/palette.lua index df764c81..d3274700 100644 --- a/lua/spacegray/palette.lua +++ b/lua/spacegray/palette.lua @@ -1,40 +1,40 @@ local colors = { - fg = "#ABB2BF", - bg = "#202020", - alt_bg = "#262626", - dark = "#222222", - accent = "#AAAAAA", - popup_back = "#2D2D30", - search_orange = "#613214", - search_blue = "#5e81ac", - white = "#D8DEE9", - gray = "#9BA1AB", - light_gray = "#c8c9c1", - blue = "#5f8ccd", - dark_blue = "#223E55", - light_blue = "#8dc0d5", - green = "#73aa7b", - cyan = "#4EC9B0", - light_green = "#B5CEA8", - red = "#D16969", - orange = "#D1866B", - light_red = "#CA535F", - yellow = "#ECCC8E", - yellow_orange = "#D7BA7D", - purple = "#BF82B4", - magenta = "#D16D9E", - cursor_fg = "#515052", - cursor_bg = "#AEAFAD", - sign_add = "#587c0c", - sign_change = "#0c7d9d", - sign_delete = "#94151b", - error_red = "#F44747", - warning_orange = "#ff8800", - info_yellow = "#FFCC66", - hint_blue = "#4FC1FF", - purple_test = "#ff007c", - cyan_test = "#00dfff", - ui_blue = "#264F78", + fg = "#ABB2BF", + bg = "#202020", + alt_bg = "#262626", + dark = "#222222", + accent = "#AAAAAA", + popup_back = "#2D2D30", + search_orange = "#613214", + search_blue = "#5e81ac", + white = "#D8DEE9", + gray = "#9BA1AB", + light_gray = "#c8c9c1", + blue = "#5f8ccd", + dark_blue = "#223E55", + light_blue = "#8dc0d5", + green = "#73aa7b", + cyan = "#4EC9B0", + light_green = "#B5CEA8", + red = "#D16969", + orange = "#D1866B", + light_red = "#CA535F", + yellow = "#ECCC8E", + yellow_orange = "#D7BA7D", + purple = "#BF82B4", + magenta = "#D16D9E", + cursor_fg = "#515052", + cursor_bg = "#AEAFAD", + sign_add = "#587c0c", + sign_change = "#0c7d9d", + sign_delete = "#94151b", + error_red = "#F44747", + warning_orange = "#ff8800", + info_yellow = "#FFCC66", + hint_blue = "#4FC1FF", + purple_test = "#ff007c", + cyan_test = "#00dfff", + ui_blue = "#264F78", } -return colors \ No newline at end of file +return colors diff --git a/lua/spacegray/util.lua b/lua/spacegray/util.lua index 1cc5a009..dbac18a2 100644 --- a/lua/spacegray/util.lua +++ b/lua/spacegray/util.lua @@ -1,22 +1,25 @@ local M = {} local function highlight(group, properties) - local bg = properties.bg == nil and "" or "guibg=" .. properties.bg - local fg = properties.fg == nil and "" or "guifg=" .. properties.fg - local style = properties.style == nil and "" or "gui=" .. properties.style + local bg = properties.bg == nil and "" or "guibg=" .. properties.bg + local fg = properties.fg == nil and "" or "guifg=" .. properties.fg + local style = properties.style == nil and "" or "gui=" .. properties.style - local cmd = table.concat({ - "highlight", group, bg, fg, style - }, " ") + local cmd = table.concat({ + "highlight", + group, + bg, + fg, + style, + }, " ") - vim.api.nvim_command(cmd) + vim.api.nvim_command(cmd) end - function M.initialise(skeleton) - for group, properties in pairs(skeleton) do - highlight(group, properties) - end + for group, properties in pairs(skeleton) do + highlight(group, properties) + end end -return M \ No newline at end of file +return M -- cgit v1.2.3 From 72f5a54ec2129148aa67da0d86fc8c7c58dedbed Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 1 Aug 2021 12:21:06 -0400 Subject: compe doc options --- lua/core/compe.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lua') diff --git a/lua/core/compe.lua b/lua/core/compe.lua index 08d8b8bd..155c7874 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -15,6 +15,10 @@ M.config = function() documentation = { border = "single", winhighlight = "NormalFloat:CompeDocumentation,FloatBorder:CompeDocumentationBorder", + max_width = 120, + min_width = 60, + max_height = math.floor(vim.o.lines * 0.3), + min_height = 1, }, -- documentation = true, -- cgit v1.2.3 From 0e05f05e9d584eec3764593a53eeeff2272718a0 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 1 Aug 2021 15:13:56 -0400 Subject: respect override table --- lua/lsp/init.lua | 9 +++++++++ lua/utils/init.lua | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'lua') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 13b64dac..03efbd00 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -73,6 +73,15 @@ function M.setup(lang) return end + local overrides = lvim.lsp.override + + if type(overrides) == "table" then + if u.has_value(overrides, lang) then + return + end + end + + local lspconfig = require "lspconfig" lspconfig[lsp.provider].setup(lsp.setup) end diff --git a/lua/utils/init.lua b/lua/utils/init.lua index b81ff4f4..9f0064e1 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -42,6 +42,15 @@ local function r_inspect_settings(structure, limit, separator) return limit - 1 end +function utils.has_value(tab, val) + for _, value in ipairs(tab) do + if value == val then + return true + end + end + return false +end + function utils.generate_settings() -- Opens a file in append mode local file = io.open("lv-settings.lua", "w") -- cgit v1.2.3 From 8e26c44ffd5eda651d2e22b9f8f99e632e8e64e9 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Sun, 1 Aug 2021 15:45:49 -0400 Subject: haskell support --- lua/default-config.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 739612af..35c5e06f 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -498,6 +498,22 @@ lvim.lang = { }, }, }, + haskell = { + formatters = { { + exe = "", + args = {}, + } }, + linters = {}, + lsp = { + provider = "hls", + setup = { + cmd = {DATA_PATH .. "/lspinstall/haskell/haskell-language-server-wrapper", "--lsp" }, + on_attach = common_on_attach, + on_init = common_on_init, + capabilities = common_capabilities, + }, + }, + }, html = { formatters = { { -- cgit v1.2.3 From 611f502104d17567654f1a6d747cf728163746ce Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Sun, 1 Aug 2021 16:07:47 -0400 Subject: use hls --- lua/default-config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 35c5e06f..bf09a1f6 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -507,7 +507,7 @@ lvim.lang = { lsp = { provider = "hls", setup = { - cmd = {DATA_PATH .. "/lspinstall/haskell/haskell-language-server-wrapper", "--lsp" }, + cmd = {DATA_PATH .. "/lspinstall/haskell/hls" }, on_attach = common_on_attach, on_init = common_on_init, capabilities = common_capabilities, -- cgit v1.2.3 From fbbf1b22a4ab48e19a33a5b10322253ebbca7b8f Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Mon, 2 Aug 2021 01:21:53 +0430 Subject: fix the formatting :pepehands: (#1208) --- lua/default-config.lua | 2 +- lua/lsp/init.lua | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index bf09a1f6..3bf6d97b 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -507,7 +507,7 @@ lvim.lang = { lsp = { provider = "hls", setup = { - cmd = {DATA_PATH .. "/lspinstall/haskell/hls" }, + cmd = { DATA_PATH .. "/lspinstall/haskell/hls" }, on_attach = common_on_attach, on_init = common_on_init, capabilities = common_capabilities, diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 03efbd00..3373ac46 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -81,7 +81,6 @@ function M.setup(lang) end end - local lspconfig = require "lspconfig" lspconfig[lsp.provider].setup(lsp.setup) end -- cgit v1.2.3 From 94fda1e939f493024a10f5e12ab1609ba178f1e6 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 1 Aug 2021 18:14:39 -0400 Subject: no more default stylua --- lua/default-config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index bf09a1f6..e008f93c 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -657,7 +657,7 @@ lvim.lang = { formatters = { { -- @usage can be stylua or lua_format - exe = "stylua", + exe = "", args = {}, }, }, -- cgit v1.2.3 From d5557f56c808f75f58c4d42e300e9a0a6baa43c1 Mon Sep 17 00:00:00 2001 From: Luc Sinet Date: Mon, 2 Aug 2021 08:05:46 +0200 Subject: Make keymaps of bufferline and compe configurable (#1205) --- lua/core/bufferline.lua | 18 ++++++++++++++++-- lua/core/compe.lua | 29 ++++++++++++++++++----------- 2 files changed, 34 insertions(+), 13 deletions(-) (limited to 'lua') diff --git a/lua/core/bufferline.lua b/lua/core/bufferline.lua index c5677580..1957226e 100644 --- a/lua/core/bufferline.lua +++ b/lua/core/bufferline.lua @@ -1,2 +1,16 @@ -vim.api.nvim_set_keymap("n", "", ":BufferNext", { noremap = true, silent = true }) -vim.api.nvim_set_keymap("n", "", ":BufferPrevious", { noremap = true, silent = true }) +lvim.builtin.bufferline = { + keymap = { + values = { + normal_mode = { + { "", ":BufferNext" }, + { "", ":BufferPrevious" }, + }, + }, + opts = { + normal_mode = { noremap = true, silent = true }, + }, + }, +} + +local keymap = require "utils.keymap" +keymap.load(lvim.builtin.bufferline.keymap.values, lvim.builtin.bufferline.keymap.opts) diff --git a/lua/core/compe.lua b/lua/core/compe.lua index 155c7874..e18147fc 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -38,6 +38,22 @@ M.config = function() emoji = { kind = " ﲃ (Emoji)", filetypes = { "markdown", "text" } }, -- for emoji press : (idk if that in compe tho) }, + + keymap = { + values = { + insert_mode = { + { "", 'pumvisible() ? "" : ""' }, + { "", 'pumvisible() ? "" : ""' }, + { "", "compe#complete()" }, + { "", "compe#close('')" }, + { "", "compe#scroll({ 'delta': +4 })" }, + { "", "compe#scroll({ 'delta': -4 })" }, + }, + }, + opts = { + insert_mode = { noremap = true, silent = true, expr = true }, + }, + }, } end @@ -64,12 +80,6 @@ M.setup = function() end end - local remap = vim.api.nvim_set_keymap - - remap("i", "", 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true }) - - remap("i", "", 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true }) - -- Use (s-)tab to: --- move to prev/next item in completion menuone --- jump to prev/next snippet's placeholder @@ -95,11 +105,8 @@ M.setup = function() end end - vim.api.nvim_set_keymap("i", "", "compe#complete()", { noremap = true, silent = true, expr = true }) - -- vim.api.nvim_set_keymap("i", "", "compe#confirm('')", { noremap = true, silent = true, expr = true }) - vim.api.nvim_set_keymap("i", "", "compe#close('')", { noremap = true, silent = true, expr = true }) - vim.api.nvim_set_keymap("i", "", "compe#scroll({ 'delta': +4 })", { noremap = true, silent = true, expr = true }) - vim.api.nvim_set_keymap("i", "", "compe#scroll({ 'delta': -4 })", { noremap = true, silent = true, expr = true }) + local keymap = require "utils.keymap" + keymap.load(lvim.builtin.compe.keymap.values, lvim.builtin.compe.keymap.opts) end return M -- cgit v1.2.3 From 8e88bf52587c99d1070258f03500cbbdb9b1420c Mon Sep 17 00:00:00 2001 From: Gauravsingh Sisodia <65955464+grvxs@users.noreply.github.com> Date: Mon, 2 Aug 2021 16:26:03 +0530 Subject: fix: comment typo (#1211) --- lua/core/autocmds.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index d9884073..62c05802 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -63,7 +63,7 @@ lvim.autocommands = { { "VimResized", "*", "wincmd =" }, }, _packer_compile = { - -- will cause split windows to be resized evenly if main window is resized + -- will run PackerCompile after writing plugins.lua { "BufWritePost", "plugins.lua", "PackerCompile" }, }, _general_lsp = { -- cgit v1.2.3 From 6d14d7b5da54fffabfec18b2b09a488d3661d7f9 Mon Sep 17 00:00:00 2001 From: Luc Sinet Date: Mon, 2 Aug 2021 17:19:44 +0200 Subject: [Refactor] Adopt which key mapping style (#1210) * Refactor keymappings to match which-key style * Update confif example + remove redundant way of registering mappings --- lua/core/bufferline.lua | 4 +-- lua/core/compe.lua | 12 +++---- lua/keymappings.lua | 92 ++++++++++++++++++++++++------------------------- lua/utils/keymap.lua | 4 +-- 4 files changed, 56 insertions(+), 56 deletions(-) (limited to 'lua') diff --git a/lua/core/bufferline.lua b/lua/core/bufferline.lua index 1957226e..35831d03 100644 --- a/lua/core/bufferline.lua +++ b/lua/core/bufferline.lua @@ -2,8 +2,8 @@ lvim.builtin.bufferline = { keymap = { values = { normal_mode = { - { "", ":BufferNext" }, - { "", ":BufferPrevious" }, + [""] = { ":BufferNext" }, + [""] = { ":BufferPrevious" }, }, }, opts = { diff --git a/lua/core/compe.lua b/lua/core/compe.lua index e18147fc..5f1632f9 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -42,12 +42,12 @@ M.config = function() keymap = { values = { insert_mode = { - { "", 'pumvisible() ? "" : ""' }, - { "", 'pumvisible() ? "" : ""' }, - { "", "compe#complete()" }, - { "", "compe#close('')" }, - { "", "compe#scroll({ 'delta': +4 })" }, - { "", "compe#scroll({ 'delta': -4 })" }, + [""] = { 'pumvisible() ? "" : ""' }, + [""] = { 'pumvisible() ? "" : ""' }, + [""] = { "compe#complete()" }, + [""] = { "compe#close('')" }, + [""] = { "compe#scroll({ 'delta': +4 })" }, + [""] = { "compe#scroll({ 'delta': -4 })" }, }, }, opts = { diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 937a5e8b..9ef37a39 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -9,72 +9,72 @@ local opts = { local keymaps = { insert_mode = { -- I hate escape - { "jk", "" }, - { "kj", "" }, - { "jj", "" }, + ["jk"] = { "" }, + ["kj"] = { "" }, + ["jj"] = { "" }, -- Move current line / block with Alt-j/k ala vscode. - { "", ":m .+1==gi" }, - { "", ":m .-2==gi" }, + [""] = { ":m .+1==gi" }, + [""] = { ":m .-2==gi" }, -- navigation - { "", "k" }, - { "", "j" }, - { "", "h" }, - { "", "l" }, + [""] = { "k" }, + [""] = { "j" }, + [""] = { "h" }, + [""] = { "l" }, }, normal_mode = { -- Better window movement - { "", "h" }, - { "", "j" }, - { "", "k" }, - { "", "l" }, + [""] = { "h" }, + [""] = { "j" }, + [""] = { "k" }, + [""] = { "l" }, -- Resize with arrows - { "", ":resize -2" }, - { "", ":resize +2" }, - { "", ":vertical resize -2" }, - { "", ":vertical resize +2" }, + [""] = { ":resize -2" }, + [""] = { ":resize +2" }, + [""] = { ":vertical resize -2" }, + [""] = { ":vertical resize +2" }, -- Tab switch buffer -- { "", ":bnext" }, -- { "", ":bprevious" }, -- Move current line / block with Alt-j/k a la vscode. - { "", ":m .+1==" }, - { "", ":m .-2==" }, + [""] = { ":m .+1==" }, + [""] = { ":m .-2==" }, -- QuickFix - { "]q", ":cnext" }, - { "[q", ":cprev" }, - { "", ":call QuickFixToggle()" }, + ["]q"] = { ":cnext" }, + ["[q"] = { ":cprev" }, + [""] = { ":call QuickFixToggle()" }, -- {'', 'compe#complete()', {noremap = true, silent = true, expr = true}}, -- LSP - { "gd", "lua vim.lsp.buf.definition()" }, - { "gD", "lua vim.lsp.buf.declaration()" }, - { "gr", "lua vim.lsp.buf.references()" }, - { "gi", "lua vim.lsp.buf.implementation()" }, - { "gl", "lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })" }, - { "gs", "lua vim.lsp.buf.signature_help()" }, - { "gp", "lua require'lsp.peek'.Peek('definition')" }, - { "K", "lua vim.lsp.buf.hover()" }, - { "", "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" }, - { "", "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" }, + ["gd"] = { "lua vim.lsp.buf.definition()" }, + ["gD"] = { "lua vim.lsp.buf.declaration()" }, + ["gr"] = { "lua vim.lsp.buf.references()" }, + ["gi"] = { "lua vim.lsp.buf.implementation()" }, + ["gl"] = { "lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })" }, + ["gs"] = { "lua vim.lsp.buf.signature_help()" }, + ["gp"] = { "lua require'lsp.peek'.Peek('definition')" }, + ["K"] = { "lua vim.lsp.buf.hover()" }, + [""] = { "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" }, + [""] = { "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" }, }, term_mode = { -- Terminal window navigation - { "", "h" }, - { "", "j" }, - { "", "k" }, - { "", "l" }, + [""] = { "h" }, + [""] = { "j" }, + [""] = { "k" }, + [""] = { "l" }, }, visual_mode = { -- Better indenting - { "<", "", ">gv" }, + ["<"] = { ""] = { ">gv" }, -- { "p", '"0p', { silent = true } }, -- { "P", '"0P', { silent = true } }, @@ -82,21 +82,21 @@ local keymaps = { visual_block_mode = { -- Move selected line / block of text in visual mode - { "K", ":move '<-2gv-gv" }, - { "J", ":move '>+1gv-gv" }, + ["K"] = { ":move '<-2gv-gv" }, + ["J"] = { ":move '>+1gv-gv" }, -- Move current line / block with Alt-j/k ala vscode. - { "", ":m '>+1gv-gv" }, - { "", ":m '<-2gv-gv" }, + [""] = { ":m '>+1gv-gv" }, + [""] = { ":m '<-2gv-gv" }, }, } if vim.fn.has "mac" == 1 then -- TODO: fix this - keymaps.normal_mode[5][1] = "" - keymaps.normal_mode[6][1] = "" - keymaps.normal_mode[7][1] = "" - keymaps.normal_mode[8][1] = "" + keymaps.normal_mode[""] = keymaps.normal_mode[""] + keymaps.normal_mode[""] = keymaps.normal_mode[""] + keymaps.normal_mode[""] = keymaps.normal_mode[""] + keymaps.normal_mode[""] = keymaps.normal_mode[""] end vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader diff --git a/lua/utils/keymap.lua b/lua/utils/keymap.lua index 121a4888..1799e21f 100644 --- a/lua/utils/keymap.lua +++ b/lua/utils/keymap.lua @@ -14,8 +14,8 @@ local mode_adapters = { -- @param opts The mapping options M.load_mode = function(mode, keymaps, opts) mode = mode_adapters[mode] and mode_adapters[mode] or mode - for _, keymap in ipairs(keymaps) do - vim.api.nvim_set_keymap(mode, keymap[1], keymap[2], opts) + for key, mapping in pairs(keymaps) do + vim.api.nvim_set_keymap(mode, key, mapping[1], opts) end end -- cgit v1.2.3 From e0f0c81ea6f595139cd4f55fbdcf9e22d9a84727 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 2 Aug 2021 15:04:10 -0400 Subject: less needs something defined for formatters and linters --- lua/default-config.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 9d1bb44e..e7d0bfa7 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -301,6 +301,29 @@ lvim.lang = { }, }, }, + less = { + formatters = { + { + -- @usage can be prettier or prettierd + exe = "", + args = {}, + }, + }, + linters = {}, + lsp = { + provider = "cssls", + setup = { + cmd = { + "node", + DATA_PATH .. "/lspinstall/css/vscode-css/css-language-features/server/dist/node/cssServerMain.js", + "--stdio", + }, + on_attach = common_on_attach, + on_init = common_on_init, + capabilities = common_capabilities, + }, + }, + }, d = { formatters = { { -- cgit v1.2.3 From 77e283bd9c33166937756250918b12e349caf050 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 2 Aug 2021 23:42:56 +0200 Subject: [Refactor] Allow editing default keymaps (#1213) --- lua/core/bufferline.lua | 15 +-- lua/core/compe.lua | 14 +-- lua/core/which-key.lua | 4 + lua/default-config.lua | 1 + lua/keymappings.lua | 252 ++++++++++++++++++++++++++++-------------------- lua/lsp/init.lua | 19 ++++ lua/utils/init.lua | 1 + 7 files changed, 187 insertions(+), 119 deletions(-) (limited to 'lua') diff --git a/lua/core/bufferline.lua b/lua/core/bufferline.lua index 35831d03..68030c81 100644 --- a/lua/core/bufferline.lua +++ b/lua/core/bufferline.lua @@ -1,16 +1,11 @@ lvim.builtin.bufferline = { keymap = { - values = { - normal_mode = { - [""] = { ":BufferNext" }, - [""] = { ":BufferPrevious" }, - }, - }, - opts = { - normal_mode = { noremap = true, silent = true }, + normal_mode = { + [""] = ":BufferNext", + [""] = ":BufferPrevious", }, }, } -local keymap = require "utils.keymap" -keymap.load(lvim.builtin.bufferline.keymap.values, lvim.builtin.bufferline.keymap.opts) +local keymap = require "keymappings" +keymap.append_to_defaults(lvim.builtin.bufferline.keymap) diff --git a/lua/core/compe.lua b/lua/core/compe.lua index 5f1632f9..2d183683 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -42,12 +42,12 @@ M.config = function() keymap = { values = { insert_mode = { - [""] = { 'pumvisible() ? "" : ""' }, - [""] = { 'pumvisible() ? "" : ""' }, - [""] = { "compe#complete()" }, - [""] = { "compe#close('')" }, - [""] = { "compe#scroll({ 'delta': +4 })" }, - [""] = { "compe#scroll({ 'delta': -4 })" }, + [""] = 'pumvisible() ? "" : ""', + [""] = 'pumvisible() ? "" : ""', + [""] = "compe#complete()", + [""] = "compe#close('')", + [""] = "compe#scroll({ 'delta': +4 })", + [""] = "compe#scroll({ 'delta': -4 })", }, }, opts = { @@ -105,7 +105,7 @@ M.setup = function() end end - local keymap = require "utils.keymap" + local keymap = require "keymappings" keymap.load(lvim.builtin.compe.keymap.values, lvim.builtin.compe.keymap.opts) end diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 17995e87..eab9266a 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -166,6 +166,10 @@ M.config = function() "Workspace Symbols", }, }, + L = { + name = "+LunarVim", + k = { "lua require('keymappings').print()", "View LunarVim's default keymappings" }, + }, s = { name = "Search", diff --git a/lua/default-config.lua b/lua/default-config.lua index e7d0bfa7..7563d36d 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -1237,6 +1237,7 @@ lvim.lang = { }, } +require("keymappings").config() require("core.which-key").config() require "core.status_colors" require("core.gitsigns").config() diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 9ef37a39..038ebed4 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,109 +1,157 @@ -local opts = { - insert_mode = { noremap = true, silent = true }, - normal_mode = { noremap = true, silent = true }, - visual_mode = { noremap = true, silent = true }, - visual_block_mode = { noremap = true, silent = true }, - term_mode = { silent = true }, -} +local M = {} + +local generic_opts_any = { noremap = true, silent = true } -local keymaps = { - insert_mode = { - -- I hate escape - ["jk"] = { "" }, - ["kj"] = { "" }, - ["jj"] = { "" }, - -- Move current line / block with Alt-j/k ala vscode. - [""] = { ":m .+1==gi" }, - [""] = { ":m .-2==gi" }, - -- navigation - [""] = { "k" }, - [""] = { "j" }, - [""] = { "h" }, - [""] = { "l" }, - }, - - normal_mode = { - -- Better window movement - [""] = { "h" }, - [""] = { "j" }, - [""] = { "k" }, - [""] = { "l" }, - - -- Resize with arrows - [""] = { ":resize -2" }, - [""] = { ":resize +2" }, - [""] = { ":vertical resize -2" }, - [""] = { ":vertical resize +2" }, - - -- Tab switch buffer - -- { "", ":bnext" }, - -- { "", ":bprevious" }, - - -- Move current line / block with Alt-j/k a la vscode. - [""] = { ":m .+1==" }, - [""] = { ":m .-2==" }, - - -- QuickFix - ["]q"] = { ":cnext" }, - ["[q"] = { ":cprev" }, - [""] = { ":call QuickFixToggle()" }, - - -- {'', 'compe#complete()', {noremap = true, silent = true, expr = true}}, - - -- LSP - ["gd"] = { "lua vim.lsp.buf.definition()" }, - ["gD"] = { "lua vim.lsp.buf.declaration()" }, - ["gr"] = { "lua vim.lsp.buf.references()" }, - ["gi"] = { "lua vim.lsp.buf.implementation()" }, - ["gl"] = { "lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })" }, - ["gs"] = { "lua vim.lsp.buf.signature_help()" }, - ["gp"] = { "lua require'lsp.peek'.Peek('definition')" }, - ["K"] = { "lua vim.lsp.buf.hover()" }, - [""] = { "lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})" }, - [""] = { "lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})" }, - }, - - term_mode = { - -- Terminal window navigation - [""] = { "h" }, - [""] = { "j" }, - [""] = { "k" }, - [""] = { "l" }, - }, - - visual_mode = { - -- Better indenting - ["<"] = { ""] = { ">gv" }, - - -- { "p", '"0p', { silent = true } }, - -- { "P", '"0P', { silent = true } }, - }, - - visual_block_mode = { - -- Move selected line / block of text in visual mode - ["K"] = { ":move '<-2gv-gv" }, - ["J"] = { ":move '>+1gv-gv" }, - - -- Move current line / block with Alt-j/k ala vscode. - [""] = { ":m '>+1gv-gv" }, - [""] = { ":m '<-2gv-gv" }, - }, +local mode_adapters = { + insert_mode = "i", + normal_mode = "n", + term_mode = "t", + visual_mode = "v", + visual_block_mode = "x", } -if vim.fn.has "mac" == 1 then - -- TODO: fix this - keymaps.normal_mode[""] = keymaps.normal_mode[""] - keymaps.normal_mode[""] = keymaps.normal_mode[""] - keymaps.normal_mode[""] = keymaps.normal_mode[""] - keymaps.normal_mode[""] = keymaps.normal_mode[""] +-- Append key mappings to lunarvim's defaults for a given mode +-- @param keymaps The table of key mappings containing a list per mode (normal_mode, insert_mode, ..) +function M.append_to_defaults(keymaps) + for mode, mappings in pairs(keymaps) do + for k, v in ipairs(mappings) do + lvim.keys[mode][k] = v + end + end +end + +-- Load key mappings for a given mode +-- @param mode The keymap mode, can be one of the keys of mode_adapters +-- @param keymaps The list of key mappings +-- @param opts The mapping options +function M.load_mode(mode, keymaps, opts) + mode = mode_adapters[mode] and mode_adapters[mode] or mode + for k, v in pairs(keymaps) do + vim.api.nvim_set_keymap(mode, k, v, opts) + end +end + +-- Load key mappings for all provided modes +-- @param keymaps A list of key mappings for each mode +-- @param opts The mapping options for each mode +function M.load(keymaps, opts) + for mode, mapping in pairs(keymaps) do + M.load_mode(mode, mapping, opts[mode]) + end end -vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader +function M.config() + lvim.keys = { + ---@usage change or add keymappings for insert mode + insert_mode = { + -- 'jk' for quitting insert mode + ["jk"] = "", + -- 'kj' for quitting insert mode + ["kj"] = "", + -- 'jj' for quitting insert mode + ["jj"] = "", + -- Move current line / block with Alt-j/k ala vscode. + [""] = ":m .+1==gi", + -- Move current line / block with Alt-j/k ala vscode. + [""] = ":m .-2==gi", + -- navigation + [""] = "k", + [""] = "j", + [""] = "h", + [""] = "l", + }, + + ---@usage change or add keymappings for normal mode + normal_mode = { + -- Better window movement + [""] = "h", + [""] = "j", + [""] = "k", + [""] = "l", + + -- Resize with arrows + [""] = ":resize -2", + [""] = ":resize +2", + [""] = ":vertical resize -2", + [""] = ":vertical resize +2", + + -- Tab switch buffer + [""] = ":BufferNext", + [""] = ":BufferPrevious", + + -- Move current line / block with Alt-j/k a la vscode. + [""] = ":m .+1==", + [""] = ":m .-2==", + + -- QuickFix + ["]q"] = ":cnext", + ["[q"] = ":cprev", + [""] = ":call QuickFixToggle()", + }, + + ---@usage change or add keymappings for terminal mode + term_mode = { + -- Terminal window navigation + [""] = "h", + [""] = "j", + [""] = "k", + [""] = "l", + }, + + ---@usage change or add keymappings for visual mode + visual_mode = { + -- Better indenting + ["<"] = ""] = ">gv", + + -- ["p"] = '"0p', + -- ["P"] = '"0P', + }, + + ---@usage change or add keymappings for visual block mode + visual_block_mode = { + -- Move selected line / block of text in visual mode + ["K"] = ":move '<-2gv-gv", + ["J"] = ":move '>+1gv-gv", + + -- Move current line / block with Alt-j/k ala vscode. + [""] = ":m '>+1gv-gv", + [""] = ":m '<-2gv-gv", + }, + } + + if vim.fn.has "mac" == 1 then + lvim.keys.normal_mode[""] = lvim.keys.normal_mode[""] + lvim.keys.normal_mode[""] = lvim.keys.normal_mode[""] + lvim.keys.normal_mode[""] = lvim.keys.normal_mode[""] + lvim.keys.normal_mode[""] = lvim.keys.normal_mode[""] + end +end --- navigate tab completion with and --- runs conditionally -vim.cmd 'inoremap pumvisible() ? "\\" : "\\"' -vim.cmd 'inoremap pumvisible() ? "\\" : "\\"' +function M.print(mode) + print "List of LunarVim's default keymappings (not including which-key)" + if mode then + print(vim.inspect(lvim.keys[mode])) + else + print(vim.inspect(lvim.keys)) + end +end + +function M.setup() + -- navigate tab completion with and + -- runs conditionally + vim.cmd 'inoremap pumvisible() ? "\\" : "\\"' + vim.cmd 'inoremap pumvisible() ? "\\" : "\\"' + local generic_opts = { + insert_mode = generic_opts_any, + normal_mode = generic_opts_any, + visual_mode = generic_opts_any, + visual_block_mode = generic_opts_any, + term_mode = { silent = true }, + } + + vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader + M.load(lvim.keys, generic_opts) +end -return { keymaps = keymaps, opts = opts } +return M diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 3373ac46..b85dfcd2 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -33,6 +33,24 @@ local function lsp_highlight_document(client) end end +local function add_lsp_buffer_keybindings(bufnr) + local wk = require "which-key" + local keys = { + ["K"] = { "lua vim.lsp.buf.hover()", "Show hover" }, + ["gd"] = { "lua vim.lsp.buf.definition()", "Goto Definition" }, + ["gD"] = { "lua vim.lsp.buf.declaration()", "Goto declaration" }, + ["gr"] = { "lua vim.lsp.buf.references()", "Goto references" }, + ["gi"] = { "lua vim.lsp.buf.implementation()", "Goto implementation" }, + ["gs"] = { "lua vim.lsp.buf.signature_help()", "show signature help" }, + ["gp"] = { "lua require'lsp.peek'.Peek('definition')", "Peek definition" }, + ["gl"] = { + "lua vim.lsp.diagnostic.show_line_diagnostics({ show_header = false, border = 'single' })", + "Show line diagnostics", + }, + } + wk.register(keys, { mode = "n", buffer = bufnr }) +end + function M.common_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true @@ -64,6 +82,7 @@ function M.common_on_attach(client, bufnr) lvim.lsp.on_attach_callback(client, bufnr) end lsp_highlight_document(client) + add_lsp_buffer_keybindings(bufnr) require("lsp.null-ls").setup(vim.bo.filetype) end diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 9f0064e1..9c9b8523 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -98,6 +98,7 @@ function utils.reload_lv_config() plugin_loader:load { plugins, lvim.plugins } vim.cmd ":PackerCompile" vim.cmd ":PackerInstall" + require("keymappings").setup() -- vim.cmd ":PackerClean" end -- cgit v1.2.3 From fc018cdc4735e3ba3e456a153ab672c8eb4df043 Mon Sep 17 00:00:00 2001 From: Will Leinweber Date: Mon, 2 Aug 2021 21:51:32 -0700 Subject: Fix lsp reporting when v.source is nil (#1209) --- lua/lsp/handlers.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/lsp/handlers.lua b/lua/lsp/handlers.lua index 849d2a03..2322e76a 100644 --- a/lua/lsp/handlers.lua +++ b/lua/lsp/handlers.lua @@ -28,10 +28,14 @@ function M.setup() for i, v in ipairs(diagnostics) do local source = v.source - if string.find(v.source, "/") then - source = string.sub(v.source, string.find(v.source, "([%w-_]+)$")) + if source then + if string.find(source, "/") then + source = string.sub(v.source, string.find(v.source, "([%w-_]+)$")) + end + diagnostics[i].message = string.format("%s: %s", source, v.message) + else + diagnostics[i].message = string.format("%s", v.message) end - diagnostics[i].message = string.format("%s: %s", source, v.message) if vim.tbl_contains(vim.tbl_keys(v), "code") then diagnostics[i].message = diagnostics[i].message .. string.format(" [%s]", v.code) -- cgit v1.2.3 From dc3b47b7e7d015a8f47c5dae5d50e4d50f9e1cfb Mon Sep 17 00:00:00 2001 From: William Goulois <37271970+williamgoulois@users.noreply.github.com> Date: Tue, 3 Aug 2021 06:54:57 +0200 Subject: [Feature]: Add possibility to focus nvimtree instead of toggle (#1074) --- lua/core/nvimtree.lua | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index dd1f4f36..4e3c0ef6 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -3,6 +3,7 @@ local M = {} M.config = function() lvim.builtin.nvimtree = { side = "left", + width = 30, show_icons = { git = 1, folders = 1, @@ -65,6 +66,35 @@ M.setup = function() } end -- +M.focus_or_close = function() + local view_status_ok, view = pcall(require, "nvim-tree.view") + if not view_status_ok then + return + end + local a = vim.api + + local curwin = a.nvim_get_current_win() + local curbuf = a.nvim_win_get_buf(curwin) + local bufnr = view.View.bufnr + local winnr = view.get_winnr() + + if view.win_open() then + if curwin == winnr and curbuf == bufnr then + view.close() + if package.loaded["bufferline.state"] then + require("bufferline.state").set_offset(0) + end + else + view.focus() + end + else + view.open() + if package.loaded["bufferline.state"] and lvim.builtin.nvimtree.side == "left" then + -- require'bufferline.state'.set_offset(lvim.builtin.nvimtree.width + 1, 'File Explorer') + require("bufferline.state").set_offset(lvim.builtin.nvimtree.width + 1, "") + end + end +end -- M.toggle_tree = function() local view_status_ok, view = pcall(require, "nvim-tree.view") @@ -78,8 +108,8 @@ M.toggle_tree = function() end else if package.loaded["bufferline.state"] and lvim.builtin.nvimtree.side == "left" then - -- require'bufferline.state'.set_offset(31, 'File Explorer') - require("bufferline.state").set_offset(31, "") + -- require'bufferline.state'.set_offset(lvim.builtin.nvimtree.width + 1, 'File Explorer') + require("bufferline.state").set_offset(lvim.builtin.nvimtree.width + 1, "") end require("nvim-tree").toggle() end -- cgit v1.2.3 From 21419b244c40350ee09ef3a5cf6b1ad19054b23f Mon Sep 17 00:00:00 2001 From: Dery Rahman Ahaddienata Date: Tue, 3 Aug 2021 12:04:51 +0700 Subject: Keymapping custom opts (#1215) --- lua/keymappings.lua | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'lua') diff --git a/lua/keymappings.lua b/lua/keymappings.lua index 038ebed4..d14bedad 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -2,6 +2,14 @@ local M = {} local generic_opts_any = { noremap = true, silent = true } +local generic_opts = { + insert_mode = generic_opts_any, + normal_mode = generic_opts_any, + visual_mode = generic_opts_any, + visual_block_mode = generic_opts_any, + term_mode = { silent = true }, +} + local mode_adapters = { insert_mode = "i", normal_mode = "n", @@ -20,23 +28,34 @@ function M.append_to_defaults(keymaps) end end +-- Set key mappings individually +-- @param mode The keymap mode, can be one of the keys of mode_adapters +-- @param key The key of keymap +-- @param val Can be form as a mapping or tuple of mapping and user defined opt +function M.set_keymaps(mode, key, val) + local opt = generic_opts[mode] and generic_opts[mode] or generic_opts_any + if type(val) == "table" then + opt = val[2] + val = val[1] + end + vim.api.nvim_set_keymap(mode, key, val, opt) +end + -- Load key mappings for a given mode -- @param mode The keymap mode, can be one of the keys of mode_adapters -- @param keymaps The list of key mappings --- @param opts The mapping options -function M.load_mode(mode, keymaps, opts) +function M.load_mode(mode, keymaps) mode = mode_adapters[mode] and mode_adapters[mode] or mode for k, v in pairs(keymaps) do - vim.api.nvim_set_keymap(mode, k, v, opts) + M.set_keymaps(mode, k, v) end end -- Load key mappings for all provided modes -- @param keymaps A list of key mappings for each mode --- @param opts The mapping options for each mode -function M.load(keymaps, opts) +function M.load(keymaps) for mode, mapping in pairs(keymaps) do - M.load_mode(mode, mapping, opts[mode]) + M.load_mode(mode, mapping) end end @@ -59,6 +78,10 @@ function M.config() [""] = "j", [""] = "h", [""] = "l", + -- navigate tab completion with and + -- runs conditionally + [""] = { 'pumvisible() ? "\\" : "\\"', { expr = true, noremap = true } }, + [""] = { 'pumvisible() ? "\\" : "\\"', { expr = true, noremap = true } }, }, ---@usage change or add keymappings for normal mode @@ -138,20 +161,8 @@ function M.print(mode) end function M.setup() - -- navigate tab completion with and - -- runs conditionally - vim.cmd 'inoremap pumvisible() ? "\\" : "\\"' - vim.cmd 'inoremap pumvisible() ? "\\" : "\\"' - local generic_opts = { - insert_mode = generic_opts_any, - normal_mode = generic_opts_any, - visual_mode = generic_opts_any, - visual_block_mode = generic_opts_any, - term_mode = { silent = true }, - } - vim.g.mapleader = (lvim.leader == "space" and " ") or lvim.leader - M.load(lvim.keys, generic_opts) + M.load(lvim.keys) end return M -- cgit v1.2.3 From c0a653a0cf5ef1842b086149b9e79a79cc62583d Mon Sep 17 00:00:00 2001 From: tafryn Date: Mon, 2 Aug 2021 22:43:57 -0700 Subject: Allow user's to define their own nvim-tree bindings (#1181) --- lua/core/nvimtree.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lua') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index 4e3c0ef6..e29168e9 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -59,11 +59,13 @@ M.setup = function() local tree_cb = nvim_tree_config.nvim_tree_callback - g.nvim_tree_bindings = { - { key = { "l", "", "o" }, cb = tree_cb "edit" }, - { key = "h", cb = tree_cb "close_node" }, - { key = "v", cb = tree_cb "vsplit" }, - } + if not g.nvim_tree_bindings then + g.nvim_tree_bindings = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + } + end end -- M.focus_or_close = function() -- cgit v1.2.3 From b608b08ff3a5f28e7c57bc7bd7a30cfe2ab5c111 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Tue, 3 Aug 2021 12:54:23 +0430 Subject: fix compe tab completion issue (#1217) --- lua/core/compe.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lua') diff --git a/lua/core/compe.lua b/lua/core/compe.lua index 2d183683..e8cb857d 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -42,12 +42,12 @@ M.config = function() keymap = { values = { insert_mode = { - [""] = 'pumvisible() ? "" : ""', - [""] = 'pumvisible() ? "" : ""', - [""] = "compe#complete()", - [""] = "compe#close('')", - [""] = "compe#scroll({ 'delta': +4 })", - [""] = "compe#scroll({ 'delta': -4 })", + [""] = { 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true } }, + [""] = { 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true } }, + [""] = { "compe#complete()", { silent = true, noremap = true, expr = true } }, + [""] = { "compe#close('')", { silent = true, noremap = true, expr = true } }, + [""] = { "compe#scroll({ 'delta': +4 })", { silent = true, noremap = true, expr = true } }, + [""] = { "compe#scroll({ 'delta': -4 })", { silent = true, noremap = true, expr = true } }, }, }, opts = { -- cgit v1.2.3 From 4c3c3f388557a182794bffdbf923129c66af885a Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 3 Aug 2021 18:10:54 +0200 Subject: feat: add lvim.lsp.smart_cwd (#1218) - Enable querying the language-server for the `root_dir` - Use `root_dir` to set the current working-directory (CWD) - Make vim-rooter configurable and add an option to disable it Inspired by "ahmedkhalf/lsp-rooter.nvim" --- lua/core/nvimtree.lua | 6 ++++++ lua/core/rooter.lua | 15 +++++++++++++++ lua/default-config.lua | 3 +++ lua/lsp/init.lua | 4 ++++ lua/lsp/null-ls.lua | 10 +++++++--- lua/plugins.lua | 4 +++- lua/utils/init.lua | 10 ++++++++++ 7 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 lua/core/rooter.lua (limited to 'lua') diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index e29168e9..1a0de0b8 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -117,4 +117,10 @@ M.toggle_tree = function() end end -- +function M.change_tree_dir(dir) + if vim.g.loaded_tree then + require("nvim-tree.lib").change_dir(dir) + end +end +-- return M diff --git a/lua/core/rooter.lua b/lua/core/rooter.lua new file mode 100644 index 00000000..8ebdf7cc --- /dev/null +++ b/lua/core/rooter.lua @@ -0,0 +1,15 @@ +local M = {} +function M.config() + lvim.builtin.rooter = { + --- This is on by default since it's currently the expected behavior. + ---@usage set to false to disable vim-rooter. + active = true, + silent_chdir = 1, + manual_only = 0, + } +end +function M.setup() + vim.g.rooter_silent_chdir = lvim.builtin.rooter.silent_chdir + vim.g.rooter_manual_only = lvim.builtin.rooter.manual_only +end +return M diff --git a/lua/default-config.lua b/lua/default-config.lua index 7563d36d..53aff8c9 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -85,6 +85,8 @@ lvim = { popup_border = "single", on_attach_callback = nil, on_init_callback = nil, + ---@usage query the project directory from the language server and use it to set the CWD + smart_cwd = true, }, plugins = { @@ -1248,3 +1250,4 @@ require("core.terminal").config() require("core.telescope").config() require("core.treesitter").config() require("core.nvimtree").config() +require("core.rooter").config() diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index b85dfcd2..66efdafc 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -83,6 +83,10 @@ function M.common_on_attach(client, bufnr) end lsp_highlight_document(client) add_lsp_buffer_keybindings(bufnr) + if lvim.lsp.smart_cwd then + vim.api.nvim_set_current_dir(client.config.root_dir) + require("core.nvimtree").change_tree_dir(client.config.root_dir) + end require("lsp.null-ls").setup(vim.bo.filetype) end diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 51fab00b..d3f7931b 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -24,10 +24,14 @@ function M.get_registered_providers_by_filetype(ft) end local function validate_nodejs_provider(requests, provider) - vim.cmd "let root_dir = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "root_dir" + local ts_client = require("utils").get_active_client_by_ft "typescript" + if ts_client == nil then + u.lvim_log "Unable to determine root directory since tsserver didn't start correctly" + return + end + local root_dir = ts_client.config.root_dir local local_nodejs_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command - u.lvim_log(string.format("checking for local node module: [%s]", vim.inspect(provider))) + u.lvim_log(string.format("checking [%s] for local node module: [%s]", local_nodejs_command, vim.inspect(provider))) if vim.fn.executable(local_nodejs_command) == 1 then provider._opts.command = local_nodejs_command table.insert(requests, provider) diff --git a/lua/plugins.lua b/lua/plugins.lua index fc4c47ab..c18dfa2b 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -147,12 +147,14 @@ return { -- vim-rooter { "airblade/vim-rooter", + event = "BufReadPre", config = function() - vim.g.rooter_silent_chdir = 1 + require("core.rooter").setup() if lvim.builtin.rooter.on_config_done then lvim.builtin.rooter.on_config_done() end end, + disable = not lvim.builtin.rooter.active, }, -- Icons diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 9c9b8523..c043550f 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -112,6 +112,16 @@ function utils.check_lsp_client_active(name) return false end +function utils.get_active_client_by_ft(filetype) + local clients = vim.lsp.get_active_clients() + for _, client in pairs(clients) do + if client.name == lvim.lang[filetype].lsp.provider then + return client + end + end + return nil +end + --- Extends a list-like table with the unique values of another list-like table. --- --- NOTE: This mutates dst! -- cgit v1.2.3 From 6c6fb67a8835cdcf911ef48ec2c19d553fe7d1a1 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Tue, 3 Aug 2021 23:02:09 -0400 Subject: use old vim rooter logic, fallback on new way if vimrooter is disabled --- lua/lsp/null-ls.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index d3f7931b..8bdea227 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -24,12 +24,22 @@ function M.get_registered_providers_by_filetype(ft) end local function validate_nodejs_provider(requests, provider) - local ts_client = require("utils").get_active_client_by_ft "typescript" - if ts_client == nil then - u.lvim_log "Unable to determine root directory since tsserver didn't start correctly" - return + local root_dir = "" + if lvim.builtin.rooter.active then + --- old logic to set root_dir + vim.cmd "let root_dir = FindRootDirectory()" + root_dir = vim.api.nvim_get_var "root_dir" + else + --- new logic to set root_dir + local ts_client = require("utils").get_active_client_by_ft "typescript" + if ts_client then + local root_dir = ts_client.config.root_dir + end + if ts_client == nil then + u.lvim_log "Unable to determine root directory since tsserver didn't start correctly" + return + end end - local root_dir = ts_client.config.root_dir local local_nodejs_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command u.lvim_log(string.format("checking [%s] for local node module: [%s]", local_nodejs_command, vim.inspect(provider))) if vim.fn.executable(local_nodejs_command) == 1 then -- cgit v1.2.3 From e504e1f08cde5893cf6a6c39fd1029fced21b996 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 4 Aug 2021 09:58:24 +0430 Subject: fix formatting and linting (#1220) --- lua/lsp/null-ls.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 8bdea227..04e35976 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -33,7 +33,7 @@ local function validate_nodejs_provider(requests, provider) --- new logic to set root_dir local ts_client = require("utils").get_active_client_by_ft "typescript" if ts_client then - local root_dir = ts_client.config.root_dir + root_dir = ts_client.config.root_dir end if ts_client == nil then u.lvim_log "Unable to determine root directory since tsserver didn't start correctly" -- cgit v1.2.3 From 7cd03ff4e332e1427497b54d5ca8b037afbc0982 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Wed, 4 Aug 2021 08:35:51 +0200 Subject: chore: minor cleanup to root_dir comments (#1222) --- lua/lsp/null-ls.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 04e35976..27cd1f78 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -24,21 +24,19 @@ function M.get_registered_providers_by_filetype(ft) end local function validate_nodejs_provider(requests, provider) - local root_dir = "" + local root_dir if lvim.builtin.rooter.active then - --- old logic to set root_dir + --- use vim-rooter to set root_dir vim.cmd "let root_dir = FindRootDirectory()" root_dir = vim.api.nvim_get_var "root_dir" else - --- new logic to set root_dir + --- use LSP to set root_dir local ts_client = require("utils").get_active_client_by_ft "typescript" - if ts_client then - root_dir = ts_client.config.root_dir - end if ts_client == nil then u.lvim_log "Unable to determine root directory since tsserver didn't start correctly" return end + root_dir = ts_client.config.root_dir end local local_nodejs_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command u.lvim_log(string.format("checking [%s] for local node module: [%s]", local_nodejs_command, vim.inspect(provider))) -- cgit v1.2.3 From db19d4c13c3b2cf15150e7c51c05cff07a316247 Mon Sep 17 00:00:00 2001 From: Pasi Bergman Date: Wed, 4 Aug 2021 16:12:01 +0300 Subject: [Bugfix]: Don't override formatter with empty exe (#1224) * fix(lsp): don't override formatter with empty exe * Check for nil value --- lua/lsp/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 66efdafc..a12fc648 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -71,7 +71,7 @@ function M.common_on_init(client, bufnr) end local formatters = lvim.lang[vim.bo.filetype].formatters - if not vim.tbl_isempty(formatters) then + if not vim.tbl_isempty(formatters) and formatters[1]["exe"] ~= nil and formatters[1].exe ~= "" then client.resolved_capabilities.document_formatting = false u.lvim_log(string.format("Overriding [%s] formatter with [%s]", client.name, formatters[1].exe)) end -- cgit v1.2.3 From 82f7bbb6f901b7506eea6eea0fab0e0e5fd5def1 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 4 Aug 2021 20:24:31 +0430 Subject: lazy loading vim-rooter might cause some issues because if FindRootDirectory not being found --- lua/plugins.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/plugins.lua b/lua/plugins.lua index c18dfa2b..57faca4e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -147,7 +147,7 @@ return { -- vim-rooter { "airblade/vim-rooter", - event = "BufReadPre", + -- event = "BufReadPre", config = function() require("core.rooter").setup() if lvim.builtin.rooter.on_config_done then -- cgit v1.2.3 From ef70e77e954a998a966eef213136328ef8a102cc Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 4 Aug 2021 23:40:38 +0430 Subject: fix GIT_DISCOVERY_ACROSS_FILESYSTEM error from solargraph (#1232) --- lua/default-config.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 53aff8c9..a7bbeff0 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -928,6 +928,16 @@ lvim.lang = { on_attach = common_on_attach, on_init = common_on_init, capabilities = common_capabilities, + filetypes = { "ruby" }, + init_options = { + formatting = true, + }, + root_dir = require("lspconfig").util.root_pattern("Gemfile", ".git"), + settings = { + solargraph = { + diagnostics = true, + }, + }, }, }, }, -- cgit v1.2.3 From 0842ebb280f4d4579294024e990625bf2d100938 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 4 Aug 2021 23:42:07 +0430 Subject: Revert "fix GIT_DISCOVERY_ACROSS_FILESYSTEM error from solargraph (#1232)" (#1233) This reverts commit ef70e77e954a998a966eef213136328ef8a102cc. --- lua/default-config.lua | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index a7bbeff0..53aff8c9 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -928,16 +928,6 @@ lvim.lang = { on_attach = common_on_attach, on_init = common_on_init, capabilities = common_capabilities, - filetypes = { "ruby" }, - init_options = { - formatting = true, - }, - root_dir = require("lspconfig").util.root_pattern("Gemfile", ".git"), - settings = { - solargraph = { - diagnostics = true, - }, - }, }, }, }, -- cgit v1.2.3 From cfa4faf0dde01329810e4afbed4d51c034b5b8ba Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 4 Aug 2021 23:46:33 +0430 Subject: Feature/ruby support (#1234) --- lua/default-config.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 53aff8c9..f228d0fb 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -928,6 +928,19 @@ lvim.lang = { on_attach = common_on_attach, on_init = common_on_init, capabilities = common_capabilities, + filetypes = { "ruby" }, + init_options = { + formatting = true, + }, + root_dir = function() + local util = require("lspconfig").util + return util.root_pattern("Gemfile", ".git") + end, + settings = { + solargraph = { + diagnostics = true, + }, + }, }, }, }, -- cgit v1.2.3 From 97fa3d9ec9e7d2416ed2d169eea757096db4581b Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 4 Aug 2021 15:20:09 -0400 Subject: update for lunarvim org --- lua/core/dashboard.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index 2f14b9f1..87741523 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -47,7 +47,7 @@ M.config = function() }, }, - footer = { "chrisatmachine.com" }, + footer = { "lunarvim.org" }, } end -- cgit v1.2.3 From 26a2225c3a08d05e0ad1ba1813c37eb6062ae7fc Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 4 Aug 2021 23:51:09 +0430 Subject: fix the ruby root_dir for good :sob: --- lua/default-config.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index f228d0fb..5b4074b6 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -932,9 +932,9 @@ lvim.lang = { init_options = { formatting = true, }, - root_dir = function() + root_dir = function(fname) local util = require("lspconfig").util - return util.root_pattern("Gemfile", ".git") + return util.root_pattern("Gemfile", ".git")(fname) end, settings = { solargraph = { -- cgit v1.2.3 From 76a16b6676183af564359c53184de1ebf6028b37 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 5 Aug 2021 16:34:25 +0200 Subject: stop registering duplicate null-ls providers (#1240) --- lua/lsp/null-ls.lua | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 27cd1f78..7adfa218 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -23,7 +23,8 @@ function M.get_registered_providers_by_filetype(ft) return matches end -local function validate_nodejs_provider(requests, provider) +local function validate_nodejs_provider(provider) + local command_path local root_dir if lvim.builtin.rooter.active then --- use vim-rooter to set root_dir @@ -41,43 +42,45 @@ local function validate_nodejs_provider(requests, provider) local local_nodejs_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command u.lvim_log(string.format("checking [%s] for local node module: [%s]", local_nodejs_command, vim.inspect(provider))) if vim.fn.executable(local_nodejs_command) == 1 then - provider._opts.command = local_nodejs_command - table.insert(requests, provider) + command_path = local_nodejs_command elseif vim.fn.executable(provider._opts.command) == 1 then u.lvim_log(string.format("checking in global path instead for node module: [%s]", provider._opts.command)) - table.insert(requests, provider) + command_path = provider._opts.command else u.lvim_log(string.format("Unable to find node module: [%s]", provider._opts.command)) - return false end - return true + return command_path end -local function validate_provider_request(requests, provider) +local function validate_provider_request(provider) if provider == "" or provider == nil then - return false + return end -- NOTE: we can't use provider.name because eslint_d uses eslint name if vim.tbl_contains(nodejs_local_providers, provider._opts.command) then - return validate_nodejs_provider(requests, provider) + return validate_nodejs_provider(provider) end if vim.fn.executable(provider._opts.command) ~= 1 then u.lvim_log(string.format("Unable to find the path for: [%s]", vim.inspect(provider))) - return false + return end - table.insert(requests, provider) - return true + return provider._opts.command end -- TODO: for linters and formatters with spaces and '-' replace with '_' function M.setup(filetype) for _, formatter in pairs(lvim.lang[filetype].formatters) do local builtin_formatter = null_ls.builtins.formatting[formatter.exe] - -- FIXME: why doesn't this work? - -- builtin_formatter._opts.args = formatter.args or builtin_formatter._opts.args - -- builtin_formatter._opts.to_stdin = formatter.stdin or builtin_formatter._opts.to_stdin - if validate_provider_request(M.requested_providers, builtin_formatter) then - u.lvim_log(string.format("Using format provider: [%s]", formatter.exe)) + if not vim.tbl_contains(M.requested_providers, builtin_formatter) then + -- FIXME: why doesn't this work? + -- builtin_formatter._opts.args = formatter.args or builtin_formatter._opts.args + -- builtin_formatter._opts.to_stdin = formatter.stdin or builtin_formatter._opts.to_stdin + local resolved_path = validate_provider_request(builtin_formatter) + if resolved_path then + builtin_formatter._opts.command = resolved_path + table.insert(M.requested_providers, builtin_formatter) + u.lvim_log(string.format("Using format provider: [%s]", builtin_formatter.name)) + end end end @@ -89,11 +92,16 @@ function M.setup(filetype) if linter.exe == "eslint_d" then builtin_diagnoser = null_ls.builtins.diagnostics.eslint.with { command = "eslint_d" } end - -- FIXME: why doesn't this work? - -- builtin_diagnoser._opts.args = linter.args or builtin_diagnoser._opts.args - -- builtin_diagnoser._opts.to_stdin = linter.stdin or builtin_diagnoser._opts.to_stdin - if validate_provider_request(M.requested_providers, builtin_diagnoser) then - u.lvim_log(string.format("Using linter provider: [%s]", linter.exe)) + if not vim.tbl_contains(M.requested_providers, builtin_diagnoser) then + -- FIXME: why doesn't this work? + -- builtin_diagnoser._opts.args = linter.args or builtin_diagnoser._opts.args + -- builtin_diagnoser._opts.to_stdin = linter.stdin or builtin_diagnoser._opts.to_stdin + local resolved_path = validate_provider_request(builtin_diagnoser) + if resolved_path then + builtin_diagnoser._opts.command = resolved_path + table.insert(M.requested_providers, builtin_diagnoser) + u.lvim_log(string.format("Using linter provider: [%s]", builtin_diagnoser.name)) + end end end -- cgit v1.2.3 From 67de24227f7244dc0f8a7ba90ad9d594e9bf4717 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 5 Aug 2021 16:35:58 +0200 Subject: chore: remove unncessary logic from utils (#1238) --- lua/lsp/init.lua | 2 +- lua/utils/init.lua | 9 --------- lua/utils/keymap.lua | 31 ------------------------------- 3 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 lua/utils/keymap.lua (limited to 'lua') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index a12fc648..a219fb1b 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -99,7 +99,7 @@ function M.setup(lang) local overrides = lvim.lsp.override if type(overrides) == "table" then - if u.has_value(overrides, lang) then + if vim.tbl_contains(overrides, lang) then return end end diff --git a/lua/utils/init.lua b/lua/utils/init.lua index c043550f..8cfd2790 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -42,15 +42,6 @@ local function r_inspect_settings(structure, limit, separator) return limit - 1 end -function utils.has_value(tab, val) - for _, value in ipairs(tab) do - if value == val then - return true - end - end - return false -end - function utils.generate_settings() -- Opens a file in append mode local file = io.open("lv-settings.lua", "w") diff --git a/lua/utils/keymap.lua b/lua/utils/keymap.lua deleted file mode 100644 index 1799e21f..00000000 --- a/lua/utils/keymap.lua +++ /dev/null @@ -1,31 +0,0 @@ -local M = {} - -local mode_adapters = { - insert_mode = "i", - normal_mode = "n", - term_mode = "t", - visual_mode = "v", - visual_block_mode = "x", -} - --- Load key mappings for a given mode --- @param mode The keymap mode, can be one of the keys of mode_adapters --- @param keymaps The list of key mappings --- @param opts The mapping options -M.load_mode = function(mode, keymaps, opts) - mode = mode_adapters[mode] and mode_adapters[mode] or mode - for key, mapping in pairs(keymaps) do - vim.api.nvim_set_keymap(mode, key, mapping[1], opts) - end -end - --- Load key mappings for all provided modes --- @param keymaps A list of key mappings for each mode --- @param opts The mapping options for each mode -M.load = function(keymaps, opts) - for mode, mapping in pairs(keymaps) do - M.load_mode(mode, mapping, opts[mode]) - end -end - -return M -- cgit v1.2.3 From 358d8b0da4af3a02d6ab49d03fcef80113517b34 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Thu, 5 Aug 2021 11:41:54 -0400 Subject: set spell file to be located in .config/lvim --- lua/default-config.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 5b4074b6..f0bae2aa 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -3,6 +3,7 @@ DATA_PATH = vim.fn.stdpath "data" CACHE_PATH = vim.fn.stdpath "cache" TERMINAL = vim.fn.expand "$TERMINAL" USER = vim.fn.expand "$USER" +vim.cmd[[ set spellfile=~/.config/lvim/spell/en.utf-8.add ]] lvim = { leader = "space", -- cgit v1.2.3 From 00d4ebc1657f4121e9f3d03f1b2c26fdd29a4247 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Thu, 5 Aug 2021 12:26:29 -0400 Subject: lq opens quickfix --- lua/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index eab9266a..6e0cbd8e 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -158,7 +158,7 @@ M.config = function() t = { "lua require('lsp.peek').Peek('typeDefinition')", "Type Definition" }, i = { "lua require('lsp.peek').Peek('implementation')", "Implementation" }, }, - q = { "Telescope quickfix", "Quickfix" }, + q = { "lua vim.lsp.diagnostic.set_loclist()", "Quickfix" }, r = { "lua vim.lsp.buf.rename()", "Rename" }, s = { "Telescope lsp_document_symbols", "Document Symbols" }, S = { -- cgit v1.2.3 From 43c9ca8f27bfef0508aa95a9a39c9ea99e314fb8 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Thu, 5 Aug 2021 22:01:39 +0430 Subject: fix formating :cry: (#1243) --- lua/default-config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index f0bae2aa..021eab06 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -3,7 +3,7 @@ DATA_PATH = vim.fn.stdpath "data" CACHE_PATH = vim.fn.stdpath "cache" TERMINAL = vim.fn.expand "$TERMINAL" USER = vim.fn.expand "$USER" -vim.cmd[[ set spellfile=~/.config/lvim/spell/en.utf-8.add ]] +vim.cmd [[ set spellfile=~/.config/lvim/spell/en.utf-8.add ]] lvim = { leader = "space", -- cgit v1.2.3 From 106c9cad0d27ea9de4bf8576fe6f498a302f9d9d Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Thu, 5 Aug 2021 23:42:16 +0430 Subject: use_decoration_api has been removed from gitsigns (#1245) --- lua/core/gitsigns.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'lua') diff --git a/lua/core/gitsigns.lua b/lua/core/gitsigns.lua index 2a5060be..f2c98f7c 100644 --- a/lua/core/gitsigns.lua +++ b/lua/core/gitsigns.lua @@ -44,7 +44,6 @@ M.config = function() sign_priority = 6, update_debounce = 200, status_formatter = nil, -- Use default - use_decoration_api = false, } end -- cgit v1.2.3 From 20a4da558335a64a7cf7a6bd1d3500827e138635 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Thu, 5 Aug 2021 15:50:09 -0400 Subject: ability to toggle bufferline --- lua/core/bufferline.lua | 1 + lua/plugins.lua | 1 + 2 files changed, 2 insertions(+) (limited to 'lua') diff --git a/lua/core/bufferline.lua b/lua/core/bufferline.lua index 68030c81..a51cff47 100644 --- a/lua/core/bufferline.lua +++ b/lua/core/bufferline.lua @@ -1,4 +1,5 @@ lvim.builtin.bufferline = { + active = true, keymap = { normal_mode = { [""] = ":BufferNext", diff --git a/lua/plugins.lua b/lua/plugins.lua index 57faca4e..38627d8e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -182,6 +182,7 @@ return { end end, event = "BufWinEnter", + disable = not lvim.builtin.bufferline.active, }, -- Debugging -- cgit v1.2.3 From 9f3510286423ed700f3a2e04be02b95d93158a5c Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Fri, 6 Aug 2021 00:57:51 +0430 Subject: dap.stop is deprecated, use dap.close instead (#1247) --- lua/core/dap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/dap.lua b/lua/core/dap.lua index 30e3aef9..f2ed5795 100644 --- a/lua/core/dap.lua +++ b/lua/core/dap.lua @@ -34,7 +34,7 @@ M.setup = function() p = { "lua require'dap'.pause.toggle()", "Pause" }, r = { "lua require'dap'.repl.toggle()", "Toggle Repl" }, s = { "lua require'dap'.continue()", "Start" }, - q = { "lua require'dap'.stop()", "Quit" }, + q = { "lua require'dap'.close()", "Quit" }, } end -- cgit v1.2.3 From e93724d5f6607e876a60c946b8f59c4b3c61c215 Mon Sep 17 00:00:00 2001 From: Pasi Bergman Date: Thu, 5 Aug 2021 23:42:19 +0300 Subject: [Feature] Add PowerShell language server support (#1244) --- lua/default-config.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 021eab06..c4b3155c 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -1235,7 +1235,7 @@ lvim.lang = { }, }, gdscript = { - formatter = {}, + formatters = {}, linters = {}, lsp = { provider = "gdscript", @@ -1251,6 +1251,19 @@ lvim.lang = { }, }, }, + ps1 = { + formatters = {}, + linters = {}, + lsp = { + provider = "powershell_es", + setup = { + bundle_path = "", + on_attach = common_on_attach, + on_init = common_on_init, + capabilities = common_capabilities, + }, + }, + }, } require("keymappings").config() -- cgit v1.2.3 From 3ccd5dbc8c56495d8424ff41cdfdb4d0d8ff39af Mon Sep 17 00:00:00 2001 From: rebuilt Date: Fri, 6 Aug 2021 04:04:21 +0200 Subject: bufferline broke because the added active toggle will always be false. Set it in default_config to fix behavior --- lua/core/bufferline.lua | 28 ++++++++++++++++++---------- lua/default-config.lua | 1 + lua/plugins.lua | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) (limited to 'lua') diff --git a/lua/core/bufferline.lua b/lua/core/bufferline.lua index a51cff47..8989ce21 100644 --- a/lua/core/bufferline.lua +++ b/lua/core/bufferline.lua @@ -1,12 +1,20 @@ -lvim.builtin.bufferline = { - active = true, - keymap = { - normal_mode = { - [""] = ":BufferNext", - [""] = ":BufferPrevious", +local M = {} + +M.config = function() + lvim.builtin.bufferline = { + active = true, + keymap = { + normal_mode = { + [""] = ":BufferNext", + [""] = ":BufferPrevious", + }, }, - }, -} + } +end + +M.setup = function() + local keymap = require "keymappings" + keymap.append_to_defaults(lvim.builtin.bufferline.keymap) +end -local keymap = require "keymappings" -keymap.append_to_defaults(lvim.builtin.bufferline.keymap) +return M diff --git a/lua/default-config.lua b/lua/default-config.lua index c4b3155c..4c9448a6 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -1278,3 +1278,4 @@ require("core.telescope").config() require("core.treesitter").config() require("core.nvimtree").config() require("core.rooter").config() +require("core.bufferline").config() diff --git a/lua/plugins.lua b/lua/plugins.lua index 38627d8e..592ff7e1 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -176,7 +176,7 @@ return { { "romgrk/barbar.nvim", config = function() - require "core.bufferline" + require("core.bufferline").setup() if lvim.builtin.bufferline.on_config_done then lvim.builtin.bufferline.on_config_done() end -- cgit v1.2.3 From 990bb622e0a7f90881a6016570c6f205499b1c0d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 6 Aug 2021 10:39:08 +0200 Subject: chore: remove now-redundant utility function --- lua/core/galaxyline.lua | 3 +-- lua/utils/init.lua | 26 -------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) (limited to 'lua') diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index b2325b19..d3f9342b 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -203,7 +203,6 @@ table.insert(gls.right, { local function get_attached_provider_name(msg) msg = msg or "LSP Inactive" local buf_clients = vim.lsp.buf_get_clients() - local utils = require "utils" if next(buf_clients) == nil then return msg end @@ -215,7 +214,7 @@ local function get_attached_provider_name(msg) table.insert(buf_client_names, client.name) end end - utils.list_extend_unique(buf_client_names, null_ls_providers) + vim.list_extend(buf_client_names, null_ls_providers) return table.concat(buf_client_names, ", ") end diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 8cfd2790..b27643ac 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -113,32 +113,6 @@ function utils.get_active_client_by_ft(filetype) return nil end ---- Extends a list-like table with the unique values of another list-like table. ---- ---- NOTE: This mutates dst! ---- ---@see |vim.tbl_extend()| ---- ---@param dst list which will be modified and appended to. ---@param src list from which values will be inserted. ---@param start Start index on src. defaults to 1 ---@param finish Final index on src. defaults to #src ---@returns dst -function utils.list_extend_unique(dst, src, start, finish) - vim.validate { - dst = { dst, "t" }, - src = { src, "t" }, - start = { start, "n", true }, - finish = { finish, "n", true }, - } - for i = start or 1, finish or #src do - if not vim.tbl_contains(dst, src[i]) then - table.insert(dst, src[i]) - end - end - return dst -end - function utils.unrequire(m) package.loaded[m] = nil _G[m] = nil -- cgit v1.2.3 From 9fc6a2e1cdac513c8ff09069263ff102852be86a Mon Sep 17 00:00:00 2001 From: grvxs Date: Fri, 6 Aug 2021 16:50:25 +0530 Subject: fix: typos in lua/ --- lua/core/dashboard.lua | 2 +- lua/lsp/peek.lua | 2 +- lua/utils/init.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lua') diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index 87741523..27d4efd1 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -84,7 +84,7 @@ M.setup = function() require("core.autocmds").define_augroups { _dashboard = { - -- seems to be nobuflisted that makes my stuff disapear will do more testing + -- seems to be nobuflisted that makes my stuff disappear will do more testing { "FileType", "dashboard", diff --git a/lua/lsp/peek.lua b/lua/lsp/peek.lua index e512eee0..cc8e57a9 100644 --- a/lua/lsp/peek.lua +++ b/lua/lsp/peek.lua @@ -100,7 +100,7 @@ function M.set_cursor_to_prev_pos(winnr) local range = location.targetRange or location.range local cursor_pos = { range.start.line + 1, range.start.character } - -- Set the winnr to the floting window if none was passed in + -- Set the winnr to the floating window if none was passed in winnr = winnr or M.floating_win -- Set the cursor at the correct position in the floating window vim.api.nvim_win_set_cursor(winnr, cursor_pos) diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 8cfd2790..8cc1b32d 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -16,7 +16,7 @@ local function r_inspect_settings(structure, limit, separator) if ts == "table" then for k, v in pairs(structure) do - -- replace non alpha keys wih ["key"] + -- replace non alpha keys with ["key"] if tostring(k):match "[^%a_]" then k = '["' .. tostring(k) .. '"]' end -- cgit v1.2.3 From 47ebd70817c99c657271e399c0b98b920f765f29 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 6 Aug 2021 16:27:19 +0200 Subject: Add LunarVim info panel (Experimental) (#1241) * feat: lunarvim info (Experimental) * Add missing providers info * Use nvim api directly to create the popup * width tweaks --- lua/core/info.lua | 180 +++++++++++++++++++++++++++++++++++++++++++++++++ lua/core/which-key.lua | 4 ++ lua/lsp/init.lua | 30 +++++++++ lua/lsp/null-ls.lua | 26 +++++++ lua/utils/init.lua | 28 ++++++++ 5 files changed, 268 insertions(+) create mode 100644 lua/core/info.lua (limited to 'lua') diff --git a/lua/core/info.lua b/lua/core/info.lua new file mode 100644 index 00000000..7f8a0a33 --- /dev/null +++ b/lua/core/info.lua @@ -0,0 +1,180 @@ +local M = {} +local u = require "utils" +local null_ls_handler = require "lsp.null-ls" +local indent = " " + +M.banner = { + "", + "", + "⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀ ⠀⠀⠀ ⠀⠀ ⣺⡿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀", + "⠀⣿⠇⠀⠀⠀⠀⠀⣤⡄⠀⠀⢠⣤⡄⠀.⣠⣤⣤⣤⡀⠀⠀⢀⣤⣤⣤⣤⡄⠀⠀⠀⣤⣄⣤⣤⣤⠀⠀ ⣿⣯ ⣿⡟⠀ ⣤⣤⠀⠀⠀⠀⣠⣤⣤⣤⣄⣤⣤", + "⢠⣿⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⣸⣿⠁⠀⣿⣿⠉⠀⠈⣿⡇⠀⠀⠛⠋⠀⠀⢹⣿⠀⠀⠀⣿⠏⠀⠸⠿⠃⠀⣿⣿⠀⣰⡟⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⣿⡟⢸⣿⡇⢀⣿", + "⣸⡇⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⡟⠀⢠⣿⡇⠀⠀⢰⣿⡇⠀⣰⣾⠟⠛⠛⣻⡇⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⢻⣿⢰⣿⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⢸⣿⠇⢸⣿⠀⢸⡏", + "⣿⣧⣤⣤⣤⡄⠀⠘⣿⣤⣤⡤⣿⠇⠀⢸⣿⠁⠀⠀⣼⣿⠀⠀⢿⣿⣤⣤⠔⣿⠃⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⢸⣿⣿⠋⠀⠀⠀⢠⣤⣤⣿⣥⣤⡄⠀⣼⣿⠀⣸⡏⠀⣿⠃", + "⠉⠉⠉⠉⠉⠁⠀⠀⠈⠉⠉⠀⠉⠀⠀⠈⠉⠀⠀⠀⠉⠉⠀⠀⠀⠉⠉⠁⠈⠉⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀⠉⠁⠀⠉⠁⠀⠉⠀", + "", + "", +} + +local function str_list(list) + return "[ " .. table.concat(list, ", ") .. " ]" +end + +local function get_formatter_suggestion_msg(ft) + local supported_formatters = u.get_supported_formatters_by_filetype(ft) + return { + "-------------------------------------------------------------------", + "", + "  HINT ", + "", + indent .. "* List of supported formatters: " .. str_list(supported_formatters), + "", + indent .. "You can enable a supported formatter by adding this to your config.lua", + "", + indent + .. "lvim.lang." + .. tostring(ft) + .. [[.formatting = { { exe = ']] + .. table.concat(supported_formatters, "|") + .. [[' } }]], + "", + "-------------------------------------------------------------------", + } +end + +local function get_linter_suggestion_msg(ft) + local supported_linters = u.get_supported_linters_by_filetype(ft) + return { + "-------------------------------------------------------------------", + "", + "  HINT ", + "", + indent .. "* List of supported linters: " .. str_list(supported_linters), + "", + indent .. "You can enable a supported linter by adding this to your config.lua", + "", + indent + .. "lvim.lang." + .. tostring(ft) + .. [[.linters = { { exe = ']] + .. table.concat(supported_linters, "|") + .. [[' } }]], + "", + "-------------------------------------------------------------------", + } +end + +---creates an average size popup +---@param buf_lines a list of lines to print +---@param callback could be used to set syntax highlighting rules for example +---@return bufnr buffer number of the created buffer +---@return win_id window ID of the created popup +function M.create_simple_popup(buf_lines, callback) + -- runtime/lua/vim/lsp/util.lua + local bufnr = vim.api.nvim_create_buf(false, true) + local height_percentage = 0.7 + local width_percentage = 0.8 + local row_start_percentage = (1 - height_percentage) / 2 + local col_start_percentage = (1 - width_percentage) / 2 + local opts = {} + opts.relative = "editor" + opts.height = math.ceil(vim.o.lines * height_percentage) + opts.row = math.ceil(vim.o.lines * row_start_percentage) + opts.col = math.floor(vim.o.columns * col_start_percentage) + opts.width = math.floor(vim.o.columns * width_percentage) + opts.border = { + "┌", + "-", + "┐", + "|", + "┘", + "-", + "└", + "|", + } + + local win_id = vim.api.nvim_open_win(bufnr, true, opts) + + vim.api.nvim_win_set_buf(win_id, bufnr) + -- this needs to be window option! + vim.api.nvim_win_set_option(win_id, "number", false) + vim.cmd "setlocal nocursorcolumn" + vim.cmd "setlocal wrap" + -- set buffer options + vim.api.nvim_buf_set_option(bufnr, "filetype", "lspinfo") + vim.lsp.util.close_preview_autocmd({ "BufHidden", "BufLeave" }, win_id) + buf_lines = vim.lsp.util._trim(buf_lines, {}) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, buf_lines) + vim.api.nvim_buf_set_option(bufnr, "modifiable", false) + if type(callback) == "function" then + callback() + end + return bufnr, win_id +end + +function M.toggle_popup(ft) + local client = u.get_active_client_by_ft(ft) + local is_client_active = not client.is_stopped() + local client_enabled_caps = require("lsp").get_ls_capabilities(client.id) + local num_caps = vim.tbl_count(client_enabled_caps) + local null_ls_providers = null_ls_handler.get_registered_providers_by_filetype(ft) + + local missing_linters = lvim.lang[ft].linters._failed_requests or {} + local missing_formatters = lvim.lang[ft].formatters._failed_requests or {} + + local buf_lines = {} + vim.list_extend(buf_lines, M.banner) + + local header = { + "Detected filetype is: " .. tostring(ft), + "", + "Treesitter active: " .. tostring(next(vim.treesitter.highlighter.active) ~= nil), + "", + "", + } + vim.list_extend(buf_lines, header) + + local lsp_info = { + "Associated language-server: " .. client.name, + indent .. "* Active: " .. tostring(is_client_active) .. ", id: " .. tostring(client.id), + indent .. "* Formatting support: " .. tostring(client.resolved_capabilities.document_formatting), + indent .. "* Capabilities list: " .. table.concat(vim.list_slice(client_enabled_caps, 1, num_caps / 2), ", "), + indent .. indent .. indent .. table.concat(vim.list_slice(client_enabled_caps, ((num_caps / 2) + 1)), ", "), + "", + } + vim.list_extend(buf_lines, lsp_info) + + local null_ls_info = { + "Configured providers: " .. table.concat(null_ls_providers, "  , ") .. "  ", + "", + } + vim.list_extend(buf_lines, null_ls_info) + + local missing_formatters_status + if vim.tbl_count(missing_formatters) > 0 then + missing_formatters_status = { "Missing formatters: " .. table.concat(missing_formatters, "  , ") .. "  ", "" } + vim.list_extend(buf_lines, missing_formatters_status) + end + + local missing_linters_status + if vim.tbl_count(missing_linters) > 0 then + missing_linters_status = { "Missing linters: " .. table.concat(missing_linters, "  , ") .. "  ", "" } + vim.list_extend(buf_lines, missing_linters_status) + end + + vim.list_extend(buf_lines, get_formatter_suggestion_msg(ft)) + + vim.list_extend(buf_lines, get_linter_suggestion_msg(ft)) + + local function set_syntax_hl() + --TODO: highlighting is either inconsistent or not working :\ + vim.cmd("syntax match Identifier /filetype is: .*\\zs\\<" .. ft .. "\\>/") + vim.cmd("syntax match Identifier /server: .*\\zs\\<" .. client.name .. "\\>/") + vim.cmd("syntax match Identifier /providers: .*\\zs\\<" .. table.concat(null_ls_providers, ", ") .. "\\>/") + vim.cmd("syntax match Identifier /formatters: .*\\zs\\<" .. table.concat(missing_formatters, ", ") .. "\\>/") + vim.cmd("syntax match Identifier /linters: .*\\zs\\<" .. table.concat(missing_linters, ", ") .. "\\>/") + end + + return M.create_simple_popup(buf_lines, set_syntax_hl) +end +return M diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 6e0cbd8e..268243e4 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -169,6 +169,10 @@ M.config = function() L = { name = "+LunarVim", k = { "lua require('keymappings').print()", "View LunarVim's default keymappings" }, + i = { + "lua require('core.info').toggle_popup(vim.bo.filetype)", + "Toggle LunarVim Info", + }, }, s = { diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index a219fb1b..29676214 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -64,6 +64,36 @@ function M.common_capabilities() return capabilities end +function M.get_ls_capabilities(client_id) + local client + if not client_id then + local buf_clients = vim.lsp.buf_get_clients() + for _, buf_client in ipairs(buf_clients) do + if buf_client.name ~= "null-ls" then + client_id = buf_client.id + break + end + end + end + if not client_id then + error "Unable to determine client_id" + end + + client = vim.lsp.get_client_by_id(tonumber(client_id)) + + local enabled_caps = {} + + for k, v in pairs(client.resolved_capabilities) do + if v == true then + -- print("got cap: ", vim.inspect(caps)) + table.insert(enabled_caps, k) + -- vim.list_extend(enabled_caps, cap) + end + end + + return enabled_caps +end + function M.common_on_init(client, bufnr) if lvim.lsp.on_init_callback then lvim.lsp.on_init_callback(client, bufnr) diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 7adfa218..19727e15 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -23,6 +23,26 @@ function M.get_registered_providers_by_filetype(ft) return matches end +function M.get_missing_providers_by_filetype(ft) + local matches = {} + for _, provider in pairs(M.requested_providers) do + if vim.tbl_contains(provider.filetypes, ft) then + local provider_name = provider.name + + table.insert(matches, provider_name) + end + end + + return matches +end + +local function register_failed_request(ft, provider, operation) + if not lvim.lang[ft][operation]._failed_requests then + lvim.lang[ft][operation]._failed_requests = {} + end + table.insert(lvim.lang[ft][operation]._failed_requests, provider) +end + local function validate_nodejs_provider(provider) local command_path local root_dir @@ -80,6 +100,9 @@ function M.setup(filetype) builtin_formatter._opts.command = resolved_path table.insert(M.requested_providers, builtin_formatter) u.lvim_log(string.format("Using format provider: [%s]", builtin_formatter.name)) + else + -- mark it here to avoid re-doing the lookup again + register_failed_request(filetype, formatter.exe, "formatters") end end end @@ -101,6 +124,9 @@ function M.setup(filetype) builtin_diagnoser._opts.command = resolved_path table.insert(M.requested_providers, builtin_diagnoser) u.lvim_log(string.format("Using linter provider: [%s]", builtin_diagnoser.name)) + else + -- mark it here to avoid re-doing the lookup again + register_failed_request(filetype, linter.exe, "linters") end end end diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 16ad5e4a..df472c66 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -113,6 +113,34 @@ function utils.get_active_client_by_ft(filetype) return nil end +-- TODO: consider porting this logic to null-ls instead +function utils.get_supported_linters_by_filetype(filetype) + local null_ls = require "null-ls" + local matches = {} + for _, provider in pairs(null_ls.builtins.diagnostics) do + if vim.tbl_contains(provider.filetypes, filetype) then + local provider_name = provider.name + + table.insert(matches, provider_name) + end + end + + return matches +end + +function utils.get_supported_formatters_by_filetype(filetype) + local null_ls = require "null-ls" + local matches = {} + for _, provider in pairs(null_ls.builtins.formatting) do + if provider.filetypes and vim.tbl_contains(provider.filetypes, filetype) then + -- table.insert(matches, { provider.name, ft }) + table.insert(matches, provider.name) + end + end + + return matches +end + function utils.unrequire(m) package.loaded[m] = nil _G[m] = nil -- cgit v1.2.3 From 2345d8cf21fd93a6cf5f716d0345ebce285660a1 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Fri, 6 Aug 2021 15:27:06 -0400 Subject: update green --- lua/spacegray/palette.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/spacegray/palette.lua b/lua/spacegray/palette.lua index d3274700..924482fd 100644 --- a/lua/spacegray/palette.lua +++ b/lua/spacegray/palette.lua @@ -13,7 +13,7 @@ local colors = { blue = "#5f8ccd", dark_blue = "#223E55", light_blue = "#8dc0d5", - green = "#73aa7b", + green = "#83ba8b", cyan = "#4EC9B0", light_green = "#B5CEA8", red = "#D16969", -- cgit v1.2.3 From 730542a47da8e2dbb7e0a800c425f210a0325b1b Mon Sep 17 00:00:00 2001 From: ashincoder <83629316+ashincoder@users.noreply.github.com> Date: Sat, 7 Aug 2021 14:53:25 +0530 Subject: Added space after plug icon (#1252) --- lua/core/dashboard.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/dashboard.lua b/lua/core/dashboard.lua index 27d4efd1..d5e5bfe9 100644 --- a/lua/core/dashboard.lua +++ b/lua/core/dashboard.lua @@ -72,7 +72,7 @@ M.setup = function() vim.api.nvim_exec( [[ - let g:dashboard_custom_footer = ['LunarVim loaded '..packages..' plugins '] + let g:dashboard_custom_footer = ['LunarVim loaded '..packages..' plugins  '] ]], false ) -- cgit v1.2.3 From 6aab0ea8ac6948fb75dd1a68c0aa07e8ccf2b8ff Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 8 Aug 2021 13:26:33 +0430 Subject: fix compe for latex --- lua/core/autopairs.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/autopairs.lua b/lua/core/autopairs.lua index f0111db6..751e47df 100644 --- a/lua/core/autopairs.lua +++ b/lua/core/autopairs.lua @@ -24,7 +24,7 @@ MUtils.completion_confirm = function() end end -if package.loaded["compe"] then +if package.loaded["compe"] and vim.bo.filetype ~= "tex" then require("nvim-autopairs.completion.compe").setup { map_cr = true, -- map on insert mode map_complete = true, -- it will auto insert `(` after select function or method item -- cgit v1.2.3 From 1484e056827080ed7946e7e664e11eedccd8a6f9 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 8 Aug 2021 20:51:24 +0430 Subject: better compe support for latex --- lua/core/autopairs.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/core/autopairs.lua b/lua/core/autopairs.lua index 751e47df..f989864f 100644 --- a/lua/core/autopairs.lua +++ b/lua/core/autopairs.lua @@ -24,10 +24,11 @@ MUtils.completion_confirm = function() end end -if package.loaded["compe"] and vim.bo.filetype ~= "tex" then +if package.loaded["compe"] then + local map_complete_optional = vim.bo.filetype ~= "tex" require("nvim-autopairs.completion.compe").setup { map_cr = true, -- map on insert mode - map_complete = true, -- it will auto insert `(` after select function or method item + map_complete = map_complete_optional, -- it will auto insert `(` after select function or method item } end -- cgit v1.2.3 From 3da49e4be455d72d2a69fb76472c1f022815681b Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 8 Aug 2021 13:34:59 -0400 Subject: tab can cycle through pum, insert a tab, and jump through snippets, what more could you want? --- lua/core/compe.lua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'lua') diff --git a/lua/core/compe.lua b/lua/core/compe.lua index e8cb857d..830cc415 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -42,8 +42,8 @@ M.config = function() keymap = { values = { insert_mode = { - [""] = { 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true } }, - [""] = { 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true } }, + -- [""] = { 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true } }, + -- [""] = { 'pumvisible() ? "" : ""', { silent = true, noremap = true, expr = true } }, [""] = { "compe#complete()", { silent = true, noremap = true, expr = true } }, [""] = { "compe#close('')", { silent = true, noremap = true, expr = true } }, [""] = { "compe#scroll({ 'delta': +4 })", { silent = true, noremap = true, expr = true } }, @@ -86,12 +86,13 @@ M.setup = function() _G.tab_complete = function() if vim.fn.pumvisible() == 1 then return t "" - elseif vim.fn.call("vsnip#available", { 1 }) == 1 then - return t "(vsnip-expand-or-jump)" + elseif vim.fn.call("vsnip#jumpable", { 1 }) == 1 then + return t "(vsnip-jump-next)" elseif check_back_space() then return t "" else - return vim.fn["compe#complete"]() + -- return vim.fn["compe#complete"]() -- < use this if you want to always offer completion + return t "" end end @@ -107,6 +108,18 @@ M.setup = function() local keymap = require "keymappings" keymap.load(lvim.builtin.compe.keymap.values, lvim.builtin.compe.keymap.opts) + + vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", { expr = true }) + vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", { expr = true }) + vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", { expr = true }) + vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", { expr = true }) + +-- vim.cmd[[ +-- imap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' +-- smap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' +-- imap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' +-- smap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' +-- ]] end return M -- cgit v1.2.3 From f3064248a0ba02b973fbd81f4eb93e18131d2fbc Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 8 Aug 2021 13:38:26 -0400 Subject: new event for vsnip --- lua/core/compe.lua | 6 ------ lua/plugins.lua | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'lua') diff --git a/lua/core/compe.lua b/lua/core/compe.lua index 830cc415..fe41c6e6 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -114,12 +114,6 @@ M.setup = function() vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", { expr = true }) vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", { expr = true }) --- vim.cmd[[ --- imap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' --- smap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' --- imap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' --- smap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' --- ]] end return M diff --git a/lua/plugins.lua b/lua/plugins.lua index 592ff7e1..30f326cc 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -57,7 +57,7 @@ return { { "hrsh7th/vim-vsnip", -- wants = "friendly-snippets", - event = "InsertCharPre", + event = "InsertEnter", }, { "rafamadriz/friendly-snippets", -- cgit v1.2.3 From 93b37d6e8697ec07038f31b3d479c5f1c38777d8 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 8 Aug 2021 22:51:09 +0430 Subject: fix formatting for compe (#1266) --- lua/core/compe.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'lua') diff --git a/lua/core/compe.lua b/lua/core/compe.lua index fe41c6e6..742fd07a 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -113,7 +113,6 @@ M.setup = function() vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", { expr = true }) vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", { expr = true }) vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", { expr = true }) - end return M -- cgit v1.2.3 From 6b98bc137894492ecbe5dfa03bc149e8760a6453 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 9 Aug 2021 07:58:22 +0200 Subject: avoid using smart_cwd if root_dir is not found --- lua/lsp/init.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lua') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 29676214..020c4313 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -51,6 +51,14 @@ local function add_lsp_buffer_keybindings(bufnr) wk.register(keys, { mode = "n", buffer = bufnr }) end +local function set_smart_cwd(client) + local proj_dir = client.config.root_dir + if lvim.lsp.smart_cwd and proj_dir ~= "/" then + vim.api.nvim_set_current_dir(proj_dir) + require("core.nvimtree").change_tree_dir(proj_dir) + end +end + function M.common_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true @@ -113,10 +121,7 @@ function M.common_on_attach(client, bufnr) end lsp_highlight_document(client) add_lsp_buffer_keybindings(bufnr) - if lvim.lsp.smart_cwd then - vim.api.nvim_set_current_dir(client.config.root_dir) - require("core.nvimtree").change_tree_dir(client.config.root_dir) - end + set_smart_cwd(client) require("lsp.null-ls").setup(vim.bo.filetype) end -- cgit v1.2.3 From 0e09963aff81bbab5d1b3f2b5f4190aadd0873d7 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Mon, 9 Aug 2021 12:43:59 +0430 Subject: fix `cmake-language-server: error: unrecognized arguments: --stdio` --- lua/default-config.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'lua') diff --git a/lua/default-config.lua b/lua/default-config.lua index 4c9448a6..ded120da 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -254,7 +254,6 @@ lvim.lang = { setup = { cmd = { DATA_PATH .. "/lspinstall/cmake/venv/bin/cmake-language-server", - "--stdio", }, on_attach = common_on_attach, on_init = common_on_init, -- cgit v1.2.3 From 625df947dcacf3804f4ec7335478535ecd8219af Mon Sep 17 00:00:00 2001 From: Pasi Bergman Date: Mon, 9 Aug 2021 17:59:27 +0300 Subject: [Feature] Add LvimInfo command (#1269) * feature: add LvimInfo command * Move :LvimInfo to core/commands.lua --- lua/core/commands.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lua') diff --git a/lua/core/commands.lua b/lua/core/commands.lua index c42b385d..22170c85 100644 --- a/lua/core/commands.lua +++ b/lua/core/commands.lua @@ -10,6 +10,8 @@ M.defaults = { endif endfunction ]], + -- :LvimInfo + [[command! LvimInfo lua require('core.info').toggle_popup(vim.bo.filetype)]], } M.load = function(commands) -- cgit v1.2.3 From 405423108fc31981c40116a827e845a1179c9053 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 9 Aug 2021 19:02:37 +0200 Subject: feat: Add an async logger using plenary (#1207) Co-authored-by: rebuilt --- lua/core/autopairs.lua | 2 ++ lua/core/compe.lua | 2 ++ lua/core/dap.lua | 2 ++ lua/core/galaxyline.lua | 2 ++ lua/core/gitsigns.lua | 2 ++ lua/core/log.lua | 29 +++++++++++++++++++++++++++++ lua/core/nvimtree.lua | 2 ++ lua/core/telescope.lua | 2 ++ lua/core/terminal.lua | 48 +++++++++++++++++++++++++++++++++++++++++++++--- lua/core/treesitter.lua | 2 ++ lua/core/which-key.lua | 20 +++++++++++++++++++- lua/default-config.lua | 17 ++++++++++++++++- lua/keymappings.lua | 4 ++++ lua/lsp/init.lua | 11 ++++++----- lua/lsp/null-ls.lua | 20 ++++++++++++-------- lua/plugins.lua | 2 ++ lua/utils/init.lua | 19 +++++++++++++++---- 17 files changed, 164 insertions(+), 22 deletions(-) create mode 100644 lua/core/log.lua (limited to 'lua') diff --git a/lua/core/autopairs.lua b/lua/core/autopairs.lua index f989864f..a5f21a1b 100644 --- a/lua/core/autopairs.lua +++ b/lua/core/autopairs.lua @@ -1,8 +1,10 @@ -- if not package.loaded['nvim-autopairs'] then -- return -- end +local Log = require "core.log" local status_ok, _ = pcall(require, "nvim-autopairs") if not status_ok then + Log:get_default().error "Failed to load autopairs" return end local npairs = require "nvim-autopairs" diff --git a/lua/core/compe.lua b/lua/core/compe.lua index 742fd07a..c2f97e27 100644 --- a/lua/core/compe.lua +++ b/lua/core/compe.lua @@ -1,4 +1,5 @@ local M = {} +local Log = require "core.log" M.config = function() lvim.builtin.compe = { enabled = true, @@ -62,6 +63,7 @@ M.setup = function() local status_ok, compe = pcall(require, "compe") if not status_ok then + Log:get_default().error "Failed to load compe" return end diff --git a/lua/core/dap.lua b/lua/core/dap.lua index f2ed5795..4e21cc4c 100644 --- a/lua/core/dap.lua +++ b/lua/core/dap.lua @@ -1,4 +1,5 @@ local M = {} +local Log = require "core.log" M.config = function() lvim.builtin.dap = { active = false, @@ -14,6 +15,7 @@ end M.setup = function() local status_ok, dap = pcall(require, "dap") if not status_ok then + Log:get_default().error "Failed to load dap" return end diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua index d3f9342b..ee0a317d 100644 --- a/lua/core/galaxyline.lua +++ b/lua/core/galaxyline.lua @@ -1,8 +1,10 @@ -- if not package.loaded['galaxyline'] then -- return -- end +local Log = require "core.log" local status_ok, gl = pcall(require, "galaxyline") if not status_ok then + Log:get_default().error "Failed to load galaxyline" return end diff --git a/lua/core/gitsigns.lua b/lua/core/gitsigns.lua index f2c98f7c..9e023762 100644 --- a/lua/core/gitsigns.lua +++ b/lua/core/gitsigns.lua @@ -1,4 +1,5 @@ local M = {} +local Log = require "core.log" M.config = function() lvim.builtin.gitsigns = { signs = { @@ -50,6 +51,7 @@ end M.setup = function() local status_ok, gitsigns = pcall(require, "gitsigns") if not status_ok then + Log:get_default().error "Failed to load gitsigns" return end gitsigns.setup(lvim.builtin.gitsigns) diff --git a/lua/core/log.lua b/lua/core/log.lua new file mode 100644 index 00000000..5dd5622e --- /dev/null +++ b/lua/core/log.lua @@ -0,0 +1,29 @@ +local Log = {} + +--- Creates a log handle based on Plenary.log +---@param opts these are passed verbatim to Plenary.log +---@return log handle +function Log:new(opts) + local status_ok, _ = pcall(require, "plenary.log") + if not status_ok then + return nil + end + + local obj = require("plenary.log").new(opts) + local path = string.format("%s/%s.log", vim.api.nvim_call_function("stdpath", { "cache" }), opts.plugin) + + obj.get_path = function() + return path + end + + return obj +end + +--- Creates or retrieves a log handle for the default logfile +--- based on Plenary.log +---@return log handle +function Log:get_default() + return Log:new { plugin = "lunarvim", level = lvim.log.level } +end + +return Log diff --git a/lua/core/nvimtree.lua b/lua/core/nvimtree.lua index 1a0de0b8..4d15b1b5 100644 --- a/lua/core/nvimtree.lua +++ b/lua/core/nvimtree.lua @@ -1,4 +1,5 @@ local M = {} +local Log = require "core.log" -- M.config = function() lvim.builtin.nvimtree = { @@ -49,6 +50,7 @@ end M.setup = function() local status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") if not status_ok then + Log:get_default().error "Failed to load nvim-tree.config" return end local g = vim.g diff --git a/lua/core/telescope.lua b/lua/core/telescope.lua index 37d59982..f4d154b0 100644 --- a/lua/core/telescope.lua +++ b/lua/core/telescope.lua @@ -1,4 +1,5 @@ local M = {} +local Log = require "core.log" M.config = function() local status_ok, actions = pcall(require, "telescope.actions") if not status_ok then @@ -79,6 +80,7 @@ end M.setup = function() local status_ok, telescope = pcall(require, "telescope") if not status_ok then + Log:get_default().error "Failed to load telescope" return end telescope.setup(lvim.builtin.telescope) diff --git a/lua/core/terminal.lua b/lua/core/terminal.lua index bd7815aa..818038fd 100644 --- a/lua/core/terminal.lua +++ b/lua/core/terminal.lua @@ -1,8 +1,11 @@ local M = {} +local Log = require "core.log" +local utils = require "utils" + M.config = function() lvim.builtin["terminal"] = { -- size can be a number or function which is passed the current terminal - size = 5, + size = 20, -- open_mapping = [[]], open_mapping = [[]], hide_numbers = true, -- hide the number column in toggleterm buffers @@ -11,7 +14,7 @@ M.config = function() shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light start_in_insert = true, insert_mappings = true, -- whether or not the open mapping applies in insert mode - persist_size = true, + persist_size = false, -- direction = 'vertical' | 'horizontal' | 'window' | 'float', direction = "float", close_on_exit = true, -- close the terminal window when the process exits @@ -36,13 +39,16 @@ M.config = function() -- { exec, keymap, name} -- lvim.builtin.terminal.execs = {{}} to overwrite -- lvim.builtin.terminal.execs[#lvim.builtin.terminal.execs+1] = {"gdb", "tg", "GNU Debugger"} - execs = { { "lazygit", "gg", "LazyGit" } }, + execs = { + { "lazygit", "gg", "LazyGit" }, + }, } end M.setup = function() local status_ok, terminal = pcall(require, "toggleterm") if not status_ok then + Log:get_default().error "Failed to load toggleterm" print(terminal) return end @@ -88,4 +94,40 @@ M._exec_toggle = function(exec) exec_term:toggle() end +local function get_log_path(name) + --handle custom paths not managed by Plenary.log + local logger = require "core.log" + local file + if name == "nvim" then + file = CACHE_PATH .. "/log" + else + file = logger:new({ plugin = name }):get_path() + end + if utils.is_file(file) then + return file + end +end + +---Toggles a log viewer according to log.viewer.layout_config +---@param name can be the name of any of the managed logs, e,g. "lunarvim" or the default ones {"nvim", "lsp", "packer.nvim"} +M.toggle_log_view = function(name) + local logfile = get_log_path(name) + if not logfile then + return + end + local term_opts = vim.tbl_deep_extend("force", lvim.builtin.terminal, { + cmd = lvim.log.viewer.cmd .. " " .. logfile, + open_mapping = lvim.log.viewer.layout_config.open_mapping, + direction = lvim.log.viewer.layout_config.direction, + -- TODO: this might not be working as expected + size = lvim.log.viewer.layout_config.size, + float_opts = lvim.log.viewer.layout_config.float_opts, + }) + + local Terminal = require("toggleterm.terminal").Terminal + local log_view = Terminal:new(term_opts) + -- require("core.log"):get_default().debug("term", vim.inspect(term_opts)) + log_view:toggle() +end + return M diff --git a/lua/core/treesitter.lua b/lua/core/treesitter.lua index cfc58bb7..0a8a2ff2 100644 --- a/lua/core/treesitter.lua +++ b/lua/core/treesitter.lua @@ -1,4 +1,5 @@ local M = {} +local Log = require "core.log" M.config = function() lvim.builtin.treesitter = { ensure_installed = {}, -- one of "all", "maintained" (parsers with maintainers), or a list of languages @@ -64,6 +65,7 @@ end M.setup = function() local status_ok, treesitter_configs = pcall(require, "nvim-treesitter.configs") if not status_ok then + Log:get_default().error "Failed to load nvim-treesitter.configs" return end diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 268243e4..90bf1ace 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -1,4 +1,5 @@ local M = {} +local Log = require "core.log" M.config = function() lvim.builtin.which_key = { active = false, @@ -173,8 +174,24 @@ M.config = function() "lua require('core.info').toggle_popup(vim.bo.filetype)", "Toggle LunarVim Info", }, + l = { + name = "+logs", + d = { + "lua require('core.terminal').toggle_log_view('lunarvim')", + "view default log", + }, + D = { "edit ~/.cache/nvim/lunarvim.log", "Open the default logfile" }, + n = { "lua require('core.terminal').toggle_log_view('lsp')", "view lsp log" }, + N = { "edit ~/.cache/nvim/log", "Open the Neovim logfile" }, + l = { "lua require('core.terminal').toggle_log_view('nvim')", "view neovim log" }, + L = { "edit ~/.cache/nvim/lsp.log", "Open the LSP logfile" }, + p = { + "lua require('core.terminal').toggle_log_view('packer.nvim')", + "view packer log", + }, + P = { "edit ~/.cache/nvim/packer.nvim.log", "Open the Packer logfile" }, + }, }, - s = { name = "Search", b = { "Telescope git_branches", "Checkout branch" }, @@ -206,6 +223,7 @@ M.setup = function() -- end local status_ok, which_key = pcall(require, "which-key") if not status_ok then + Log:get_default "Failed to load whichkey" return end diff --git a/lua/default-config.lua b/lua/default-config.lua index ded120da..bba21206 100644 --- a/lua/default-config.lua +++ b/lua/default-config.lua @@ -34,6 +34,22 @@ lvim = { terminal = {}, }, + log = { + ---@usage can be { "trace", "debug", "info", "warn", "error", "fatal" }, + level = "warn", + viewer = { + ---@usage this will fallback on "less +F" if not found + cmd = "lnav", + layout_config = { + ---@usage direction = 'vertical' | 'horizontal' | 'window' | 'float', + direction = "horizontal", + open_mapping = "", + size = 40, + float_opts = {}, + }, + }, + }, + lsp = { completion = { item_kind = { @@ -95,7 +111,6 @@ lvim = { }, autocommands = {}, - debug = false, } local schemas = nil diff --git a/lua/keymappings.lua b/lua/keymappings.lua index d14bedad..e82df5ae 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,4 +1,5 @@ local M = {} +local Log = require "core.log" local generic_opts_any = { noremap = true, silent = true } @@ -148,6 +149,9 @@ function M.config() lvim.keys.normal_mode[""] = lvim.keys.normal_mode[""] lvim.keys.normal_mode[""] = lvim.keys.normal_mode[""] lvim.keys.normal_mode[""] = lvim.keys.normal_mode[""] + if Log:get_default() then + Log:get_default().info "Activated mac keymappings" + end end end diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 020c4313..0d08ecee 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,6 +1,5 @@ local M = {} -local u = require "utils" - +local Log = require "core.log" function M.config() vim.lsp.protocol.CompletionItemKind = lvim.lsp.completion.item_kind @@ -93,9 +92,7 @@ function M.get_ls_capabilities(client_id) for k, v in pairs(client.resolved_capabilities) do if v == true then - -- print("got cap: ", vim.inspect(caps)) table.insert(enabled_caps, k) - -- vim.list_extend(enabled_caps, cap) end end @@ -105,19 +102,23 @@ end function M.common_on_init(client, bufnr) if lvim.lsp.on_init_callback then lvim.lsp.on_init_callback(client, bufnr) + Log:get_default().info "Called lsp.on_init_callback" return end local formatters = lvim.lang[vim.bo.filetype].formatters if not vim.tbl_isempty(formatters) and formatters[1]["exe"] ~= nil and formatters[1].exe ~= "" then client.resolved_capabilities.document_formatting = false - u.lvim_log(string.format("Overriding [%s] formatter with [%s]", client.name, formatters[1].exe)) + Log:get_default().info( + string.format("Overriding language server [%s] with format provider [%s]", client.name, formatters[1].exe) + ) end end function M.common_on_attach(client, bufnr) if lvim.lsp.on_attach_callback then lvim.lsp.on_attach_callback(client, bufnr) + Log:get_default().info "Called lsp.on_init_callback" end lsp_highlight_document(client) add_lsp_buffer_keybindings(bufnr) diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index 19727e15..c5388109 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -1,5 +1,6 @@ local M = {} -local u = require "utils" +local Log = require "core.log" + local null_ls = require "null-ls" local nodejs_local_providers = { "prettier", "prettierd", "prettier_d_slim", "eslint_d", "eslint" } @@ -54,20 +55,21 @@ local function validate_nodejs_provider(provider) --- use LSP to set root_dir local ts_client = require("utils").get_active_client_by_ft "typescript" if ts_client == nil then - u.lvim_log "Unable to determine root directory since tsserver didn't start correctly" + Log:get_default().error "Unable to determine root directory since tsserver didn't start correctly" return end root_dir = ts_client.config.root_dir end local local_nodejs_command = root_dir .. "/node_modules/.bin/" .. provider._opts.command - u.lvim_log(string.format("checking [%s] for local node module: [%s]", local_nodejs_command, vim.inspect(provider))) + Log:get_default().debug("checking for local node module: ", vim.inspect(provider)) + if vim.fn.executable(local_nodejs_command) == 1 then command_path = local_nodejs_command elseif vim.fn.executable(provider._opts.command) == 1 then - u.lvim_log(string.format("checking in global path instead for node module: [%s]", provider._opts.command)) + Log:get_default().debug("checking in global path instead for node module", provider._opts.command) command_path = provider._opts.command else - u.lvim_log(string.format("Unable to find node module: [%s]", provider._opts.command)) + Log:get_default().debug("Unable to find node module", provider._opts.command) end return command_path end @@ -81,7 +83,7 @@ local function validate_provider_request(provider) return validate_nodejs_provider(provider) end if vim.fn.executable(provider._opts.command) ~= 1 then - u.lvim_log(string.format("Unable to find the path for: [%s]", vim.inspect(provider))) + Log:get_default().warn("Unable to find the path for", vim.inspect(provider)) return end return provider._opts.command @@ -90,6 +92,7 @@ end -- TODO: for linters and formatters with spaces and '-' replace with '_' function M.setup(filetype) for _, formatter in pairs(lvim.lang[filetype].formatters) do + Log:get_default().debug("validating format provider: ", formatter.exe) local builtin_formatter = null_ls.builtins.formatting[formatter.exe] if not vim.tbl_contains(M.requested_providers, builtin_formatter) then -- FIXME: why doesn't this work? @@ -99,7 +102,7 @@ function M.setup(filetype) if resolved_path then builtin_formatter._opts.command = resolved_path table.insert(M.requested_providers, builtin_formatter) - u.lvim_log(string.format("Using format provider: [%s]", builtin_formatter.name)) + Log:get_default().info("Using format provider", builtin_formatter.name) else -- mark it here to avoid re-doing the lookup again register_failed_request(filetype, formatter.exe, "formatters") @@ -109,6 +112,7 @@ function M.setup(filetype) for _, linter in pairs(lvim.lang[filetype].linters) do local builtin_diagnoser = null_ls.builtins.diagnostics[linter.exe] + Log:get_default().debug("validating lint provider: ", linter.exe) -- special case: fallback to "eslint" -- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/9b8458bd1648e84169a7e8638091ba15c2f20fc0/doc/BUILTINS.md#eslint -- if provider.exe @@ -123,7 +127,7 @@ function M.setup(filetype) if resolved_path then builtin_diagnoser._opts.command = resolved_path table.insert(M.requested_providers, builtin_diagnoser) - u.lvim_log(string.format("Using linter provider: [%s]", builtin_diagnoser.name)) + Log:get_default().info("Using linter provider", builtin_diagnoser.name) else -- mark it here to avoid re-doing the lookup again register_failed_request(filetype, linter.exe, "linters") diff --git a/lua/plugins.lua b/lua/plugins.lua index 30f326cc..598e8164 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -135,6 +135,8 @@ return { config = function() local status_ok, nvim_comment = pcall(require, "nvim_comment") if not status_ok then + local Log = require "core.log" + Log:get_default().error "Failed to load nvim-comment" return end nvim_comment.setup() diff --git a/lua/utils/init.lua b/lua/utils/init.lua index df472c66..208871bf 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -1,4 +1,6 @@ local utils = {} +local Log = require "core.log" +local uv = vim.loop -- recursive Print (structure, limit, separator) local function r_inspect_settings(structure, limit, separator) @@ -68,6 +70,9 @@ function utils.toggle_autoformat() }, }, } + if Log:get_default() then + Log:get_default().info "Format on save active" + end end if not lvim.format_on_save then @@ -76,6 +81,9 @@ function utils.toggle_autoformat() :autocmd! autoformat endif ]] + if Log:get_default() then + Log:get_default().info "Format on save off" + end end end @@ -91,6 +99,7 @@ function utils.reload_lv_config() vim.cmd ":PackerInstall" require("keymappings").setup() -- vim.cmd ":PackerClean" + Log:get_default().info "Reloaded configuration" end function utils.check_lsp_client_active(name) @@ -157,10 +166,12 @@ function utils.gsub_args(args) return args end -function utils.lvim_log(msg) - if lvim.debug then - vim.notify(msg, vim.log.levels.DEBUG) - end +--- Checks whether a given path exists and is a file. +--@param filename (string) path to check +--@returns (bool) +function utils.is_file(filename) + local stat = uv.fs_stat(filename) + return stat and stat.type == "file" or false end return utils -- cgit v1.2.3 From 68287877806e1931f4c6f342c3ee0ba47b634737 Mon Sep 17 00:00:00 2001 From: Ahmed Khalf Date: Tue, 10 Aug 2021 18:59:05 +0400 Subject: Fix window borders for lunarvim info (#1280) --- lua/core/info.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index 7f8a0a33..501f786e 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -23,7 +23,7 @@ end local function get_formatter_suggestion_msg(ft) local supported_formatters = u.get_supported_formatters_by_filetype(ft) return { - "-------------------------------------------------------------------", + "───────────────────────────────────────────────────────────────────", "", "  HINT ", "", @@ -35,17 +35,17 @@ local function get_formatter_suggestion_msg(ft) .. "lvim.lang." .. tostring(ft) .. [[.formatting = { { exe = ']] - .. table.concat(supported_formatters, "|") + .. table.concat(supported_formatters, "│") .. [[' } }]], "", - "-------------------------------------------------------------------", + "───────────────────────────────────────────────────────────────────", } end local function get_linter_suggestion_msg(ft) local supported_linters = u.get_supported_linters_by_filetype(ft) return { - "-------------------------------------------------------------------", + "───────────────────────────────────────────────────────────────────", "", "  HINT ", "", @@ -57,10 +57,10 @@ local function get_linter_suggestion_msg(ft) .. "lvim.lang." .. tostring(ft) .. [[.linters = { { exe = ']] - .. table.concat(supported_linters, "|") + .. table.concat(supported_linters, "│") .. [[' } }]], "", - "-------------------------------------------------------------------", + "───────────────────────────────────────────────────────────────────", } end @@ -83,14 +83,14 @@ function M.create_simple_popup(buf_lines, callback) opts.col = math.floor(vim.o.columns * col_start_percentage) opts.width = math.floor(vim.o.columns * width_percentage) opts.border = { - "┌", - "-", - "┐", - "|", - "┘", - "-", - "└", - "|", + "╭", + "─", + "╮", + "│", + "╯", + "─", + "╰", + "│", } local win_id = vim.api.nvim_open_win(bufnr, true, opts) -- cgit v1.2.3 From 4f47e6cfe0a60183e0095d1bfc9012efa3be21de Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Tue, 10 Aug 2021 22:06:21 +0430 Subject: pin astronauta till we figure out the root cause (#1282) --- lua/plugins.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/plugins.lua b/lua/plugins.lua index 598e8164..730b0d70 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -18,7 +18,7 @@ return { { "nvim-lua/popup.nvim" }, { "nvim-lua/plenary.nvim" }, - { "tjdevries/astronauta.nvim" }, + { "tjdevries/astronauta.nvim", commit = "e69d7bdc4183047c4700427922c4a3cc1e3258c6" }, -- Telescope { -- cgit v1.2.3 From 44e43e225bee70cef004529d3a62ab82f2ca1a74 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Tue, 10 Aug 2021 22:17:24 +0430 Subject: remove the violent message for provider not found (#1283) --- lua/lsp/null-ls.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua index c5388109..697eac39 100644 --- a/lua/lsp/null-ls.lua +++ b/lua/lsp/null-ls.lua @@ -83,7 +83,8 @@ local function validate_provider_request(provider) return validate_nodejs_provider(provider) end if vim.fn.executable(provider._opts.command) ~= 1 then - Log:get_default().warn("Unable to find the path for", vim.inspect(provider)) + Log:get_default().debug("Unable to find the path for", vim.inspect(provider)) + Log:get_default().warn("Unable to find the path for ", provider._opts.command) return end return provider._opts.command -- cgit v1.2.3 From 9a68500333660af76a2b7e75c3d7dcd38f8481b2 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 10 Aug 2021 20:53:56 +0200 Subject: fix: do not overwrite plugins bindings in reload (#1284) --- lua/utils/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/utils/init.lua b/lua/utils/init.lua index 208871bf..8264189d 100644 --- a/lua/utils/init.lua +++ b/lua/utils/init.lua @@ -90,6 +90,7 @@ end function utils.reload_lv_config() vim.cmd "source ~/.local/share/lunarvim/lvim/lua/settings.lua" vim.cmd("source " .. USER_CONFIG_PATH) + require("keymappings").setup() -- this should be done before loading the plugins vim.cmd "source ~/.local/share/lunarvim/lvim/lua/plugins.lua" local plugins = require "plugins" local plugin_loader = require("plugin-loader").init() @@ -97,7 +98,6 @@ function utils.reload_lv_config() plugin_loader:load { plugins, lvim.plugins } vim.cmd ":PackerCompile" vim.cmd ":PackerInstall" - require("keymappings").setup() -- vim.cmd ":PackerClean" Log:get_default().info "Reloaded configuration" end -- cgit v1.2.3 From a6a10e3fdbcfea9d8600772b91e45fb19084a390 Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Tue, 10 Aug 2021 15:01:26 -0400 Subject: bring back behavior we used to get from astronauta --- lua/core/autocmds.lua | 5 +++++ lua/utils/ft.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 lua/utils/ft.lua (limited to 'lua') diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index 62c05802..c00e4ba7 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -2,6 +2,11 @@ local autocommands = {} lvim.autocommands = { _general_settings = { + { + "Filetype", + "*", + "lua require('utils.ft').do_filetype(vim.fn.expand(\"\"))", + }, { "TextYankPost", "*", diff --git a/lua/utils/ft.lua b/lua/utils/ft.lua new file mode 100644 index 00000000..fcebd1ea --- /dev/null +++ b/lua/utils/ft.lua @@ -0,0 +1,45 @@ +local ft = {} + +ft.find_lua_ftplugins = function(filetype) + local patterns = { + string.format("ftplugin/%s.lua", filetype), + + -- Looks like we don't need this, because the first one works + -- string.format("after/ftplugin/%s.lua", filetype), + } + + local result = {} + for _, pat in ipairs(patterns) do + vim.list_extend(result, vim.api.nvim_get_runtime_file(pat, true)) + end + + return result +end + +ft.do_filetype = function(filetype) + local ftplugins = ft.find_lua_ftplugins(filetype) + + local f_env = setmetatable({ + -- Override print, so the prints still go through, otherwise it's confusing for people + print = vim.schedule_wrap(print), + }, { + -- Buf default back read/write to whatever is going on in the global landscape + __index = _G, + __newindex = _G, + }) + + for _, file in ipairs(ftplugins) do + local f = loadfile(file) + if not f then + vim.api.nvim_err_writeln("Unable to load file: " .. file) + else + local ok, msg = pcall(setfenv(f, f_env)) + + if not ok then + vim.api.nvim_err_writeln("Error while processing file: " .. file .. "\n" .. msg) + end + end + end +end + +return ft -- cgit v1.2.3 From fc9090f64b73c2c2c5d9a6c3ec60ef4c2fe56cfe Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Tue, 10 Aug 2021 15:07:35 -0400 Subject: remove astronauta --- lua/plugins.lua | 2 -- lua/utils/ft.lua | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/plugins.lua b/lua/plugins.lua index 730b0d70..8e497075 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -18,8 +18,6 @@ return { { "nvim-lua/popup.nvim" }, { "nvim-lua/plenary.nvim" }, - { "tjdevries/astronauta.nvim", commit = "e69d7bdc4183047c4700427922c4a3cc1e3258c6" }, - -- Telescope { "nvim-telescope/telescope.nvim", diff --git a/lua/utils/ft.lua b/lua/utils/ft.lua index fcebd1ea..e9852e6f 100644 --- a/lua/utils/ft.lua +++ b/lua/utils/ft.lua @@ -1,3 +1,5 @@ +-- Here be dragons +-- Opening files with telescope will not start LSP without this local ft = {} ft.find_lua_ftplugins = function(filetype) -- cgit v1.2.3 From 2fcb64ac561b2860ccac2e28dcaed51d00337f85 Mon Sep 17 00:00:00 2001 From: tuxflo Date: Wed, 11 Aug 2021 04:56:25 +0200 Subject: change no highlight behavior (#1285) with `let @/=""` its not possible to use `n`,`N` or stuff like `gcn` anymore because the last search is overwritten. With `:nohlsearch` this is not the case. --- lua/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 90bf1ace..67a553ff 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -68,7 +68,7 @@ M.config = function() ["c"] = { "BufferClose!", "Close Buffer" }, ["e"] = { "lua require'core.nvimtree'.toggle_tree()", "Explorer" }, ["f"] = { "Telescope find_files", "Find File" }, - ["h"] = { 'let @/=""', "No Highlight" }, + ["h"] = { 'nohlsearch', "No Highlight" }, b = { name = "Buffers", j = { "BufferPick", "jump to buffer" }, -- cgit v1.2.3 From e7c6275879dfceeedb99b74e3cce9f41e3e22625 Mon Sep 17 00:00:00 2001 From: Pasi Bergman Date: Wed, 11 Aug 2021 08:54:53 +0300 Subject: [Refactor] LunarVim Info UI (#1281) * refactor: lunarvim info ui * refactor: lunarvim info ui - remove close hint, add highlighting * refactor: lunarvim info ui - remove TODO --- lua/core/info.lua | 137 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 83 insertions(+), 54 deletions(-) (limited to 'lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index 501f786e..e4c787a2 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -4,15 +4,19 @@ local null_ls_handler = require "lsp.null-ls" local indent = " " M.banner = { - "", - "", - "⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀ ⠀⠀⠀ ⠀⠀ ⣺⡿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀", - "⠀⣿⠇⠀⠀⠀⠀⠀⣤⡄⠀⠀⢠⣤⡄⠀.⣠⣤⣤⣤⡀⠀⠀⢀⣤⣤⣤⣤⡄⠀⠀⠀⣤⣄⣤⣤⣤⠀⠀ ⣿⣯ ⣿⡟⠀ ⣤⣤⠀⠀⠀⠀⣠⣤⣤⣤⣄⣤⣤", - "⢠⣿⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⣸⣿⠁⠀⣿⣿⠉⠀⠈⣿⡇⠀⠀⠛⠋⠀⠀⢹⣿⠀⠀⠀⣿⠏⠀⠸⠿⠃⠀⣿⣿⠀⣰⡟⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⣿⡟⢸⣿⡇⢀⣿", - "⣸⡇⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⡟⠀⢠⣿⡇⠀⠀⢰⣿⡇⠀⣰⣾⠟⠛⠛⣻⡇⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⢻⣿⢰⣿⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⢸⣿⠇⢸⣿⠀⢸⡏", - "⣿⣧⣤⣤⣤⡄⠀⠘⣿⣤⣤⡤⣿⠇⠀⢸⣿⠁⠀⠀⣼⣿⠀⠀⢿⣿⣤⣤⠔⣿⠃⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⢸⣿⣿⠋⠀⠀⠀⢠⣤⣤⣿⣥⣤⡄⠀⣼⣿⠀⣸⡏⠀⣿⠃", - "⠉⠉⠉⠉⠉⠁⠀⠀⠈⠉⠉⠀⠉⠀⠀⠈⠉⠀⠀⠀⠉⠉⠀⠀⠀⠉⠉⠁⠈⠉⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀⠉⠁⠀⠉⠁⠀⠉⠀", - "", + " ", + indent + .. "⠀⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀ ⠀⠀⠀ ⠀⠀ ⣺⡿⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀", + indent + .. "⠀⣿⠇⠀⠀⠀⠀⠀⣤⡄⠀⠀⢠⣤⡄⠀.⣠⣤⣤⣤⡀⠀⠀⢀⣤⣤⣤⣤⡄⠀⠀⠀⣤⣄⣤⣤⣤⠀⠀ ⣿⣯ ⣿⡟⠀ ⣤⣤⠀⠀⠀⠀⣠⣤⣤⣤⣄⣤⣤", + indent + .. "⢠⣿⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⣸⣿⠁⠀⣿⣿⠉⠀⠈⣿⡇⠀⠀⠛⠋⠀⠀⢹⣿⠀⠀⠀⣿⠏⠀⠸⠿⠃⠀⣿⣿⠀⣰⡟⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⣿⡟⢸⣿⡇⢀⣿", + indent + .. "⣸⡇⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⣿⡟⠀⢠⣿⡇⠀⠀⢰⣿⡇⠀⣰⣾⠟⠛⠛⣻⡇⠀⠀⢸⡿⠀⠀⠀⠀⠀⠀⢻⣿⢰⣿⠀⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⢸⣿⠇⢸⣿⠀⢸⡏", + indent + .. "⣿⣧⣤⣤⣤⡄⠀⠘⣿⣤⣤⡤⣿⠇⠀⢸⣿⠁⠀⠀⣼⣿⠀⠀⢿⣿⣤⣤⠔⣿⠃⠀⠀⣾⡇⠀⠀⠀⠀⠀⠀⢸⣿⣿⠋⠀⠀⠀⢠⣤⣤⣿⣥⣤⡄⠀⣼⣿⠀⣸⡏⠀⣿⠃", + indent + .. "⠉⠉⠉⠉⠉⠁⠀⠀⠈⠉⠉⠀⠉⠀⠀⠈⠉⠀⠀⠀⠉⠉⠀⠀⠀⠉⠉⠁⠈⠉⠀⠀⠀⠉⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠀⠀⠀⠀⠈⠉⠉⠉⠉⠉⠁⠀⠉⠁⠀⠉⠁⠀⠉⠀", "", } @@ -23,44 +27,42 @@ end local function get_formatter_suggestion_msg(ft) local supported_formatters = u.get_supported_formatters_by_filetype(ft) return { - "───────────────────────────────────────────────────────────────────", + indent + .. "───────────────────────────────────────────────────────────────────", "", - "  HINT ", + indent .. " HINT ", "", indent .. "* List of supported formatters: " .. str_list(supported_formatters), + indent .. "* Configured formatter needs to be installed and executable.", + indent .. "* Enable installed formatter(s) with following config in ~/.config/lvim/config.lua", "", - indent .. "You can enable a supported formatter by adding this to your config.lua", - "", - indent - .. "lvim.lang." - .. tostring(ft) - .. [[.formatting = { { exe = ']] - .. table.concat(supported_formatters, "│") - .. [[' } }]], + indent .. " lvim.lang." .. tostring(ft) .. [[.formatting = { { exe = ']] .. table.concat( + supported_formatters, + "│" + ) .. [[' } }]], "", - "───────────────────────────────────────────────────────────────────", } end local function get_linter_suggestion_msg(ft) local supported_linters = u.get_supported_linters_by_filetype(ft) return { - "───────────────────────────────────────────────────────────────────", + indent + .. "───────────────────────────────────────────────────────────────────", "", - "  HINT ", + indent .. " HINT ", "", indent .. "* List of supported linters: " .. str_list(supported_linters), - "", - indent .. "You can enable a supported linter by adding this to your config.lua", + indent .. "* Configured linter needs to be installed and executable.", + indent .. "* Enable installed linter(s) with following config in ~/.config/lvim/config.lua", "", indent - .. "lvim.lang." + .. " lvim.lang." .. tostring(ft) .. [[.linters = { { exe = ']] .. table.concat(supported_linters, "│") .. [[' } }]], "", - "───────────────────────────────────────────────────────────────────", } end @@ -72,26 +74,30 @@ end function M.create_simple_popup(buf_lines, callback) -- runtime/lua/vim/lsp/util.lua local bufnr = vim.api.nvim_create_buf(false, true) - local height_percentage = 0.7 + local height_percentage = 0.9 local width_percentage = 0.8 local row_start_percentage = (1 - height_percentage) / 2 local col_start_percentage = (1 - width_percentage) / 2 local opts = {} opts.relative = "editor" - opts.height = math.ceil(vim.o.lines * height_percentage) + opts.height = math.min(math.ceil(vim.o.lines * height_percentage), #buf_lines) opts.row = math.ceil(vim.o.lines * row_start_percentage) opts.col = math.floor(vim.o.columns * col_start_percentage) opts.width = math.floor(vim.o.columns * width_percentage) + opts.style = "minimal" + opts.border = "rounded" + --[[ opts.border = { - "╭", - "─", - "╮", - "│", - "╯", - "─", - "╰", - "│", + lvim.builtin.telescope.defaults.borderchars[5], -- "┌", + lvim.builtin.telescope.defaults.borderchars[3], -- "-", + lvim.builtin.telescope.defaults.borderchars[6], -- "┐", + lvim.builtin.telescope.defaults.borderchars[2], -- "|", + lvim.builtin.telescope.defaults.borderchars[7], -- "┘", + lvim.builtin.telescope.defaults.borderchars[3], -- "-", + lvim.builtin.telescope.defaults.borderchars[8], -- "└", + lvim.builtin.telescope.defaults.borderchars[4], -- "|", } + --]] local win_id = vim.api.nvim_open_win(bufnr, true, opts) @@ -112,6 +118,17 @@ function M.create_simple_popup(buf_lines, callback) return bufnr, win_id end +local function tbl_set_highlight(terms, highlight_group) + if type(terms) ~= "table" then + return + end + + for _, v in pairs(terms) do + print("Add highlight for word: " .. v) + vim.cmd('let m=matchadd("' .. highlight_group .. '", "' .. v .. '")') + end +end + function M.toggle_popup(ft) local client = u.get_active_client_by_ft(ft) local is_client_active = not client.is_stopped() @@ -126,53 +143,65 @@ function M.toggle_popup(ft) vim.list_extend(buf_lines, M.banner) local header = { - "Detected filetype is: " .. tostring(ft), - "", - "Treesitter active: " .. tostring(next(vim.treesitter.highlighter.active) ~= nil), - "", + indent .. "Detected filetype: " .. tostring(ft), + indent .. "Treesitter active: " .. tostring(next(vim.treesitter.highlighter.active) ~= nil), "", } vim.list_extend(buf_lines, header) local lsp_info = { - "Associated language-server: " .. client.name, - indent .. "* Active: " .. tostring(is_client_active) .. ", id: " .. tostring(client.id), - indent .. "* Formatting support: " .. tostring(client.resolved_capabilities.document_formatting), - indent .. "* Capabilities list: " .. table.concat(vim.list_slice(client_enabled_caps, 1, num_caps / 2), ", "), + indent .. "Language Server Protocol (LSP) info", + indent .. "* Associated server: " .. client.name, + indent .. "* Active: " .. tostring(is_client_active) .. " (id: " .. tostring(client.id) .. ")", + indent .. "* Supports formatting: " .. tostring(client.resolved_capabilities.document_formatting), + indent .. "* Capabilities list: " .. table.concat(vim.list_slice(client_enabled_caps, 1, num_caps / 2), ", "), indent .. indent .. indent .. table.concat(vim.list_slice(client_enabled_caps, ((num_caps / 2) + 1)), ", "), "", } vim.list_extend(buf_lines, lsp_info) local null_ls_info = { - "Configured providers: " .. table.concat(null_ls_providers, "  , ") .. "  ", - "", + indent .. "Formatters and linters", + indent .. "* Configured providers: " .. table.concat(null_ls_providers, "  , ") .. "  ", } vim.list_extend(buf_lines, null_ls_info) local missing_formatters_status if vim.tbl_count(missing_formatters) > 0 then - missing_formatters_status = { "Missing formatters: " .. table.concat(missing_formatters, "  , ") .. "  ", "" } + missing_formatters_status = { + indent .. "* Missing formatters: " .. table.concat(missing_formatters, "  , ") .. "  ", + } vim.list_extend(buf_lines, missing_formatters_status) end local missing_linters_status if vim.tbl_count(missing_linters) > 0 then - missing_linters_status = { "Missing linters: " .. table.concat(missing_linters, "  , ") .. "  ", "" } + missing_linters_status = { + indent .. "* Missing linters: " .. table.concat(missing_linters, "  , ") .. "  ", + } vim.list_extend(buf_lines, missing_linters_status) end + vim.list_extend(buf_lines, { "" }) + vim.list_extend(buf_lines, get_formatter_suggestion_msg(ft)) vim.list_extend(buf_lines, get_linter_suggestion_msg(ft)) local function set_syntax_hl() - --TODO: highlighting is either inconsistent or not working :\ - vim.cmd("syntax match Identifier /filetype is: .*\\zs\\<" .. ft .. "\\>/") - vim.cmd("syntax match Identifier /server: .*\\zs\\<" .. client.name .. "\\>/") - vim.cmd("syntax match Identifier /providers: .*\\zs\\<" .. table.concat(null_ls_providers, ", ") .. "\\>/") - vim.cmd("syntax match Identifier /formatters: .*\\zs\\<" .. table.concat(missing_formatters, ", ") .. "\\>/") - vim.cmd("syntax match Identifier /linters: .*\\zs\\<" .. table.concat(missing_linters, ", ") .. "\\>/") + vim.cmd [[highlight LvimInfoIdentifier gui=bold]] + vim.cmd [[highlight link LvimInfoHeader Type]] + vim.cmd [[let m=matchadd("DashboardHeader", "Language Server Protocol (LSP) info")]] + vim.cmd [[let m=matchadd("DashboardHeader", "Formatters and linters")]] + vim.cmd('let m=matchadd("LvimInfoIdentifier", " ' .. ft .. '$")') + vim.cmd 'let m=matchadd("luaString", "true")' + vim.cmd 'let m=matchadd("luaError", "false")' + tbl_set_highlight(null_ls_providers, "LvimInfoIdentifier") + tbl_set_highlight(missing_formatters, "LvimInfoIdentifier") + tbl_set_highlight(missing_linters, "LvimInfoIdentifier") + -- tbl_set_highlight(u.get_supported_formatters_by_filetype(ft), "LvimInfoIdentifier") + -- tbl_set_highlight(u.get_supported_linters_by_filetype(ft), "LvimInfoIdentifier") + vim.cmd('let m=matchadd("LvimInfoIdentifier", "' .. client.name .. '")') end return M.create_simple_popup(buf_lines, set_syntax_hl) -- cgit v1.2.3 From 0a1c76eb6a0e3bb37245943905c1f96e1615f15f Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 11:27:10 +0430 Subject: fix formatting for which-key.lua (#1288) --- lua/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index 67a553ff..d75b2c70 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -68,7 +68,7 @@ M.config = function() ["c"] = { "BufferClose!", "Close Buffer" }, ["e"] = { "lua require'core.nvimtree'.toggle_tree()", "Explorer" }, ["f"] = { "Telescope find_files", "Find File" }, - ["h"] = { 'nohlsearch', "No Highlight" }, + ["h"] = { "nohlsearch", "No Highlight" }, b = { name = "Buffers", j = { "BufferPick", "jump to buffer" }, -- cgit v1.2.3 From abbde6c138cebe17b354544395525a8e27673565 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 11:32:33 +0430 Subject: remove useless print for LunarVim info --- lua/core/info.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index e4c787a2..825f8fa7 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -124,7 +124,6 @@ local function tbl_set_highlight(terms, highlight_group) end for _, v in pairs(terms) do - print("Add highlight for word: " .. v) vim.cmd('let m=matchadd("' .. highlight_group .. '", "' .. v .. '")') end end -- cgit v1.2.3 From cbbaf010f6d872187e08473350ae0ad43d8cad84 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 11:36:32 +0430 Subject: luaString highlight group is not always available --- lua/core/info.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index 825f8fa7..087157c4 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -193,8 +193,8 @@ function M.toggle_popup(ft) vim.cmd [[let m=matchadd("DashboardHeader", "Language Server Protocol (LSP) info")]] vim.cmd [[let m=matchadd("DashboardHeader", "Formatters and linters")]] vim.cmd('let m=matchadd("LvimInfoIdentifier", " ' .. ft .. '$")') - vim.cmd 'let m=matchadd("luaString", "true")' - vim.cmd 'let m=matchadd("luaError", "false")' + vim.cmd 'let m=matchadd("string", "true")' + vim.cmd 'let m=matchadd("error", "false")' tbl_set_highlight(null_ls_providers, "LvimInfoIdentifier") tbl_set_highlight(missing_formatters, "LvimInfoIdentifier") tbl_set_highlight(missing_linters, "LvimInfoIdentifier") -- cgit v1.2.3 From 47915dd33ef3ed4cc662c5f68b16d68f4f230ec2 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 12:03:58 +0430 Subject: `` mapping must end with `` --- lua/core/which-key.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua') diff --git a/lua/core/which-key.lua b/lua/core/which-key.lua index d75b2c70..96f3a8f7 100644 --- a/lua/core/which-key.lua +++ b/lua/core/which-key.lua @@ -68,7 +68,7 @@ M.config = function() ["c"] = { "BufferClose!", "Close Buffer" }, ["e"] = { "lua require'core.nvimtree'.toggle_tree()", "Explorer" }, ["f"] = { "Telescope find_files", "Find File" }, - ["h"] = { "nohlsearch", "No Highlight" }, + ["h"] = { "nohlsearch", "No Highlight" }, b = { name = "Buffers", j = { "BufferPick", "jump to buffer" }, -- cgit v1.2.3 From 333b1034255e0ac38124d814cebaf32ed5cbba8d Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 14:41:36 +0430 Subject: Fix lunarvim info nil issue (#1289) * fix lunarvim info nil issue * fix num_caps counting issue --- lua/core/info.lua | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'lua') diff --git a/lua/core/info.lua b/lua/core/info.lua index 087157c4..56fc3ca2 100644 --- a/lua/core/info.lua +++ b/lua/core/info.lua @@ -130,13 +130,27 @@ end function M.toggle_popup(ft) local client = u.get_active_client_by_ft(ft) - local is_client_active = not client.is_stopped() - local client_enabled_caps = require("lsp").get_ls_capabilities(client.id) - local num_caps = vim.tbl_count(client_enabled_caps) + local is_client_active = false + local client_enabled_caps = {} + local client_name = "" + local client_id = 0 + local document_formatting = false + local missing_linters = {} + local missing_formatters = {} + local num_caps = 0 local null_ls_providers = null_ls_handler.get_registered_providers_by_filetype(ft) - - local missing_linters = lvim.lang[ft].linters._failed_requests or {} - local missing_formatters = lvim.lang[ft].formatters._failed_requests or {} + if client ~= nil then + is_client_active = not client.is_stopped() + client_enabled_caps = require("lsp").get_ls_capabilities(client.id) + num_caps = vim.tbl_count(client_enabled_caps) + client_name = client.name + client_id = client.id + document_formatting = client.resolved_capabilities.document_formatting + end + if lvim.lang[ft] ~= nil then + missing_linters = lvim.lang[ft].linters._failed_requests or {} + missing_formatters = lvim.lang[ft].formatters._failed_requests or {} + end local buf_lines = {} vim.list_extend(buf_lines, M.banner) @@ -150,9 +164,9 @@ function M.toggle_popup(ft) local lsp_info = { indent .. "Language Server Protocol (LSP) info", - indent .. "* Associated server: " .. client.name, - indent .. "* Active: " .. tostring(is_client_active) .. " (id: " .. tostring(client.id) .. ")", - indent .. "* Supports formatting: " .. tostring(client.resolved_capabilities.document_formatting), + indent .. "* Associated server: " .. client_name, + indent .. "* Active: " .. tostring(is_client_active) .. " (id: " .. tostring(client_id) .. ")", + indent .. "* Supports formatting: " .. tostring(document_formatting), indent .. "* Capabilities list: " .. table.concat(vim.list_slice(client_enabled_caps, 1, num_caps / 2), ", "), indent .. indent .. indent .. table.concat(vim.list_slice(client_enabled_caps, ((num_caps / 2) + 1)), ", "), "", @@ -200,7 +214,7 @@ function M.toggle_popup(ft) tbl_set_highlight(missing_linters, "LvimInfoIdentifier") -- tbl_set_highlight(u.get_supported_formatters_by_filetype(ft), "LvimInfoIdentifier") -- tbl_set_highlight(u.get_supported_linters_by_filetype(ft), "LvimInfoIdentifier") - vim.cmd('let m=matchadd("LvimInfoIdentifier", "' .. client.name .. '")') + vim.cmd('let m=matchadd("LvimInfoIdentifier", "' .. client_name .. '")') end return M.create_simple_popup(buf_lines, set_syntax_hl) -- cgit v1.2.3 From b26b61e3041b860967640e7172eac87f16b258d9 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Wed, 11 Aug 2021 14:50:01 +0430 Subject: fix nil exception for langs without providers (#1290) --- lua/lsp/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 0d08ecee..e4ea02db 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -140,8 +140,10 @@ function M.setup(lang) end end - local lspconfig = require "lspconfig" - lspconfig[lsp.provider].setup(lsp.setup) + if lsp.provider ~= nil and lsp.provider ~= "" then + local lspconfig = require "lspconfig" + lspconfig[lsp.provider].setup(lsp.setup) + end end return M -- cgit v1.2.3 From 5a7630cac761e91335d2f25cb07a81271569c791 Mon Sep 17 00:00:00 2001 From: Ahmed Khalf Date: Wed, 11 Aug 2021 16:00:41 +0400 Subject: Add spell checking to git commit filetype (#1291) --- lua/core/autocmds.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lua') diff --git a/lua/core/autocmds.lua b/lua/core/autocmds.lua index c00e4ba7..91278544 100644 --- a/lua/core/autocmds.lua +++ b/lua/core/autocmds.lua @@ -56,6 +56,10 @@ lvim.autocommands = { -- {'BufWinEnter', '.gmi', 'setlocal filetype=markdown'}, {'BufRead', '*.gmi', 'setlocal filetype=markdown'}, -- {'BufNewFile', '*.gmi', 'setlocal filetype=markdown'} -- }, + _git = { + { "FileType", "gitcommit", "setlocal wrap" }, + { "FileType", "gitcommit", "setlocal spell" }, + }, _markdown = { { "FileType", "markdown", "setlocal wrap" }, { "FileType", "markdown", "setlocal spell" }, -- cgit v1.2.3