Refactor plugin configs for safe import

This commit is contained in:
Arkaprabha Chakraborty
2023-03-05 07:23:25 +05:30
parent 83d16eaddd
commit 38bb5e1b6a
7 changed files with 139 additions and 127 deletions

View File

@@ -42,7 +42,7 @@ if colorscheme == "onedark" then
}) })
-- Load One Dark -- Load One Dark
require("onedark").load() onedark.load()
end end
if colorscheme == "catppuccin" then if colorscheme == "catppuccin" then
@@ -96,7 +96,7 @@ if colorscheme == "catppuccin" then
}) })
-- Load Catppuccin -- Load Catppuccin
require("catppuccin").load() catppuccin.load()
end end
if colorscheme == "gruvbox" then if colorscheme == "gruvbox" then
@@ -126,5 +126,5 @@ if colorscheme == "gruvbox" then
}) })
-- Load Gruvbox -- Load Gruvbox
require("gruvbox").load() gruvbox.load()
end end

View File

@@ -55,17 +55,6 @@ cmp.setup({
end end
end, { "i", "s" }), end, { "i", "s" }),
}, },
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end,
},
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
@@ -79,4 +68,19 @@ cmp.setup({
experimental = { experimental = {
ghost_text = false, ghost_text = false,
}, },
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local lk_ok, lspkind = pcall(require, "lspkind")
if not lk_ok then
return
end
local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end,
},
}) })

View File

@@ -1,5 +1,5 @@
-- disable netrw -- disable netrw
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1
-- set termguicolors to enable highlight groups -- set termguicolors to enable highlight groups

View File

@@ -19,7 +19,12 @@ mason_lspconfig.setup({
ensure_installed = { "lua_ls", "rust_analyzer", "clangd" }, ensure_installed = { "lua_ls", "rust_analyzer", "clangd" },
}) })
local capabilities = require("cmp_nvim_lsp").default_capabilities() local cnl_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not cnl_ok then
return
end
local capabilities = cmp_nvim_lsp.default_capabilities()
mason_lspconfig.setup_handlers({ mason_lspconfig.setup_handlers({
function(server) function(server)

View File

@@ -68,8 +68,11 @@ packer.startup(function(use)
use({ use({
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
run = function() run = function()
local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) local ntsi_ok, nvim_treesitter_install = pcall(require, "nvim-treesitter.install")
if ntsi_ok then
local ts_update = nvim_treesitter_install.install.update({ with_sync = true })
ts_update() ts_update()
end
end, end,
}) })