migrate config form function to global variable

This commit is contained in:
asep komarudin 2023-03-05 17:34:12 +07:00
parent b6f0601d3d
commit 38d2c29a95
24 changed files with 248 additions and 245 deletions

View file

@ -24,7 +24,7 @@
"lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" }, "lualine.nvim": { "branch": "master", "commit": "e99d733e0213ceb8f548ae6551b04ae32e590c80" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "e4badf7984f7a5f0ac7dc10657dbedbd99a82f94" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "e4badf7984f7a5f0ac7dc10657dbedbd99a82f94" },
"mason-null-ls.nvim": { "branch": "main", "commit": "29ce60f9a16fef3de682a9365ef635f24ae92bf9" }, "mason-null-ls.nvim": { "branch": "main", "commit": "29ce60f9a16fef3de682a9365ef635f24ae92bf9" },
"mason.nvim": { "branch": "main", "commit": "51228a60d1a5017030429ba38f018ff27a460c76" }, "mason.nvim": { "branch": "main", "commit": "2237ebfecf70de911b0e2174128217b3fd6744b4" },
"mini.animate": { "branch": "main", "commit": "b0c717ed5513b5f23e7c48615449c7dc9fabd05b" }, "mini.animate": { "branch": "main", "commit": "b0c717ed5513b5f23e7c48615449c7dc9fabd05b" },
"mini.indentscope": { "branch": "main", "commit": "7998edc970610c05598c7aea3d21ece8dd87ed52" }, "mini.indentscope": { "branch": "main", "commit": "7998edc970610c05598c7aea3d21ece8dd87ed52" },
"neoscroll.nvim": { "branch": "master", "commit": "d7601c26c8a183fa8994ed339e70c2d841253e93" }, "neoscroll.nvim": { "branch": "master", "commit": "d7601c26c8a183fa8994ed339e70c2d841253e93" },

38
lua/core/config.lua Normal file
View file

@ -0,0 +1,38 @@
local config
-- shim vim for kitty and other generators
vim = vim or { g = {}, o = {} }
local function opt(key, default)
key = "pcode_" .. key
if vim.g[key] == nil then
return default
end
-- if vim.g[key] == 0 then
-- return false
-- end
return vim.g[key]
end
config = {
colorscheme = opt("colorscheme", "gruvbox-baby"),
transparent_mode = opt("transparent_mode", 0),
progress = opt("progress", 2),
lualine_style = opt("lualine_style", 0),
status_icon = opt("status_icon", 0),
custom_lualine = opt("custom_lualine", false),
component_separators = opt("component_separators", { left = " ", right = " " }),
section_separators = opt("section_separators", { left = " ", right = " " }),
dashboard1 = opt("dashboard1", nil),
dashboard2 = opt("dashboard2", nil),
footer = opt("footer", nil),
model = opt("model", 1),
format_on_save = opt("format_on_save", 1),
lsp_installer = opt("lsp_installer", {}),
register_lsp = opt("register_lsp", {}),
unregister_lsp = opt("unregister_lsp", {}),
null_ls_sources = opt("null_ls_sources", {}),
whichkey = opt("whichkey", {}),
}
return config

View file

@ -1,3 +1,5 @@
require("custom.default")
require("custom.dashboard")
require("config.lazy") require("config.lazy")
require("user.colorscheme") require("user.colorscheme")
require("user.keymaps") require("user.keymaps")

View file

@ -1,10 +1,8 @@
local M = {}
-- Untuk Ubah Dashboard -- Untuk Ubah Dashboard
-- 1. Buka remark dash board dibawah -- 1. Buka remark dash board dibawah
-- 2. Ubah dashboard sesuai keinginan dan kebutuhan -- 2. Ubah dashboard sesuai keinginan dan kebutuhan
-- M.dashboard1 = { -- vim.g.pcode_dashboard1 = {
-- [[ _ __ __ ]], -- [[ _ __ __ ]],
-- [[ ___ ___ (____ / /__ _______ ___/ ___ ]], -- [[ ___ ___ (____ / /__ _______ ___/ ___ ]],
-- [[ / _ / _ \ / / _ \/ '_/ / __/ _ / _ / -_) ]], -- [[ / _ / _ \ / / _ \/ '_/ / __/ _ / _ / -_) ]],
@ -12,7 +10,7 @@ local M = {}
-- [[ /_/ |___/ ]], -- [[ /_/ |___/ ]],
-- } -- }
-- M.dashboard2 = { -- vim.g.pcode_dashboard2 = {
-- [[ __ ]], -- [[ __ ]],
-- [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], -- [[ ___ ___ ___ __ __ /\_\ ___ ___ ]],
-- [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], -- [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]],
@ -20,8 +18,6 @@ local M = {}
-- [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], -- [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]],
-- [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], -- [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]],
-- } -- }
-- M.footer = "PCode" -- vim.g.pcode_footer = "PCode"
M.model = 1 -- isi dengan 1 atau 2 untuk model dashboard vim.g.pcode_model = 2 -- isi dengan 1 atau 2 untuk model dashboard
return M

