From fe65abed359c1c4d0312f5d7f3eab89b70f84c39 Mon Sep 17 00:00:00 2001 From: ray-x Date: Thu, 27 May 2021 11:10:32 +1000 Subject: [PATCH] allow change log level to trace from config --- lua/navigator.lua | 4 ++-- lua/navigator/lspclient/attach.lua | 8 +++++++- lua/navigator/lspclient/clients.lua | 8 ++++---- lua/navigator/util.lua | 8 +++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lua/navigator.lua b/lua/navigator.lua index 85c86ea..d4c5a2f 100644 --- a/lua/navigator.lua +++ b/lua/navigator.lua @@ -10,8 +10,8 @@ _NgConfigValues = { -- -- your on_attach will be called at end of navigator on_attach -- end, sumneko_root_path = vim.fn.expand("$HOME") .. "/github/sumneko/lua-language-server", - sumneko_binary = vim.fn.expand("$HOME") .. - "/github/sumneko/lua-language-server/bin/macOS/lua-language-server", + sumneko_binary = vim.fn.expand("$HOME") + .. "/github/sumneko/lua-language-server/bin/macOS/lua-language-server", code_action_prompt = {enable = true, sign = true, sign_priority = 40, virtual_text = true}, treesitter_analysis = true, -- treesitter variable context lsp = { diff --git a/lua/navigator/lspclient/attach.lua b/lua/navigator/lspclient/attach.lua index 5ff476b..e39a3c9 100644 --- a/lua/navigator/lspclient/attach.lua +++ b/lua/navigator/lspclient/attach.lua @@ -12,7 +12,13 @@ end local M = {} M.on_attach = function(client, bufnr) - log("attaching", bufnr, client.name) + + local uri = vim.uri_from_bufnr(bufnr) + if uri == "file://" or uri == "file:///" then + log("skip for float buffer", uri) + return + end + log("attaching", bufnr, client.name, uri) trace(client) 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 bcfc8dd..a26f0eb 100644 --- a/lua/navigator/lspclient/clients.lua +++ b/lua/navigator/lspclient/clients.lua @@ -8,8 +8,8 @@ _LoadedClients = {} if packer_plugins ~= nil then -- packer installed local loader = require"packer".loader - if not packer_plugins["neovim/nvim-lspconfig"] or - not packer_plugins["neovim/nvim-lspconfig"].loaded then + if not packer_plugins["neovim/nvim-lspconfig"] + or not packer_plugins["neovim/nvim-lspconfig"].loaded then loader("nvim-lspconfig") end if not packer_plugins["ray-x/guihua.lua"] or not packer_plugins["guihua.lua"].loaded then @@ -117,8 +117,8 @@ local setups = { }, rust_analyzer = { root_dir = function(fname) - return util.root_pattern("Cargo.toml", "rust-project.json", ".git")(fname) or - util.path.dirname(fname) + return util.root_pattern("Cargo.toml", "rust-project.json", ".git")(fname) + or util.path.dirname(fname) end, filetypes = {"rust"}, message_level = vim.lsp.protocol.MessageType.error, diff --git a/lua/navigator/util.lua b/lua/navigator/util.lua index b71eaa1..6e5dacf 100644 --- a/lua/navigator/util.lua +++ b/lua/navigator/util.lua @@ -85,8 +85,14 @@ function M.get_relative_path(base_path, my_path) return data end -local default_config = {plugin = "navigator", use_console = false, use_file = true, level = "error"} +local level = "error" +if _NgConfigValues.debug == true then + level = "debug" +elseif _NgConfigValues.debug == "trace" then + level = "trace" +end +local default_config = {plugin = "navigator", use_console = false, use_file = true, level = level} M._log = require("guihua.log").new({level = default_config.level}, true) -- add log to you lsp.log