add: config global variable

This commit is contained in:
asep.komarudin 2024-05-21 14:20:50 +07:00
parent 77436b89c4
commit a7726a6b33
30 changed files with 703 additions and 857 deletions

View file

@ -1,14 +1,9 @@
local data_exists, custom_dasboard = pcall(require, "core.config")
if data_exists then
local model = custom_dasboard.model
if model ~= nil then
if model == 1 then
require("user.startify")
else
require("user.dashboard")
end
else
local model = vim.g.pcode_model
if model ~= nil then
if model == 1 then
require("user.startify")
else
require("user.dashboard")
end
else
require("user.startify")

View file

@ -3,7 +3,7 @@ if not status_ok then
return
end
local ico = require("user.icons")
local ico = vim.g.pcode_icons
local icons = ico.kind
navic.setup({

View file

@ -1,22 +1,33 @@
local colorscheme = "gruvbox-baby"
local lst_style =
{ "sonokai", "sonokai_atlantis", "sonokai_andromeda", "sonokai_shusia", "sonokai_maia", "sonokai_espresso" }
local lst_material = { "material", "material_deepocean", "material_palenight", "material_lighter", "material_darker" }
local lst_onedark =
{ "onedark", "onedark_darker", "onedark_cool", "onedark_deep,onedark_warm", "onedark_warmer", "onedark_light" }
local data_exists, config = pcall(require, "core.config")
if data_exists then
if config.colorscheme ~= nil then
colorscheme = config.colorscheme
else
colorscheme = "gruvbox-baby"
end
local transparent_mode = config.transparent_mode
if transparent_mode ~= nil then
if transparent_mode == 1 then
vim.g.gruvbox_baby_transparent_mode = 1
vim.g.sonokai_transparent_background = 2
end
local colorscheme = vim.g.pcode_colorscheme
local lst_style = {
"sonokai",
"sonokai_atlantis",
"sonokai_andromeda",
"sonokai_shusia",
"sonokai_maia",
"sonokai_espresso",
}
local lst_material = {
"material",
"material_deepocean",
"material_palenight",
"material_lighter",
"material_darker",
}
local lst_onedark = {
"onedark",
"onedark_darker",
"onedark_cool",
"onedark_deep,onedark_warm",
"onedark_warmer",
"onedark_light",
}
local transparent_mode = vim.g.pcode_transparent_mode
if transparent_mode ~= nil then
if transparent_mode == 1 then
vim.g.gruvbox_baby_transparent_mode = 1
vim.g.sonokai_transparent_background = 2
end
end
@ -38,10 +49,5 @@ for _, v in pairs(lst_onedark) do
break
end
end
local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not status_ok then
local ok, _ = pcall(vim.cmd, "colorscheme " .. "gruvbox-baby")
if not ok then
return
end
end
vim.cmd("colorscheme " .. colorscheme)

View file

@ -14,12 +14,9 @@ local board = {
[[|_| |__/ ]],
}
local data_exists, custom_dasboard = pcall(require, "core.config")
if data_exists then
local data_board = custom_dasboard.header2
if data_board ~= nil then
board = data_board
end
local data_board = vim.g.pcode_header2
if data_board ~= nil then
board = data_board
end
local dashboard = require("alpha.themes.dashboard")
@ -44,11 +41,9 @@ dashboard.opts.opts.noautocmd = true
alpha.setup(dashboard.opts)
local footer_text = "Pojok Code"
if data_exists then
local data_txt = custom_dasboard.footer
if data_txt ~= nil then
footer_text = data_txt
end
local data_txt = vim.g.pcode_footer
if data_txt ~= nil then
footer_text = data_txt
end
vim.api.nvim_create_autocmd("User", {

View file

@ -1,13 +1,12 @@
local run = 0
local data_exists, frmt = pcall(require, "core.config")
if not data_exists then
run = 1
end
if frmt.format_on_save == 1 then
local frmt = vim.g.pcode_format_on_save
if frmt == 1 then
run = 1
else
run = 0
end
local buf_clients = vim.lsp.buf_get_clients()
local buf_clients = vim.lsp.get_clients()
if next(buf_clients) == nil then
run = 0
end

View file

@ -9,11 +9,8 @@ local lspconfig = require("lspconfig")
-- local servers = { "jdtls", "yamlls" }
local servers = {}
local data_exists, custom_lsp = pcall(require, "core.config")
if data_exists then
for _, client in pairs(custom_lsp.lsp_installer) do
table.insert(servers, client)
end
for _, client in pairs(vim.g.pcode_lsp_installer) do
table.insert(servers, client)
end
lsp_installer.setup({

View file

@ -5,13 +5,8 @@ if not status_cmp_ok then
return
end
local lspvitualtext = false
local data_exists, lspconfig = pcall(require, "core.config")
if data_exists then
lspvitualtext = lspconfig.lsp_virtualtext
end
local icons = require("user.icons")
local lspvitualtext = vim.g.pcode_lsp_virtualtext
local icons = vim.g.pcode_icons
M.capabilities = vim.lsp.protocol.make_client_capabilities()
M.capabilities.textDocument.completion.completionItem.snippetSupport = true

View file

@ -11,31 +11,18 @@ local function idxOf(array, value)
return nil
end
local data_exists, custom_lsp = pcall(require, "core.config")
if data_exists then
for _, client in pairs(custom_lsp.mason_ensure_installed) do
table.insert(servers, client)
end
for _, client in pairs(vim.g.pcode_mason_ensure_installed) do
table.insert(servers, client)
end
local unregis_lsp = {}
local data_ok, unregis = pcall(require, "core.config")
if data_ok then
if unregis.unregister_lsp ~= nil then
unregis_lsp = unregis.unregister_lsp
end
end
local icons = require("user.icons").ui
local unregis_lsp = vim.g.pcode_unregister_lsp
local icons = vim.g.pcode_icons.ui
local settings = {
ui = {
-- border = "none",
border = icons.Border,
icons = {
-- package_installed = "◍",
-- package_pending = "◍",
-- package_uninstalled = "◍",
package_pending = icons.DotCircle,
package_installed = icons.CheckCircle,
package_uninstalled = icons.BlankCircle,

View file

@ -20,12 +20,9 @@ if data_ok then
end
end
local data_exists, data = pcall(require, "core.config")
if data_exists then
-- load data null-ls
for _, nullls in pairs(data.null_ls_ensure_installed) do
table.insert(ensure_installed, nullls)
end
-- load data null-ls
for _, nullls in pairs(vim.g.pcode_null_ls_ensure_installed) do
table.insert(ensure_installed, nullls)
end
local mason_ok, mason_null_ls = pcall(require, "mason-null-ls")
@ -36,11 +33,8 @@ if mason_ok then
end
local run = 0
local ok, frmt = pcall(require, "core.config")
if not ok then
run = 1
end
if frmt.format_on_save == 1 then
local frmt = vim.g.pcode_format_on_save
if frmt == 1 then
run = 1
end

View file

@ -1,39 +0,0 @@
require("onedark").setup({
-- Main options --
style = "darker", -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
transparent = true, -- Show/hide background
term_colors = true, -- Change terminal color as per the selected theme style
ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden
cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu
-- toggle theme style ---
toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, -- List of styles to toggle between
-- Change code style ---
-- Options are italic, bold, underline, none
-- You can configure multiple style with comma seperated, For e.g., keywords = 'italic,bold'
code_style = {
comments = "italic",
keywords = "none",
functions = "none",
strings = "none",
variables = "none",
},
-- Lualine options --
lualine = {
transparent = false, -- lualine center bar transparency
},
-- Custom Highlights --
colors = {}, -- Override default colors
highlights = {}, -- Override highlight groups
-- Plugins Config --
diagnostics = {
darker = true, -- darker colors for diagnostic
undercurl = true, -- use undercurl instead of underline for diagnostics
background = true, -- use background color for virtual text
},
})

View file

@ -9,13 +9,11 @@ dash_model = {
[[ /_/ |___/ ]],
}
local data_exists, custom_dasboard = pcall(require, "core.config")
if data_exists then
local board = custom_dasboard.header1
if board ~= nil then
dash_model = board
end
local board = vim.g.pcode_header1
if board ~= nil then
dash_model = board
end
startify.section.header.val = dash_model
startify.section.top_buttons.val = {
startify.button("F", "󰈞 Find file", ":Telescope find_files <CR>"),
@ -41,11 +39,9 @@ startify.section.bottom_buttons.val = {
}
local footer_text = "Pojok Code"
if data_exists then
local data_txt = custom_dasboard.footer
if data_txt ~= nil then
footer_text = data_txt
end
local data_txt = vim.g.pcode_footer
if data_txt ~= nil then
footer_text = data_txt
end
vim.api.nvim_create_autocmd("User", {

View file

@ -5,17 +5,15 @@ end
local transp = false
local sidebar = "normal" --"dark , transparent, normal"
local hilight = "#292e42"
local data_exists, config = pcall(require, "core.config")
if data_exists then
local tras = config.transparent_mode
if tras == 1 then
transp = true
sidebar = "transparent"
-- hilight = "#3E4254"
-- hilight = "#353a56"
hilight = "#292e42"
end
local tras = vim.g.pcode_transparent_mode
if tras == 1 then
transp = true
sidebar = "transparent"
-- hilight = "#3E4254"
-- hilight = "#353a56"
hilight = "#292e42"
end
tokyonight.setup({
-- your configuration comes here
-- or leave it empty to use the default settings

View file

@ -1,48 +0,0 @@
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end
configs.setup({
ensure_installed = {
"lua",
"vim",
},
ignore_install = { "phpdoc" }, -- List of parsers to ignore installing
highlight = {
enable = true,
disable = { "css" }, -- list of language that will be disabled
additional_vim_regex_highlighting = false,
},
-- context_commentstring = {
-- enable = true,
-- enable_autocmd = false,
-- config = {
-- Languages that have a single comment style
-- typescript = "// %s",
-- css = "/* %s */",
-- scss = "/* %s */",
-- html = "<!-- %s -->",
-- svelte = "<!-- %s -->",
-- vue = "<!-- %s -->",
-- jsx = "{/* %s */}",
-- json = "",
-- },
-- },
-- rainbow = {
-- enable = true,
-- disable = { "html", "tsx" },
-- equery = "rainbow-parens",
-- strategy = require("ts-rainbow").strategy.global,
-- },
-- rainbow = {
-- enable = false,
-- extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
-- max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int
-- },
-- autotag = { enable = true, enable_rename = true, enable_close = true, enable_close_on_slash = true },
incremental_selection = { enable = true },
indent = { enable = true, disable = { "python", "css" } },
autopairs = {
enable = true,
},
})

View file

@ -1,7 +1,7 @@
local hide_in_width = function()
return vim.fn.winwidth(0) > 75
end
local icons = require("user.icons")
local icons = vim.g.pcode_icons
local formatter = require("user.utils.formatter")
local linter = require("user.utils.linter")

View file

@ -1,5 +1,5 @@
local active = true
local icons = require("user.icons")
local icons = vim.g.pcode_icons
local excludes = function()
return vim.tbl_contains({
"help",