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" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "e4badf7984f7a5f0ac7dc10657dbedbd99a82f94" },
"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.indentscope": { "branch": "main", "commit": "7998edc970610c05598c7aea3d21ece8dd87ed52" },
"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("user.colorscheme")
require("user.keymaps")

View file

@ -1,10 +1,8 @@
local M = {}
-- Untuk Ubah Dashboard
-- 1. Buka remark dash board dibawah
-- 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
return M
vim.g.pcode_model = 2 -- isi dengan 1 atau 2 untuk model dashboard

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
end
local data_exists, custom_ui = pcall(require, "custom.ui")
local data_exists, config = pcall(require, "core.config")
if data_exists then
if type(custom_ui) == "table" then
local color = custom_ui.colorscheme
if config.colorscheme ~= nil then
local color = config.colorscheme
switch(color, {
["tokyonight"] = function()
gruvbox = false
@ -206,7 +206,7 @@ if data_exists then
end
local transparent = false
local transparent_mode = custom_ui.transparent_mode
local transparent_mode = config.transparent_mode
if transparent_mode ~= nil then
if transparent_mode == 1 then
transparent = true

View file

@ -1,6 +1,6 @@
local fidget = true
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 type(custom_ui) == "table" then
if custom_ui.progress == 1 then

View file

@ -1,16 +1,14 @@
local data_exists, custom_dasboard = pcall(require, "custom.dashboard")
local data_exists, custom_dasboard = pcall(require, "core.config")
if data_exists then
if type(custom_dasboard) == "table" 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 = custom_dasboard.model
if model ~= nil then
if model == 1 then
require("user.startify")
else
require("user.dashboard")
end
else
require("user.startify")
end
else
require("user.startify")

View file

@ -4,21 +4,18 @@ local lst_style =
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, custom_ui = pcall(require, "custom.ui")
local data_exists, config = pcall(require, "core.config")
if data_exists then
if type(custom_ui) == "table" then
local color = custom_ui.colorscheme
if color ~= nil then
colorscheme = color
else
colorscheme = "gruvbox-baby"
end
local transparent_mode = custom_ui.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
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
end
end

View file

@ -14,13 +14,11 @@ 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 type(custom_dasboard) == "table" then
local data_board = custom_dasboard.dashboard2
if data_board ~= nil then
board = data_board
end
local data_board = custom_dasboard.dashboard2
if data_board ~= nil then
board = data_board
end
end
@ -40,11 +38,9 @@ dashboard.section.buttons.val = {
local function footer()
local footer_text = "Pojok Code"
if data_exists then
if type(custom_dasboard) == "table" then
local data_txt = custom_dasboard.footer
if data_txt ~= nil then
footer_text = data_txt
end
local data_txt = custom_dasboard.footer
if data_txt ~= nil then
footer_text = data_txt
end
end

View file

@ -1,9 +1,9 @@
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
run = 1
end
if frmt.disable == 0 then
if frmt.format_on_save == 1 then
run = 1
end

View file

@ -9,14 +9,13 @@ local lspconfig = require("lspconfig")
-- local servers = { "jdtls", "yamlls" }
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
for _, client in pairs(custom_lsp.lspinstall) do
for _, client in pairs(custom_lsp.lsp_installer) do
table.insert(servers, client)
end
end
lsp_installer.setup({
ensure_installed = servers,
})

View file

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

View file

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

View file

@ -53,40 +53,38 @@ local section_separators = { left = "", right = "" }
local icon_mode = ""
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 type(custom_ui) == "table" then
local ui_style = custom_ui.lualine_style
if ui_style ~= nil then
if custom_ui.lualine_style == 1 then
component_separators = { left = "", right = "" }
section_separators = { left = "", right = "" }
elseif custom_ui.lualine_style == 2 then
component_separators = { left = "", right = "" }
section_separators = { left = "", right = "" }
elseif custom_ui.lualine_style == 3 then
component_separators = { left = "", right = "" }
section_separators = { left = "", right = "" }
end
local ui_style = custom_ui.lualine_style
if ui_style ~= nil then
if custom_ui.lualine_style == 1 then
component_separators = { left = "", right = "" }
section_separators = { left = "", right = "" }
elseif custom_ui.lualine_style == 2 then
component_separators = { left = "", right = "" }
section_separators = { left = "", right = "" }
elseif custom_ui.lualine_style == 3 then
component_separators = { left = "", right = "" }
section_separators = { left = "", right = "" }
end
local ui_icon = custom_ui.status_icon
if ui_icon ~= nil then
if custom_ui.status_icon == 1 then
icon_mode = ""
sts_mode = 1
elseif custom_ui.status_icon == 2 then
icon_mode = ""
sts_mode = 1
end
end
local ui_icon = custom_ui.status_icon
if ui_icon ~= nil then
if custom_ui.status_icon == 1 then
icon_mode = ""
sts_mode = 1
elseif custom_ui.status_icon == 2 then
icon_mode = ""
sts_mode = 1
end
local custom_style = custom_ui.custom_lualine
if custom_style ~= nil and custom_style == true then
local comp = custom_ui.component_separators
local section = custom_ui.section_separators
if comp ~= nil and section ~= nil then
component_separators = comp
section_separators = section
end
end
local custom_style = custom_ui.custom_lualine
if custom_style ~= nil and custom_style == true then
local comp = custom_ui.component_separators
local section = custom_ui.section_separators
if comp ~= nil and section ~= nil then
component_separators = comp
section_separators = section
end
end
end

View file

@ -9,13 +9,11 @@ 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 type(custom_dasboard) == "table" then
local board = custom_dasboard.dashboard1
if board ~= nil then
dash_model = board
end
local board = custom_dasboard.dashboard1
if board ~= nil then
dash_model = board
end
end
startify.section.header.val = dash_model
@ -44,11 +42,9 @@ startify.section.bottom_buttons.val = {
local footer_text = "Pojok Code"
if data_exists then
if type(custom_dasboard) == "table" then
local data_txt = custom_dasboard.footer
if data_txt ~= nil then
footer_text = data_txt
end
local data_txt = custom_dasboard.footer
if data_txt ~= nil then
footer_text = data_txt
end
end
startify.section.footer.val = {

View file

@ -4,14 +4,12 @@ if not status_ok then
end
local transp = false
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 type(custom_ui) == "table" then
local tras = custom_ui.transparent_mode
if tras ~= nil and tras == 1 then
transp = true
sidebar = "transparent"
end
local tras = config.transparent_mode
if tras == 1 then
transp = true
sidebar = "transparent"
end
end
tokyonight.setup({

View file

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