115
lua/custom/default.lua Normal file
View file

@ -0,0 +1,115 @@
-- custom colorscheme
-- colorscheme ready :
-- tokyonight, tokyonight-night, tokyonight-storm, tokyonight-day, tokyonight-moon
-- gruvbox-baby (default)
-- sonokai, sonokai_atlantis,
-- sonokai_andromeda,sonokai_shusia,sonokai_maia,sonokai_espresso
-- material, material_deepocean, material_palenight, material_lighter, material_darker
-- onedark, onedark_darker, onedark_cool, onedark_deep,onedark_warm,
-- onedark_warmer, onedark_light
-- lunar
-- nord
-- catppuccin, catppuccin-latte, catppuccin-frappe, catppuccin-macchiato, catppuccin-mocha
-- dracula
-- nightfox, dayfox, dawnfox, duskfox, nordfox, terafox, carbonfox
vim.g.pcode_colorscheme = "gruvbox-baby"
-- custom transparent mode
-- only support
-- gruvbox-baby,
-- tokyonight,
-- sonokai,
-- material
-- onedark
-- catppuccin
-- nord
-- dracula
-- nightfox
-- 0 =off 1= on
vim.g.pcode_transparent_mode = 0
-- 0 disable progress
-- 1 lualine lsp progress
-- 2 fidget progress
vim.g.pcode_progress = 1
-- style
-- 0 = default
-- 1 = { left = "", right = "" },
-- 2 = { left = " ", right = " " },
-- 3 = { left = "", right = "" },
vim.g.pcode_lualine_style = 0
-- style status icon
-- 0 = default
-- 1 = vim icon " "
-- 2 = vim icon " "
vim.g.pcode_status_icon = 0
-- start custom lualine style
-- contoh style
-- {
-- { left = "│", right = "│" },
-- { left = " ", right = " " },
-- },
-- {
-- { left = " ", right = " " },
-- { left = " ", right = "" },
-- },
-- {
-- { left = " ", right = " " },
-- { left = "", right = "" },
-- },
-- {
-- { left = "", right = "" },
-- { left = "", right = "" },
-- },
-- {
-- { left = " ", right = " " },
-- { left = "", right = "" },
-- },
-- }
vim.g.pcode_custom_lualine = false
vim.g.pcode_component_separators = { left = " ", right = " " }
vim.g.pcode_section_separators = { left = "", right = "" }
-- 0 ( format jalan) 1 (fromat off)
vim.g.pcode_format_on_save = 1
-- ini hanya untuk lsp yg tidak support masson
-- untuk referesi support language kunjungi link dibawah
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
vim.g.pcode_lsp_installer = {
"yamlls",
-- tambahkan di bawah sini setelah melakukan :masoninstall
}
-- untuk referesi support language kunjungi link dibawah
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
vim.g.pcode_register_lsp = {
"yamlls",
"intelephense",
"marksman",
"csharp_ls",
"clangd",
"dartls",
"kotlin_language_server",
-- tambahkan di bawah sini setelah melakukan :masoninstall
}
vim.g.pcode_unregister_lsp = {
"jdtls", -- tambahkan di bawah ini
}
-- https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md
local formatting = {}
local diagnostics = {}
vim.g.pcode_null_ls_sources = {
formatting.stylua, -- tambahkan di bawah sini
diagnostics.flake8, -- tambahkan di bawah sini
}
-- https://github.com/folke/which-key.nvim
vim.g.pcode_whichkey = {
-- contoh penambahan
-- ["k"] = {
-- name = "Example",
-- k = { '<cmd>lua print("Testing")<cr>', "Example" },
-- },
["r"] = {
name = "Run",
j = { "<cmd>Jaq float<CR>", "Run With Jaq" },
},
["o"] = { "<cmd>SymbolsOutline<cr>", "Symbol Outline" },
}

View file

@ -1,5 +0,0 @@
local M = {
disable = 0, -- 0 ( format jalan) 1 (fromat off)
}
return M

View file

@ -1,10 +0,0 @@
-- ini hanya untuk lsp yg tidak support masson
-- untuk referesi support language kunjungi link dibawah
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
local m = {
lspinstall = {
"yamlls",
-- tambahkan di bawah sini setelah melakukan :masoninstall
},
}
return m

