From f92160080e2826631d5de5d9c751e176ec07cc1f Mon Sep 17 00:00:00 2001 From: ray-x Date: Mon, 26 Apr 2021 21:21:01 +1000 Subject: [PATCH] code clean up, remove lsp-status --- README.md | 12 +++++- lua/navigator.lua | 2 +- lua/navigator/lspclient/attach.lua | 12 ------ lua/navigator/lspclient/clients.lua | 67 +++-------------------------- 4 files changed, 17 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 6f138f7..490a03f 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,6 @@ Generally speaking, you could remove most part of your lspconfig.lua and use the - guihua.lua (provides floating window, FZY) - Optional: - treesitter (list treesitter symbols) - - lsp-status - lsp-signature - vim-illuminate @@ -93,6 +92,17 @@ Please refer to lua/navigator/lspclient/mapping.lua on key mappings. Should be a - (or \, \) to move - \ to open location or apply code actions +## Configuration + +In `navigator.lua` there is a default configration. You can override the values by pass you own values + +e.g + +```lua +-- The attach will be call at end of navigator on_attach() +require'navigator'.setup({on_attach = function(client, bufnr) require 'illuminate'.on_attach(client)}) +``` + ## Screenshots colorscheme: [aurora](https://github.com/ray-x/aurora) diff --git a/lua/navigator.lua b/lua/navigator.lua index 57de288..d8de119 100644 --- a/lua/navigator.lua +++ b/lua/navigator.lua @@ -1,6 +1,6 @@ local M = {} _NgConfigValues ={ - debug = false, -- log output + debug = false, -- log output not implemented code_action_icon = ' ', width = nil, -- valeu of cols TODO allow float e.g. 0.6 height = nil, diff --git a/lua/navigator/lspclient/attach.lua b/lua/navigator/lspclient/attach.lua index 5ebae42..124da37 100644 --- a/lua/navigator/lspclient/attach.lua +++ b/lua/navigator/lspclient/attach.lua @@ -3,15 +3,6 @@ local lsp = require("vim.lsp") local util = require "navigator.util" local log = util.log -if packer_plugins ~= nil then - if not packer_plugins["nvim-lua/lsp-status.nvim"] or not packer_plugins["lsp-status.nvim"].loaded then - vim.cmd [[silent! packadd lsp-status.nvim]] - end -end -local lsp_status = nil -if package.loaded["lsp-status"] then - lsp_status = require("lsp-status") -end local diagnostic_map = function(bufnr) local opts = {noremap = true, silent = true} @@ -44,9 +35,6 @@ end M.on_attach = function(client, bufnr) log("attaching") - if lsp_status ~= nil then - lsp_status.on_attach(client, bufnr) - end local hassig, sig = pcall(require, "lsp_signature") if hassig then diff --git a/lua/navigator/lspclient/clients.lua b/lua/navigator/lspclient/clients.lua index c781dbb..daf6f93 100644 --- a/lua/navigator/lspclient/clients.lua +++ b/lua/navigator/lspclient/clients.lua @@ -1,15 +1,10 @@ -- todo allow config passed in local lspconfig = nil -local lsp_status = nil if packer_plugins ~= nil then if not packer_plugins["neovim/nvim-lspconfig"] or not packer_plugins["neovim/nvim-lspconfig"].loaded then vim.cmd [[packadd nvim-lspconfig]] end - if not packer_plugins["nvim-lua/lsp-status.nvim"] or not packer_plugins["lsp-status.nvim"].loaded then - vim.cmd [[silent! packadd lsp-status.nvim]] - -- if lazyloading - end if not packer_plugins["ray-x/guihua.lua"] or not packer_plugins["guihua.lua"].loaded then vim.cmd [[packadd guihua.lua]] -- if lazyloading @@ -18,9 +13,6 @@ end if package.loaded["lspconfig"] then lspconfig = require "lspconfig" end -if package.loaded["lsp-status"] then - lsp_status = require("lsp-status") -end local highlight = require "navigator.lspclient.highlight" if lspconfig == nil then @@ -30,34 +22,6 @@ local config = require "navigator".config_values() local cap = vim.lsp.protocol.make_client_capabilities() local on_attach = require("navigator.lspclient.attach").on_attach -local lsp_status_cfg = { - status_symbol = " ", - indicator_errors = " ", --' ', - indicator_warnings = " ", --' ', - indicator_info = "﯎", - --' ', - indicator_hint = "💡", - indicator_ok = " ", - --'✔️', - spinner_frames = {"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"}, - select_symbol = function(cursor_pos, symbol) - if symbol.valuerange then - local value_range = { - ["start"] = { - character = 0, - line = vim.fn.byte2line(symbol.valuerange[1]) - }, - ["end"] = { - character = 0, - line = vim.fn.byte2line(symbol.valuerange[2]) - } - } - - return require("lsp-status.util").in_range(cursor_pos, value_range) - end - end -} - -- local gopls = {} -- gopls["ui.completion.usePlaceholders"] = true @@ -140,7 +104,6 @@ local rust_cfg = { local sqls_cfg = { on_attach = function(client, bufnr) client.resolved_capabilities.execute_command = true - lsp_status.on_attach(client, bufnr) highlight.diagnositc_config_sign() require "sqls".setup {picker = "telescope"} -- or default end, @@ -223,23 +186,12 @@ local servers = { "terraformls" } -local function lsp_status_setup() - if lsp_status ~= nil then - lsp_status.register_progress() - - lsp_status.config(lsp_status_cfg) - end - highlight.diagnositc_config_sign() - highlight.add_highlight() -end - local function setup(user_opts) if lspconfig == nil then error("lsp-config need installed and enabled") return end - lsp_status_setup() for _, lspclient in ipairs(servers) do if lspconfig[lspclient] == nil then print("not supported", lspclient) @@ -259,20 +211,11 @@ local function setup(user_opts) end end - if lsp_status ~= nil and lsp_status.capabilities ~= nil then - lspconfig[lspclient].setup { - message_level = vim.lsp.protocol.MessageType.error, - log_level = vim.lsp.protocol.MessageType.error, - on_attach = on_attach, - capabilities = vim.tbl_extend('keep', lspconfig[lspclient].capabilities or {}, lsp_status.capabilities) - } - else - lspconfig[lspclient].setup { - message_level = vim.lsp.protocol.MessageType.error, - log_level = vim.lsp.protocol.MessageType.error, - on_attach = on_attach - } - end + lspconfig[lspclient].setup { + message_level = vim.lsp.protocol.MessageType.error, + log_level = vim.lsp.protocol.MessageType.error, + on_attach = on_attach + } ::continue:: end