From 98a141b4b5c91cfd44e161ead3aedb99e08eac00 Mon Sep 17 00:00:00 2001 From: "asep.komarudin" Date: Wed, 26 Jun 2024 12:25:53 +0700 Subject: [PATCH] add: lualine null-ls validation --- lazy-lock.json | 10 +++------- lua/plugins/nonels.lua | 1 + lua/user/utils/formatter.lua | 12 ++++++++---- lua/user/utils/linter.lua | 30 +++++++++++++++++++----------- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 7e86f2c..c194072 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,6 +1,5 @@ { "Comment.nvim": { "branch": "master", "commit": "e51f2b142d88bb666dcaa77d93a07f4b419aca70" }, - "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, @@ -17,8 +16,8 @@ "dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" }, "friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" }, "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, - "indent-blankline.nvim": { "branch": "master", "commit": "4036c8ae9cc29faf8e6443fa5b23e679db055d24" }, - "lazy.nvim": { "branch": "main", "commit": "378bfb465673a747e9e9f966e518063499e20cfe" }, + "indent-blankline.nvim": { "branch": "master", "commit": "4288ce8128a52650e401dda42fd7651a6038f262" }, + "lazy.nvim": { "branch": "main", "commit": "69041bccb70f68408633e93ed33012ee18889bb0" }, "lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, @@ -26,8 +25,6 @@ "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mini.indentscope": { "branch": "main", "commit": "56d42be090e8fcc68eda69cfe55af8c5e562300e" }, "neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" }, - "neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" }, - "neotest-java": { "branch": "main", "commit": "320f31c71b183f2c584198f33f93542fd0e5a768" }, "noice.nvim": { "branch": "main", "commit": "d580646db85f49b8226d52b143a458161f41954a" }, "none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" }, "none-ls.nvim": { "branch": "main", "commit": "f1b438ab1709cf9d8875843559d20265013ac755" }, @@ -38,7 +35,6 @@ "nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" }, "nvim-material-icon": { "branch": "main", "commit": "5ad42234d880659dfe9d4ff936c310cd6c5a1610" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, - "nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-scrollview": { "branch": "main", "commit": "fd334e5ad0c616987d1b9114890a59c97165cf83" }, "nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" }, @@ -53,7 +49,7 @@ "rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" }, "rest.nvim": { "branch": "main", "commit": "91badd46c60df6bd9800c809056af2d80d33da4c" }, "smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" }, - "telescope.nvim": { "branch": "master", "commit": "58ec6eca1c3704d130d749843e16fbf6c8cdc57e" }, + "telescope.nvim": { "branch": "master", "commit": "61a4a615366c470a4e9ca8f8b45718b6b92af73f" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "9be4af5b1bc1f26a11206ed7ce8bf44312e7941a" }, "toggleterm.nvim": { "branch": "main", "commit": "cd55bf6aab3f88c259fa29ea86bbdcb1a325687d" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, diff --git a/lua/plugins/nonels.lua b/lua/plugins/nonels.lua index db824f0..809376b 100644 --- a/lua/plugins/nonels.lua +++ b/lua/plugins/nonels.lua @@ -2,6 +2,7 @@ return { { "nvimtools/none-ls.nvim", lazy = true, + enabled = false, dependencies = { { "jayp0521/mason-null-ls.nvim", diff --git a/lua/user/utils/formatter.lua b/lua/user/utils/formatter.lua index 32cf578..1fba9cb 100644 --- a/lua/user/utils/formatter.lua +++ b/lua/user/utils/formatter.lua @@ -1,10 +1,14 @@ -local null_ls = require("null-ls") +local ok, null_ls = pcall(require, "null-ls") local M = {} M.list_registered = function(filetype) - local method = null_ls.methods.FORMATTING - local registered_providers = require("user.utils.lsp").list_registered_providers_names(filetype) - return registered_providers[method] or {} + if ok then + local method = null_ls.methods.FORMATTING + local registered_providers = require("user.utils.lsp").list_registered_providers_names(filetype) + return registered_providers[method] or {} + else + return {} + end end M.list_registered_all = function() diff --git a/lua/user/utils/linter.lua b/lua/user/utils/linter.lua index 3ab99e4..5fbb7b5 100644 --- a/lua/user/utils/linter.lua +++ b/lua/user/utils/linter.lua @@ -1,19 +1,27 @@ -local null_ls = require("null-ls") +local ok, null_ls = pcall(require, "null-ls") local M = {} -M.alternative_methods = { - null_ls.methods.DIAGNOSTICS, - null_ls.methods.DIAGNOSTICS_ON_OPEN, - null_ls.methods.DIAGNOSTICS_ON_SAVE, -} +if ok then + M.alternative_methods = { + null_ls.methods.DIAGNOSTICS, + null_ls.methods.DIAGNOSTICS_ON_OPEN, + null_ls.methods.DIAGNOSTICS_ON_SAVE, + } +else + M.alternative_methods = {} +end M.linter_list_registered = function(filetype) - local registered_providers = require("user.utils.lsp").list_registered_providers_names(filetype) - local providers_for_methods = vim.iter(vim.tbl_map(function(m) - return registered_providers[m] or {} - end, M.alternative_methods)) + if ok then + local registered_providers = require("user.utils.lsp").list_registered_providers_names(filetype) + local providers_for_methods = vim.iter(vim.tbl_map(function(m) + return registered_providers[m] or {} + end, M.alternative_methods)) - return providers_for_methods + return providers_for_methods + else + return {} + end end return M