View file

@ -1,10 +0,0 @@
local null_ls = require("null-ls")
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local m = {
sources = {
formatting.stylua, -- tambahkan di bawah sini
diagnostics.flake8, -- tambahkan di bawah sini
},
}
return m

View file

@ -1,18 +0,0 @@
-- untuk referesi support language kunjungi link dibawah
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
local m = {
lspreg = {
"yamlls",
"intelephense",
"marksman",
"csharp_ls",
"clangd",
"dartls",
"kotlin_language_server",
-- tambahkan di bawah sini setelah melakukan :masoninstall
},
skipreg = {
"jdtls", -- tambahkan di bawah ini
},
}
return m

View file

@ -1,73 +0,0 @@
local m = {}
-- 0 disable progress
-- 1 lualine lsp progress
-- 2 fidget progress
m.progress = 1
-- style
-- 0 = default
-- 1 = { left = "", right = "" },
-- 2 = { left = " ", right = " " },
-- 3 = { left = "", right = "" },
m.lualine_style = 0
-- style status icon
-- 0 = default
-- 1 = vim icon " "
-- 2 = vim icon " "
m.status_icon = 0
-- start custom lualine style
-- contoh style
-- {
-- { left = "│", right = "│" },
-- { left = " ", right = " " },
-- },
-- {
-- { left = " ", right = " " },
-- { left = " ", right = "" },
-- },
-- {
-- { left = " ", right = " " },
-- { left = "", right = "" },
-- },
-- {
-- { left = "", right = "" },
-- { left = "", right = "" },
-- },
-- {
-- { left = " ", right = " " },
-- { left = "", right = "" },
-- },
-- }
m.custom_lualine = false
m.component_separators = { left = " ", right = " " }
m.section_separators = { left = "", right = "" }
-- end custom lualine style
-- custom colorscheme
-- colorscheme ready :
-- tokyonight, tokyonight-night, tokyonight-storm, tokyonight-day, tokyonight-moon
-- gruvbox-baby (default)
-- sonokai, sonokai_atlantis,
-- sonokai_andromeda,sonokai_shusia,sonokai_maia,sonokai_espresso
-- material, material_deepocean, material_palenight, material_lighter, material_darker
-- onedark, onedark_darker, onedark_cool, onedark_deep,onedark_warm,
-- onedark_warmer, onedark_light
-- lunar
-- nord
-- catppuccin, catppuccin-latte, catppuccin-frappe, catppuccin-macchiato, catppuccin-mocha
-- dracula
-- nightfox, dayfox, dawnfox, duskfox, nordfox, terafox, carbonfox
m.colorscheme = "gruvbox-baby"
-- custom transparent mode
-- only support
-- gruvbox-baby,
-- tokyonight,
-- sonokai,
-- material
-- onedark
-- catppuccin
-- nord
-- dracula
-- nightfox
-- 0 =off 1= on
m.transparent_mode = 0
return m

View file

@ -1,12 +0,0 @@
return {
-- contoh penambahan
-- ["k"] = {
-- name = "Example",
-- k = { '<cmd>lua print("Testing")<cr>', "Example" },
-- },
["r"] = {
name = "Run",
j = { "<cmd>Jaq float<CR>", "Run With Jaq" },
},
["o"] = { "<cmd>SymbolsOutline<cr>", "Symbol Outline" },
}

View file

