diff options
| author | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-02-25 01:17:08 +0100 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-02-25 01:17:08 +0100 |
| commit | 336b2de4b36ad9eafdef6c5e882bc08a66d7c959 (patch) | |
| tree | 838df5f79e13b8b598f81113cf83d9c98f9a405f | |
| parent | bbe5d2d967a1a77328c71e11823bb57d56ee044c (diff) | |
pcall now prints error, fixed cmp luasnip
| -rw-r--r-- | lua/user/autopairs.lua | 27 | ||||
| -rw-r--r-- | lua/user/bufferline.lua | 5 | ||||
| -rw-r--r-- | lua/user/cmp.lua | 11 | ||||
| -rw-r--r-- | lua/user/lsp/ccls.lua | 5 | ||||
| -rw-r--r-- | lua/user/lsp/handlers.lua | 5 | ||||
| -rw-r--r-- | lua/user/lsp/init.lua | 6 | ||||
| -rw-r--r-- | lua/user/lsp/mason.lua | 84 | ||||
| -rw-r--r-- | lua/user/nvim-tree.lua | 14 | ||||
| -rw-r--r-- | lua/user/plugins.lua | 6 |
9 files changed, 105 insertions, 58 deletions
diff --git a/lua/user/autopairs.lua b/lua/user/autopairs.lua index be94c26..6032164 100644 --- a/lua/user/autopairs.lua +++ b/lua/user/autopairs.lua @@ -1,10 +1,24 @@ --- Setup nvim-cmp. -local status_ok, npairs = pcall(require, "nvim-autopairs") -if not status_ok then +local nvim_autopairs_status, nvim_autopairs = pcall(require, "nvim-autopairs") +if not nvim_autopairs_status then + print("autopairs.lua: loading nvim-autopairs failed") return end -npairs.setup { +local cmp_autopairs_status, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp") +if not cmp_autopairs_status then + print("autopairs.lua: loading cmp_autopairs failed") + return +end + +local cmp_status, cmp = pcall(require, "cmp") +if not cmp_status then + print("autopairs.lua: loading cmp failed") + return +end + + +-- nvim-cmp +nvim_autopairs.setup { check_ts = true, ts_config = { lua = { "string", "source" }, @@ -25,9 +39,4 @@ npairs.setup { }, } -local cmp_autopairs = require "nvim-autopairs.completion.cmp" -local cmp_status_ok, cmp = pcall(require, "cmp") -if not cmp_status_ok then - return -end cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) diff --git a/lua/user/bufferline.lua b/lua/user/bufferline.lua index 95464ee..fb7431b 100644 --- a/lua/user/bufferline.lua +++ b/lua/user/bufferline.lua @@ -1,5 +1,6 @@ -local status_ok, bufferline = pcall(require, "bufferline") -if not status_ok then +local bufferline_status, bufferline = pcall(require, "bufferline") +if not bufferline_status then + print("bufferline.lua: loading bufferline failed") return end diff --git a/lua/user/cmp.lua b/lua/user/cmp.lua index 39bde60..bb475a3 100644 --- a/lua/user/cmp.lua +++ b/lua/user/cmp.lua @@ -1,10 +1,12 @@ -local cmp_status_ok, cmp = pcall(require, "cmp") -if not cmp_status_ok then +local cmp_status, cmp = pcall(require, "cmp") +if not cmp_status then + print("cmp.lua: loading cmp failed") return end -local snip_status_ok, luasnip = pcall(require, "luasnip") -if not snip_status_ok then +local luasnip_status, luasnip = pcall(require, "luasnip") +if not luasnip_status then + print("cmp.lua: loading luasnip failed") return end @@ -42,7 +44,6 @@ local kind_icons = { Operator = "", TypeParameter = "", } --- find more here: https://www.nerdfonts.com/cheat-sheet cmp.setup { snippet = { diff --git a/lua/user/lsp/ccls.lua b/lua/user/lsp/ccls.lua index b3393da..ef3c179 100644 --- a/lua/user/lsp/ccls.lua +++ b/lua/user/lsp/ccls.lua @@ -1,5 +1,6 @@ -local status, lspconfig = pcall(require, "lspconfig") -if not status then +local lspconfig_status, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status then + print("lsp/ccls.lua: loading lspconfig failed") return end diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua index ee802b9..eabeae6 100644 --- a/lua/user/lsp/handlers.lua +++ b/lua/user/lsp/handlers.lua @@ -95,8 +95,9 @@ end local capabilities = vim.lsp.protocol.make_client_capabilities() -local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") -if not status_ok then +local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not cmp_nvim_lsp_status then + print("lsp/handlers.lua: loading cmp_nvim_lsp failed") return end diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua index 4ac9a3e..2714c99 100644 --- a/lua/user/lsp/init.lua +++ b/lua/user/lsp/init.lua @@ -1,8 +1,2 @@ require "user.lsp.mason" - -local status, lspconfig = pcall(require, "lspconfig") -if not status then - return -end - require "user.lsp.ccls" diff --git a/lua/user/lsp/mason.lua b/lua/user/lsp/mason.lua index 2c14313..8425934 100644 --- a/lua/user/lsp/mason.lua +++ b/lua/user/lsp/mason.lua @@ -1,43 +1,81 @@ -local status, mason = pcall(require, "mason") -if not status then +local mason_status, mason = pcall(require, "mason") +if not mason_status then + print("lsp/mason.lua: loading mason failed") return end --- mason -mason.setup({ +local mason_lspconfig_status, mason_lspconfig = pcall(require, "mason-lspconfig") +if not mason_lspconfig_status then + print("lsp/mason.lua: loading mason-lspconfig failed") + return +end + +local lspconfig_status, lspconfig = pcall(require, "lspconfig") +if not lspconfig_status then + print("lsp/mason.lua: loading lspconfig failed") + return +end + +local mason_null_ls_status, mason_null_ls = pcall(require, "mason-null-ls") +if not mason_null_ls_status then + print("lsp/mason.lua: loading mason-null-ls failed") + return +end + +local null_ls_status, null_ls = pcall(require, "null-ls") +if not null_ls_status then + print("lsp/mason.lua: loading null-ls failed") + return +end + + +local settings = { ui = { + border = "none", icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } -}) + package_installed = "◍", + package_pending = "◍", + package_uninstalled = "◍", + }, + }, + log_level = vim.log.levels.INFO, + max_concurrent_installers = 4, +} --- mason-lspconfig -require("mason-lspconfig").setup { - ensure_installed = { "pylsp", "bashls", "lua_ls", "cmake" }, +local servers = { + "pylsp", "bashls", "lua_ls", "cmake" } -require("mason-lspconfig").setup_handlers { + + +-- mason +mason.setup(settings) + +-- mason-lspconfig +mason_lspconfig.setup({ + ensure_installed = servers, + automatic_installation = true, +}) + +table.insert(servers, "ccls") +mason_lspconfig.setup_handlers { function(server_name) - require("lspconfig")[server_name].setup {} - end + lspconfig[server_name].setup { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + end, } -- mason-null-ls -require('mason-null-ls').setup({ +mason_null_ls.setup({ automatic_setup = true, - ensure_installed = {} + ensure_installed = {}, }) -require('mason-null-ls').setup_handlers { +mason_null_ls.setup_handlers { function(source_name, methods) require("mason-null-ls.automatic_setup")(source_name, methods) end, } -- null_ls -local status, null_ls = pcall(require, "null-ls") -if not status then - return -end null_ls.setup() diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua index 932cbbe..7a65321 100644 --- a/lua/user/nvim-tree.lua +++ b/lua/user/nvim-tree.lua @@ -1,16 +1,16 @@ --- following options are the default --- each of these are documented in `:help nvim-tree.OPTION_NAME` - -local status_ok, nvim_tree = pcall(require, "nvim-tree") -if not status_ok then +local nvim_tree_status, nvim_tree = pcall(require, "nvim-tree") +if not nvim_tree_status then + print("nvim-tree.lua: loading nvim-tree failed") return end -local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") -if not config_status_ok then +local nvim_tree_config_status, nvim_tree_config = pcall(require, "nvim-tree.config") +if not nvim_tree_config_status then + print("nvim-tree.lua: loading nvim-tree.config failed") return end + local tree_cb = nvim_tree_config.nvim_tree_callback nvim_tree.setup { diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua index 3129e1b..b4947d1 100644 --- a/lua/user/plugins.lua +++ b/lua/user/plugins.lua @@ -14,8 +14,9 @@ vim.cmd([[ augroup end ]]) -local status, packer = pcall(require, "packer") -if not status then +local packer_status, packer = pcall(require, "packer") +if not packer_status then + print("plugins.lua: loading packer failed") return end @@ -39,6 +40,7 @@ return packer.startup(function(use) use "hrsh7th/cmp-path" use "hrsh7th/cmp-cmdline" use "hrsh7th/cmp-nvim-lua" + use "L3MON4D3/LuaSnip" -- LSP, linters & formatters |
