feat: disable lsp_lines by default

This commit is contained in:
Matthew Leong 2022-12-30 13:00:04 -08:00
parent 11fecdb9d0
commit 96499d0d67
3 changed files with 29 additions and 26 deletions

View file

@ -17,7 +17,7 @@
"lualine.nvim": { "branch": "master", "commit": "32a7382a75a52e8ad05f4cec7eeb8bbfbe80d461" }, "lualine.nvim": { "branch": "master", "commit": "32a7382a75a52e8ad05f4cec7eeb8bbfbe80d461" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "aa25b4153d2f2636c3b3a8c8360349d2b29e7ae3" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "aa25b4153d2f2636c3b3a8c8360349d2b29e7ae3" },
"mason.nvim": { "branch": "main", "commit": "1592493e3406c271e9128b4d424731e25f1ff2a1" }, "mason.nvim": { "branch": "main", "commit": "1592493e3406c271e9128b4d424731e25f1ff2a1" },
"noice.nvim": { "branch": "main", "commit": "7816fcd8a43a9de84d7f4695b0688b4f54b25570" }, "noice.nvim": { "branch": "main", "commit": "6aa6585da8cf9ffa44575b320b4d64d50f3c13a2" },
"nui.nvim": { "branch": "main", "commit": "4939282919885e1c83aff68ecb35b3cadf6015a9" }, "nui.nvim": { "branch": "main", "commit": "4939282919885e1c83aff68ecb35b3cadf6015a9" },
"null-ls.nvim": { "branch": "main", "commit": "647a1eeeefc43ce15d941972642210637c370471" }, "null-ls.nvim": { "branch": "main", "commit": "647a1eeeefc43ce15d941972642210637c370471" },
"nvim-autopairs": { "branch": "master", "commit": "03580d758231956d33c8dd91e2be195106a79fa4" }, "nvim-autopairs": { "branch": "master", "commit": "03580d758231956d33c8dd91e2be195106a79fa4" },

View file

@ -11,7 +11,7 @@ local default_config = {
-- true - loads plugin and is enabled at start -- true - loads plugin and is enabled at start
-- false - loads plugin but is not enabled at start -- false - loads plugin but is not enabled at start
-- you may use <leader>ld to toggle -- you may use <leader>ld to toggle
enable_on_start = true, enable_on_start = false,
}, },
}, },
lsp = { lsp = {

View file

@ -1,33 +1,36 @@
local u = require('cosmic.utils')
local user_config = require('cosmic.core.user') local user_config = require('cosmic.core.user')
return { local vt_config = require('cosmic.lsp.diagnostics.config')
event = 'VeryLazy', local map = require('cosmic.utils').map
url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim', local is_plugin_enabled = user_config.plugins.lsp_lines.enable_on_start
config = function() local function toggle()
local u = require('cosmic.utils') if is_plugin_enabled then
local map = require('cosmic.utils').map vim.diagnostic.config(u.merge(vt_config, {
local vt_config = require('cosmic.lsp.diagnostics.config') virtual_text = false,
local is_plugin_enabled = user_config.plugins.lsp_lines.enable_on_start virtual_lines = true,
}))
else
vim.diagnostic.config(u.merge(vt_config, {
virtual_lines = false,
}))
end
is_plugin_enabled = not is_plugin_enabled
end
return {
url = 'https://git.sr.ht/~whynothugo/lsp_lines.nvim',
keys = {
{
'<leader>ld',
toggle,
desc = 'Enable lsp_lines',
},
},
config = function()
-- init lsp_lines -- init lsp_lines
require('lsp_lines').setup() require('lsp_lines').setup()
local function toggle()
if is_plugin_enabled then
vim.diagnostic.config(u.merge(vt_config, {
virtual_text = false,
virtual_lines = true,
}))
else
vim.diagnostic.config(u.merge(vt_config, {
virtual_lines = false,
}))
end
is_plugin_enabled = not is_plugin_enabled
end
-- run once to properly show/hide based on user config -- run once to properly show/hide based on user config
toggle() toggle()
-- map for toggling lines -- map for toggling lines
map('n', '<leader>ld', '', { map('n', '<leader>ld', '', {
callback = toggle, callback = toggle,