First step to mkae config modulary

This commit is contained in:
Jeff Lance 2023-12-29 22:50:42 +01:00
parent b0664ec8e0
commit 9fc738cae0
7 changed files with 485 additions and 79 deletions

View File

@ -48,87 +48,32 @@ lvim.builtin.terminal.active = true
-- lvim.builtin.theme.options.style = "storm" -- lvim.builtin.theme.options.style = "storm"
-- ==============================================
-- Trying to make a modular configuration
-- plugins
--
-- require("user.plugins")
-- variables
-- -- functions
-- --
-- require("user.functions")
-- keybindings
--
require("user.keybindings").setup()
-- --
-- functions -- which_key
-- --
require("user.whichkey").setup()
-- keymappings [view all the defaults by pressing <leader>Lvk]
-- --
-- ==============================================
lvim.leader = ";"
lvim.keys.insert_mode[";;"] = "<Esc>"
lvim.keys.normal_mode["<C-s>"] = "<CMD>w!<CR>"
lvim.keys.normal_mode["<C-z>"] = "<CMD>undo<CR>"
lvim.keys.normal_mode["<M-z>"] = "<CMD>redo<CR>"
-- lvim.keys.normal_mode["<C-w>"] = "<CMD>BufferKill<CR>"
lvim.keys.normal_mode["<C-[>"] = ":<<CR>"
lvim.keys.normal_mode["<C-]>"] = ":><CR>"
-- remap neo-tree shortcut to rnvimr
lvim.builtin.which_key.mappings["e"] = { "<CMD>RnvimrToggle<CR>", "File explorer" }
lvim.builtin.which_key.mappings["d"] = lvim.builtin.which_key.mappings[";"]
lvim.builtin.which_key.mappings["G"] = lvim.builtin.which_key.mappings["g"]
lvim.builtin.which_key.mappings["g"] = {}
lvim.builtin.which_key.mappings["H"] = lvim.builtin.which_key.mappings["h"]
lvim.builtin.which_key.mappings["h"] = {
name = " Header",
h = { "<CMD>AddHeader<CR>", "Add header to the file" },
m = { "<CMD>AddMinHeader<CR>", "Add minimal header to the file" },
lg = { "<CMD>AddGNULicense<CR>", "Add GPLv3 License" },
lm = { "<CMD>AddMITLicense<CR>", "Add MIT License" },
}
lvim.builtin.which_key.mappings["Lv"] = lvim.builtin.which_key.mappings["L"]
lvim.builtin.which_key.mappings["Ll"] = lvim.builtin.which_key.mappings["l"]
lvim.builtin.which_key.mappings["l"] = {}
lvim.builtin.which_key.mappings["L"] = {
name = " LSP, Lunar"
}
lvim.builtin.which_key.mappings["Lve"] = lvim.builtin.which_key.mappings["Lvc"]
lvim.builtin.which_key.mappings["Lvc"] = {}
lvim.builtin.which_key.mappings["n"] = { "<CMD>AdvancedNewFile<CR>", "Create a new file"}
lvim.builtin.which_key.mappings["N"] = {
name = " Notes",
c = { "<CMD>edit /home/jeff/.config/zk/config.toml<CR>", "Edit config.toml" },
n = { "<CMD>ZkNew { dir = vim.fn.input('Groupe: '), title = vim.fn.input('Titre: '), date = 'now' }<CR>",
"Créer une nouvelle note" },
o = { "<CMD>ZkNotes { sort = { 'modified' } }<CR>", "Ouvrir une note" },
O = { "<CMD>ZkTags<CR>", "Ouvrir les notes avec le tag sélectionné" },
f = { "<CMD>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Rechercher note: ') } }<CR>",
"Rechercher une note" },
F = { ":'<,'>ZkMatch<CR>", "Rechercher les notes contenant la sélection" },
}
lvim.builtin.which_key.mappings["o"] = { "<CMD>Telescope find_files<CR>", "Open a file" }
lvim.builtin.which_key.mappings["P"] = {
name = " Plugins"
}
lvim.builtin.which_key.mappings["P"] = lvim.builtin.which_key.mappings["p"]
lvim.builtin.which_key.mappings["p"] = { "<CMD>Telescope projects<CR>", "Projects" }
lvim.builtin.which_key.mappings["S"] = lvim.builtin.which_key.mappings["s"]
lvim.builtin.which_key.mappings["s"] = { "<CMD>echom 'Sourcing' <BAR> source %<CR>", "Source current file" }
lvim.builtin.which_key.mappings["r"] = { "<CMD>Telescope oldfiles<CR>", "Open recent file" }
lvim.builtin.which_key.mappings["x"] = { "<CMD>w! <BAR> q!<CR>", "Save and quit" }
lvim.builtin.which_key.mappings[";"] = {}
lvim.builtin.terminal.open_mapping = "<C-t>"
@ -343,7 +288,7 @@ lvim.plugins = {
}), }),
}, },
symbols = { symbols = {
encode = map.gen_encode_symbols.dot('2x1'), encode = map.gen_encode_symbols.dot('2x1'),
}, },
window = { window = {
side = 'right', side = 'right',

View File

@ -0,0 +1,33 @@
--[[--
File : conf.d/lvim/lua/user/functions.lua
Author : Jeff Lance <email@jefflance.me>
Date : 28.12.2023 20:13:31
Last Modified Date: 28.12.2023 20:13:31
Last Modified By : Jeff Lance <email@jefflance.me>
--]]--
-- function Surround(w_or_W)
-- local open_char = vim.fn.input("Surround with: ")
-- local closed_char = nil
-- if open_char == "(" then closed_char = ")" end
-- if open_char == "[" then closed_char = "]" end
-- if open_char == "{" then closed_char = "}" end
-- if open_char == "<" then closed_char = ">" end
-- if open_char == "'" then closed_char = "'" end
-- if open_char == '"' then closed_char = '"' end
-- if open_char == "`" then closed_char = "`" end
-- if open_char == "/" then closed_char = "/" end
-- if open_char == "|" then closed_char = "|" end
-- if w_or_W == "w" then
-- vim.cmd("normal! ciw" .. open_char)
-- elseif w_or_W == "W" then
-- vim.cmd([[normal! ciW]] .. open_char)
-- end
-- vim.cmd("normal! p")
-- vim.cmd("normal! a" .. closed_char)
-- vim.cmd("normal! a")
-- end

View File

@ -0,0 +1,35 @@
--[[--
File : conf.d/lvim/lua/user/keybindings.lua
Author : Jeff Lance <email@jefflance.me>
Date : 28.12.2023 20:32:45
Last Modified Date: 29.12.2023 22:35:31
Last Modified By : Jeff Lance <email@jefflance.me>
--]]--
local M = {}
M.setup = function()
-- ============
-- key mappings
--
-- vim-surround shortcuts as example
-- vim.api.nvim_set_keymap("n", "sw", "<Plug>Ysurroundiw", { noremap = true, silent = true })
-- vim.api.nvim_set_keymap("n", "Sw", "<Plug>YSurroundiw", { noremap = true, silent = true })
--
lvim.leader = ";"
lvim.keys.insert_mode[";;"] = "<Esc>"
lvim.keys.normal_mode["<C-s>"] = "<CMD>w!<CR>"
lvim.keys.normal_mode["<C-z>"] = "<CMD>undo<CR>"
lvim.keys.normal_mode["<C-r>"] = "<CMD>redo<CR>"
lvim.keys.normal_mode["<C-[>"] = ":<<CR>"
lvim.keys.normal_mode["<C-]>"] = ":><CR>"
end
return M

View File

@ -0,0 +1,40 @@
--[[--
File : conf.d/lvim/lua/user/plugin-configs.lua
Author : Jeff Lance <email@jefflance.me>
Date : 28.12.2023 21:34:48
Last Modified Date: 28.12.2023 21:34:48
Last Modified By : Jeff Lance <email@jefflance.me>
--]]--
local M = {}
-- setup debug adapter
M.dap = function ()
lvim.builtin.dap.active = true
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/")
pcall(function()
require("dap-python").setup(mason_path .. "packages/debugpy/venv/bin/python")
end)
end
-- setup testing
M.neotest = function ()
require("neotest").setup({
adapters = {
require("neotest-python")({
-- Extra arguments for nvim-dap configuration
-- See https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for values
dap = {
justMyCode = false,
console = "integratedTerminal",
},
args = { "--log-level", "DEBUG", "--quiet" },
runner = "pytest",
})
}
})
end
return M

View File

@ -0,0 +1,269 @@
--[[--
File : conf.d/lvim/lua/user/plugins.lua
Author : Jeff Lance <email@jefflance.me>
Date : 28.12.2023 21:31:06
Last Modified Date: 28.12.2023 21:31:06
Last Modified By : Jeff Lance <email@jefflance.me>
--]]--
local M = {}
M.setup = function ()
-- local config = require("user.plugin-configs")
lvim.plugins = {
-- addheader
{
'alpertuna/vim-header',
config = function()
vim.cmd([[
let g:header_field_author = 'Jeff Lance'
let g:header_field_author_email = 'email@jefflance.me'
let g:header_auto_update_header = 1
let g:header_field_filename_path = 1
let g:header_field_timestamp_format = '%d.%m.%Y %H:%M:%S'
]])
end,
},
-- new file plugin
{
'Mohammed-Taher/AdvancedNewFile.nvim',
},
-- asyncrun
{
"skywind3000/asyncrun.vim",
},
-- cmp addons
{
"tzachar/cmp-tabnine",
build = "./install.sh",
dependencies = "hrsh7th/nvim-cmp",
event = "InsertEnter",
},
{
"micangl/cmp-vimtex",
dependencies = "hrsh7th/nvim-cmp",
},
-- colorschemes
{
'Abstract-IDE/Abstract-cs',
},
{
'ishan9299/modus-theme-vim',
},
{
'NLKNguyen/papercolor-theme',
},
{
'olimorris/onedarkpro.nvim',
priority = 1000,
config = function()
require("onedarkpro").setup({
colors = {
onedark = {
bg = "#000000" -- black
},
onelight = {
bg = "#FFFFFF" -- white
},
-- cursorline = "#FF0000",
},
styles = {
types = "NONE",
methods = "NONE",
numbers = "NONE",
strings = "NONE",
comments = "italic",
keywords = "bold,italic",
constants = "NONE",
functions = "italic",
operators = "NONE",
variables = "NONE",
parameters = "NONE",
conditionals = "italic",
virtual_text = "NONE",
},
options = {
cursorline = true,
transparency = true,
}
})
end
},
-- gitignore
{
'jefflance/vim-gitignore',
},
-- languagetool
{
'dpelle/vim-grammalecte',
config = function ()
vim.cmd([[
let g:grammalecte_cli_py = '/usr/bin/grammalecte-cli'
]])
end
},
-- markdown previewer
{
'iamcco/markdown-preview.nvim',
build = "cd app && npm install",
ft = "markdown",
config = function()
vim.cmd([[
let g:mkdp_auto_start = 1
]])
end,
},
-- minimap
{
'echasnovski/mini.map',
branch = "stable",
config = function()
require('mini.map').setup()
local map = require('mini.map')
map.setup({
integrations = {
map.gen_integration.builtin_search(),
map.gen_integration.diagnostic({
error = 'DiagnosticFloatingError',
warn = 'DiagnosticFloatingWarn',
info = 'DiagnosticFloatingInfo',
hint = 'DiagnosticFloatingHint',
}),
},
symbols = {
encode = map.gen_encode_symbols.dot('2x1'),
},
window = {
side = 'right',
width = 20, -- set to 1 for a pure scrollbar :)
winblend = 15,
show_integration_count = false,
},
})
end
},
-- neoscroll: smooth scrolling
{
"karb94/neoscroll.nvim",
event = "WinScrolled",
config = function()
require('neoscroll').setup({
-- All these keys will be mapped to their corresponding default scrolling animation
mappings = { '<C-u>', '<C-d>', '<C-b>', '<C-f>',
'<C-y>', '<C-e>', 'zt', 'zz', 'zb' },
hide_cursor = true, -- Hide cursor while scrolling
stop_eof = true, -- Stop at <EOF> when scrolling downwards
use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope
respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file
cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further
easing_function = nil, -- Default easing function
pre_hook = nil, -- Function to run before the scrolling animation starts
post_hook = nil, -- Function to run after the scrolling animation ends
})
end
},
-- zk: a plain text note-taking assistant
{
'mickael-menu/zk-nvim',
config = function()
require("zk").setup({
})
end,
},
-- nvim-ts-rainbow: rainbowed parenthesis
{
"mrjones2014/nvim-ts-rainbow",
},
-- colorizer: color highlighter
{
'norcalli/nvim-colorizer.lua',
config = function()
require("colorizer").setup({ '*' }, {
RGB = true, -- #RGB hex codes
RRGGBB = true, -- #RRGGBB hex codes
RRGGBBAA = true, -- #RRGGBBAA hex codes
rgb_fn = true, -- CSS rgb() and rgba() functions
hsl_fn = true, -- CSS hsl() and hsla() functions
css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
mode = 'background',
})
end,
},
{
"kevinhwang91/rnvimr",
cmd = "RnvimrToggle",
config = function()
vim.cmd([[
let g:rnvimr_draw_border = 1
let g:rnvimr_pick_enable = 1
let g:rnvimr_bw_enable = 1
]])
end,
},
-- suda
{
'lambdalisue/suda.vim',
config = function()
vim.cmd([[
let g:prompt = 'Mot de passe: '
let g:suda_smart_edit = 1
]])
end,
},
-- trouble
{
'folke/trouble.nvim',
cmd = "TroubleToggle",
},
-- vim-repeat: enable repeating supported plugin maps with "."
{
"tpope/vim-repeat"
},
-- vim-surround
{
'tpope/vim-surround',
config = function()
vim.cmd([[
let timeoutlen = 500
]])
end,
},
-- LaTeX management needed plugins
{
"lervag/vimtex",
config = function()
vim.cmd([[
let g:vimtex_view_method = "zathura"
let g:vimtex_quickfix_enabled = 0
let g:vimtex_compiler_method = 'latexmk'
let g:vimtex_view_use_temp_files = 0
]])
end,
},
{
"KeitaNakamura/tex-conceal.vim"
},
-- Python management needed plugins
{
"ChristianChiarulli/swenv.nvim"
},
{
"stevearc/dressing.nvim"
},
{
"mfussenegger/nvim-dap-python"
},
{
"nvim-neotest/neotest"
},
{
"nvim-neotest/neotest-python"
},
}
end
return M

View File

@ -0,0 +1,88 @@
--[[--
File : conf.d/lvim/lua/user/whichkey.lua
Author : Jeff Lance <email@jefflance.me>
Date : 29.12.2023 22:30:57
Last Modified Date: 29.12.2023 22:30:57
Last Modified By : Jeff Lance <email@jefflance.me>
--]]--
local M = {}
M.setup = function()
-- =================
-- whichkey mappings
--
-- remap neo-tree shortcut to rnvimr
lvim.builtin.which_key.mappings["e"] = { "<CMD>RnvimrToggle<CR>", "File explorer" }
-- remap dashboard
lvim.builtin.which_key.mappings["d"] = lvim.builtin.which_key.mappings[";"]
-- remap git
lvim.builtin.which_key.mappings["G"] = lvim.builtin.which_key.mappings["g"]
lvim.builtin.which_key.mappings["g"] = {}
-- remap highlight
lvim.builtin.which_key.mappings["H"] = lvim.builtin.which_key.mappings["h"]
-- remap lunarvim and lsp
lvim.builtin.which_key.mappings["Lv"] = lvim.builtin.which_key.mappings["L"]
lvim.builtin.which_key.mappings["Ll"] = lvim.builtin.which_key.mappings["l"]
lvim.builtin.which_key.mappings["l"] = {}
lvim.builtin.which_key.mappings["L"] = {
name = "LSP, Lunar"
}
lvim.builtin.which_key.mappings["Lve"] = lvim.builtin.which_key.mappings["Lvc"]
lvim.builtin.which_key.mappings["Lvc"] = {}
-- zettle mappings
lvim.builtin.which_key.mappings["N"] = {
name = "Notes",
c = { "<CMD>edit /home/jeff/.config/zk/config.toml<CR>", "Edit config.toml" },
n = { "<CMD>ZkNew { dir = vim.fn.input('Groupe: '), title = vim.fn.input('Titre: '), date = 'now' }<CR>",
"Créer une nouvelle note" },
o = { "<CMD>ZkNotes { sort = { 'modified' } }<CR>", "Ouvrir une note" },
O = { "<CMD>ZkTags<CR>", "Ouvrir les notes avec le tag sélectionné" },
f = { "<CMD>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Rechercher note: ') } }<CR>",
"Rechercher une note" },
F = { ":'<,'>ZkMatch<CR>", "Rechercher les notes contenant la sélection" },
}
-- remap plugins mappings
lvim.builtin.which_key.mappings["P"] = {
name = "Plugins"
}
-- telescope
lvim.builtin.which_key.mappings["P"] = lvim.builtin.which_key.mappings["p"]
lvim.builtin.which_key.mappings["o"] = { "<CMD>Telescope find_files<CR>", "Open a file" }
lvim.builtin.which_key.mappings["p"] = { "<CMD>Telescope projects<CR>", "Projects" }
lvim.builtin.which_key.mappings["r"] = { "<CMD>Telescope oldfiles<CR>", "Open recent file" }
-- remap search
lvim.builtin.which_key.mappings["S"] = lvim.builtin.which_key.mappings["s"]
-- new mappings
lvim.builtin.which_key.mappings["h"] = {
name = "Header",
h = { "<CMD>AddHeader<CR>", "Add header to the file" },
m = { "<CMD>AddMinHeader<CR>", "Add minimal header to the file" },
lg = { "<CMD>AddGNULicense<CR>", "Add GPLv3 License" },
lm = { "<CMD>AddMITLicense<CR>", "Add MIT License" },
}
lvim.builtin.which_key.mappings["n"] = { "<CMD>AdvancedNewFile<CR>", "Create a new file"}
lvim.builtin.which_key.mappings["s"] = { "<CMD>echom 'Sourcing' <BAR> source %<CR>", "Source current file" }
lvim.builtin.which_key.mappings["x"] = { "<CMD>w! <BAR> q!<CR>", "Save and quit" }
lvim.builtin.which_key.mappings[";"] = {}
lvim.builtin.terminal.open_mapping = "<C-t>"
end
return M

View File

@ -1,4 +0,0 @@
-- Read the docs: https://www.lunarvim.org/docs/configuration
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6
-- Forum: https://www.reddit.com/r/lunarvim/
-- Discord: https://discord.com/invite/Xb9B4Ny