@ -22,10 +22,10 @@ _G.switch = function(param, case_table)
return def and def() or nil return def and def() or nil
end end
local data_exists, custom_ui = pcall(require, "custom.ui") local data_exists, config = pcall(require, "core.config")
if data_exists then if data_exists then
if type(custom_ui) == "table" then if config.colorscheme ~= nil then
local color = custom_ui.colorscheme local color = config.colorscheme
switch(color, { switch(color, {
["tokyonight"] = function() ["tokyonight"] = function()
gruvbox = false gruvbox = false
@ -206,7 +206,7 @@ if data_exists then
end end
local transparent = false local transparent = false
local transparent_mode = custom_ui.transparent_mode local transparent_mode = config.transparent_mode
if transparent_mode ~= nil then if transparent_mode ~= nil then
if transparent_mode == 1 then if transparent_mode == 1 then
transparent = true transparent = true

View file

@ -1,6 +1,6 @@
local fidget = true local fidget = true
local lualine = false local lualine = false
local data_exists, custom_ui = pcall(require, "custom.ui") local data_exists, custom_ui = pcall(require, "core.config")
if data_exists then if data_exists then
if type(custom_ui) == "table" then if type(custom_ui) == "table" then
if custom_ui.progress == 1 then if custom_ui.progress == 1 then

View file

@ -1,6 +1,5 @@
local data_exists, custom_dasboard = pcall(require, "custom.dashboard") local data_exists, custom_dasboard = pcall(require, "core.config")
if data_exists then if data_exists then
if type(custom_dasboard) == "table" then
local model = custom_dasboard.model local model = custom_dasboard.model
if model ~= nil then if model ~= nil then
if model == 1 then if model == 1 then
@ -11,7 +10,6 @@ if data_exists then
else else
require("user.startify") require("user.startify")
end end
end
else else
require("user.startify") require("user.startify")
end end

View file

@ -4,23 +4,20 @@ local lst_style =
local lst_material = { "material", "material_deepocean", "material_palenight", "material_lighter", "material_darker" } local lst_material = { "material", "material_deepocean", "material_palenight", "material_lighter", "material_darker" }
local lst_onedark = local lst_onedark =
{ "onedark", "onedark_darker", "onedark_cool", "onedark_deep,onedark_warm", "onedark_warmer", "onedark_light" } { "onedark", "onedark_darker", "onedark_cool", "onedark_deep,onedark_warm", "onedark_warmer", "onedark_light" }
local data_exists, custom_ui = pcall(require, "custom.ui") local data_exists, config = pcall(require, "core.config")
if data_exists then if data_exists then
if type(custom_ui) == "table" then if config.colorscheme ~= nil then
local color = custom_ui.colorscheme colorscheme = config.colorscheme
if color ~= nil then
colorscheme = color
else else
colorscheme = "gruvbox-baby" colorscheme = "gruvbox-baby"
end end
local transparent_mode = custom_ui.transparent_mode local transparent_mode = config.transparent_mode
if transparent_mode ~= nil then if transparent_mode ~= nil then
if transparent_mode == 1 then if transparent_mode == 1 then
vim.g.gruvbox_baby_transparent_mode = 1 vim.g.gruvbox_baby_transparent_mode = 1
vim.g.sonokai_transparent_background = 2 vim.g.sonokai_transparent_background = 2
end end
end end
end
end end
for _, v in pairs(lst_style) do for _, v in pairs(lst_style) do

View file

@ -14,14 +14,12 @@ local board = {
[[|_| |__/ ]], [[|_| |__/ ]],
} }
local data_exists, custom_dasboard = pcall(require, "custom.dashboard") local data_exists, custom_dasboard = pcall(require, "core.config")
if data_exists then if data_exists then
if type(custom_dasboard) == "table" then
local data_board = custom_dasboard.dashboard2 local data_board = custom_dasboard.dashboard2
if data_board ~= nil then if data_board ~= nil then
board = data_board board = data_board
end end
end
end end
local dashboard = require("alpha.themes.dashboard") local dashboard = require("alpha.themes.dashboard")
@ -40,13 +38,11 @@ dashboard.section.buttons.val = {
local function footer() local function footer()
local footer_text = "Pojok Code" local footer_text = "Pojok Code"
if data_exists then if data_exists then
if type(custom_dasboard) == "table" then
local data_txt = custom_dasboard.footer local data_txt = custom_dasboard.footer
if data_txt ~= nil then if data_txt ~= nil then
footer_text = data_txt footer_text = data_txt
end end
end end
end
return footer_text return footer_text
end end

View file

@ -1,9 +1,9 @@
local run = 0 local run = 0
local data_exists, frmt = pcall(require, "custom.format_onsave") local data_exists, frmt = pcall(require, "core.config")
if not data_exists then if not data_exists then
run = 1 run = 1
end end
if frmt.disable == 0 then if frmt.format_on_save == 1 then
run = 1 run = 1
end end

View file

@ -9,14 +9,13 @@ local lspconfig = require("lspconfig")
-- local servers = { "jdtls", "yamlls" } -- local servers = { "jdtls", "yamlls" }
local servers = {} local servers = {}
local data_exists, custom_lsp = pcall(require, "custom.lsp_installer") local data_exists, custom_lsp = pcall(require, "core.config")
if data_exists then if data_exists then
for _, client in pairs(custom_lsp.lspinstall) do for _, client in pairs(custom_lsp.lsp_installer) do
table.insert(servers, client) table.insert(servers, client)
end end
end end
lsp_installer.setup({ lsp_installer.setup({
ensure_installed = servers, ensure_installed = servers,
}) })

View file

@ -17,17 +17,17 @@ local function idxOf(array, value)
return nil return nil
end end
local data_exists, custom_lsp = pcall(require, "custom.register_lsp") local data_exists, custom_lsp = pcall(require, "core.config")
if data_exists then if data_exists then
for _, client in pairs(custom_lsp.lspreg) do for _, client in pairs(custom_lsp.register_lsp) do
table.insert(servers, client) table.insert(servers, client)
end end
end end
local data_ok, unregis = pcall(require, "custom.register_lsp") local data_ok, unregis = pcall(require, "core.config")
if data_ok then if data_ok then
if unregis.skip_reg ~= nil then if unregis.unregister_lsp ~= nil then
for _, unreg in pairs(custom_lsp.skip_reg) do for _, unreg in pairs(custom_lsp.unregister_lsp) do
local my_index = idxOf(servers, unreg) local my_index = idxOf(servers, unreg)
table.remove(servers, my_index) table.remove(servers, my_index)
end end

View file

@ -12,19 +12,19 @@ local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local sources = {} local sources = {}
local data_exists, data = pcall(require, "custom.null-ls") local data_exists, data = pcall(require, "core.config")
if data_exists then if data_exists then
for _, cfg in pairs(data.sources) do for _, cfg in pairs(data.null_ls_sources) do
table.insert(sources, cfg) table.insert(sources, cfg)
end end
end end
local run = 0 local run = 0
local data_exists, frmt = pcall(require, "custom.format_onsave") local ok, frmt = pcall(require, "core.config")
if not data_exists then if not ok then
run = 1 run = 1
end end
if frmt.disable == 0 then if frmt.format_on_save == 1 then
run = 1 run = 1
end end

View file

@ -53,9 +53,8 @@ local section_separators = { left = "", right = "" }
local icon_mode = "" local icon_mode = ""
local sts_mode = 0 local sts_mode = 0
local data_exists, custom_ui = pcall(require, "custom.ui") local data_exists, custom_ui = pcall(require, "core.config")
if data_exists then if data_exists then
if type(custom_ui) == "table" then
local ui_style = custom_ui.lualine_style local ui_style = custom_ui.lualine_style
if ui_style ~= nil then if ui_style ~= nil then
if custom_ui.lualine_style == 1 then if custom_ui.lualine_style == 1 then
@ -88,7 +87,6 @@ if data_exists then
section_separators = section section_separators = section
end end
end end
end
end end
local mode = { local mode = {

View file

@ -9,14 +9,12 @@ dash_model = {
[[ /_/ |___/ ]], [[ /_/ |___/ ]],
} }
local data_exists, custom_dasboard = pcall(require, "custom.dashboard") local data_exists, custom_dasboard = pcall(require, "core.config")
if data_exists then if data_exists then
if type(custom_dasboard) == "table" then
local board = custom_dasboard.dashboard1 local board = custom_dasboard.dashboard1
if board ~= nil then if board ~= nil then
dash_model = board dash_model = board
end end
end
end end
startify.section.header.val = dash_model startify.section.header.val = dash_model
startify.section.top_buttons.val = { startify.section.top_buttons.val = {
@ -44,12 +42,10 @@ startify.section.bottom_buttons.val = {
local footer_text = "Pojok Code" local footer_text = "Pojok Code"
if data_exists then if data_exists then
if type(custom_dasboard) == "table" then
local data_txt = custom_dasboard.footer local data_txt = custom_dasboard.footer
if data_txt ~= nil then if data_txt ~= nil then
footer_text = data_txt footer_text = data_txt
end end
end
end end
startify.section.footer.val = { startify.section.footer.val = {
{ type = "text", val = footer_text }, { type = "text", val = footer_text },

View file

@ -4,15 +4,13 @@ if not status_ok then
end end
local transp = false local transp = false
local sidebar = "dark" local sidebar = "dark"
local data_exists, custom_ui = pcall(require, "custom.ui") local data_exists, config = pcall(require, "core.config")
if data_exists then if data_exists then
if type(custom_ui) == "table" then local tras = config.transparent_mode
local tras = custom_ui.transparent_mode if tras == 1 then
if tras ~= nil and tras == 1 then
transp = true transp = true
sidebar = "transparent" sidebar = "transparent"
end end
end
end end
tokyonight.setup({ tokyonight.setup({
-- your configuration comes here -- your configuration comes here

View file

@ -395,11 +395,9 @@ local mappings = {
} }
local wkey = {} local wkey = {}
local data_exists, key = pcall(require, "custom.whichkey") local data_exists, key = pcall(require, "core.config")
if data_exists then if data_exists then
if type(key) == "table" then wkey = key.whichkey
wkey = key
end
end end
which_key.setup(setup) which_key.setup(setup)