This commit is contained in:
Loïc Gremaud 2023-05-24 03:26:31 +02:00
parent 262a06776a
commit b933fbe1d9
No known key found for this signature in database
GPG Key ID: ACD9F65FA7E19986
13 changed files with 277 additions and 25 deletions

2
.gitignore vendored
View File

@ -1,5 +1,3 @@
plugin
custom
spell spell
ftplugin ftplugin
coc-settings.json coc-settings.json

View File

@ -10,9 +10,9 @@ M.ui = {
hl_add = {}, hl_add = {},
hl_override = {}, hl_override = {},
changed_themes = {}, changed_themes = {},
theme_toggle = { "onedark", "one_light" }, theme_toggle = { "gatekeeper", "one_light" },
theme = "onedark", -- default theme theme = "gatekeeper", -- default theme
transparency = false, transparency = true,
lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens
-- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations -- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations

View File

@ -6,7 +6,7 @@ local config = require("core.utils").load_config()
g.nvchad_theme = config.ui.theme g.nvchad_theme = config.ui.theme
g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/"
g.toggle_theme_icon = "" g.toggle_theme_icon = ""
g.transparency = config.ui.transparency g.transparency = true
-------------------------------------- options ------------------------------------------ -------------------------------------- options ------------------------------------------
opt.laststatus = 3 -- global statusline opt.laststatus = 3 -- global statusline
@ -17,10 +17,10 @@ opt.cursorline = true
-- Indenting -- Indenting
opt.expandtab = true opt.expandtab = true
opt.shiftwidth = 2 opt.shiftwidth = 4
opt.smartindent = true opt.smartindent = true
opt.tabstop = 2 opt.tabstop = 4
opt.softtabstop = 2 opt.softtabstop = 4
opt.fillchars = { eob = " " } opt.fillchars = { eob = " " }
opt.ignorecase = true opt.ignorecase = true
@ -31,6 +31,7 @@ opt.mouse = "a"
opt.number = true opt.number = true
opt.numberwidth = 2 opt.numberwidth = 2
opt.ruler = false opt.ruler = false
opt.relativenumber = true
-- disable nvim intro -- disable nvim intro
opt.shortmess:append "sI" opt.shortmess:append "sI"
@ -92,6 +93,7 @@ vim.api.nvim_create_autocmd("BufWritePost", {
vim.g.nvchad_theme = config.ui.theme vim.g.nvchad_theme = config.ui.theme
vim.g.transparency = config.ui.transparency vim.g.transparency = config.ui.transparency
vim.g.transparency = true
-- statusline -- statusline
require("plenary.reload").reload_module("nvchad_ui.statusline." .. config.ui.statusline.theme) require("plenary.reload").reload_module("nvchad_ui.statusline." .. config.ui.statusline.theme)

View File

@ -16,31 +16,41 @@ M.general = {
}, },
n = { n = {
["<Esc>"] = { ":noh <CR>", "Clear highlights" }, ["<leader>n"] = { ":noh <CR>", "Clear highlights" },
["<leader>rr"] = { ":source $MYVIMRC<CR>", "Reload config file" },
-- switch between windows -- switch between windows
["<C-h>"] = { "<C-w>h", "Window left" }, ["<C-h>"] = { "<C-w>h", "Window left" },
["<C-l>"] = { "<C-w>l", "Window right" }, ["<C-l>"] = { "<C-w>l", "Window right" },
["<C-j>"] = { "<C-w>j", "Window down" }, ["<C-j>"] = { "<C-w>j", "Window down" },
["<C-k>"] = { "<C-w>k", "Window up" }, ["<C-k>"] = { "<C-w>k", "Window up" },
["<C-d>"] = { "<cmd> tab Git diff %<CR>", "Git diff this file" },
["<C-p>"] = { "<cmd> tab Git diff<CR>", "Git diff global" },
-- save -- save
["<C-s>"] = { "<cmd> w <CR>", "Save file" }, ["<C-s>"] = { "<cmd> w <CR>", "Save file" },
-- Copy all -- Copy all
["<C-c>"] = { "<cmd> %y+ <CR>", "Copy whole file" }, -- ["<C-c>"] = { "<cmd> %y+ <CR>", "Copy whole file" },
-- Quit
["<C-q>"] = { "<cmd> q! <CR>", "Force quit window" },
-- line numbers -- line numbers
["<leader>n"] = { "<cmd> set nu! <CR>", "Toggle line number" }, -- ["<leader>n"] = { "<cmd> set nu! <CR>", "Toggle line number" },
["<leader>rn"] = { "<cmd> set rnu! <CR>", "Toggle relative number" }, -- ["<leader>rn"] = { "<cmd> set rnu! <CR>", "Toggle relative number" },
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down> -- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
-- empty mode is same as using <cmd> :map -- empty mode is same as using <cmd> :map
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, -- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } },
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } },
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- ["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } },
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, -- ["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } },
["<leader>y"] = {"<cmd> :w! /tmp/vimtmp<CR>", "Save into a global tmp file"},
["<leader>p"] = {"<cmd> :r! cat /tmp/vimtmp<CR>", "Restore from the global tmp file"},
-- new buffer -- new buffer
["<leader>b"] = { "<cmd> enew <CR>", "New buffer" }, ["<leader>b"] = { "<cmd> enew <CR>", "New buffer" },
@ -52,19 +62,29 @@ M.general = {
}, },
v = { v = {
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- ["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } },
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, -- ["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } },
}, },
x = { x = {
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, -- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } },
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } },
-- Don't copy the replaced text after pasting in visual mode -- Don't copy the replaced text after pasting in visual mode
-- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste
["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', "Dont copy replaced text", opts = { silent = true } }, ["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', "Dont copy replaced text", opts = { silent = true } },
}, },
} }
M.gitstuffs = {
n = {
["<C-c>"] = { "<cmd> vertical topleft Git <bar> vertical resize 50<CR>", "Show Git status on a left pane" },
["<F3>"] = { "<cmd> Flog -all<CR>", "Show git tree" },
["<C-t>"] = { "<cmd> TagbarToggle<CR>", "Show tagbar" },
}
}
M.tabufline = { M.tabufline = {
plugin = true, plugin = true,
@ -259,10 +279,10 @@ M.telescope = {
n = { n = {
-- find -- find
["<leader>ff"] = { "<cmd> Telescope find_files <CR>", "Find files" }, ["<C-g>"] = { "<cmd> Telescope find_files <CR>", "Find files" },
["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "Find all" }, ["<C-x>"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "Find all" },
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "Live grep" }, ["<C-f>"] = { "<cmd> Telescope live_grep <CR>", "Live grep" },
["<leader>fb"] = { "<cmd> Telescope buffers <CR>", "Find buffers" }, ["<C-b>"] = { "<cmd> Telescope buffers <CR>", "Find buffers" },
["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "Help page" }, ["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "Help page" },
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "Find oldfiles" }, ["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "Find oldfiles" },
["<leader>fz"] = { "<cmd> Telescope current_buffer_fuzzy_find <CR>", "Find in current buffer" }, ["<leader>fz"] = { "<cmd> Telescope current_buffer_fuzzy_find <CR>", "Find in current buffer" },

20
lua/custom/chadrc.lua Normal file
View File

@ -0,0 +1,20 @@
---@type ChadrcConfig
local M = {}
-- Path to overriding theme and highlights files
local highlights = require "custom.highlights"
M.ui = {
theme = "gatekeeper",
theme_toggle = { "gatekeeper", "one_light" },
hl_override = highlights.override,
hl_add = highlights.add,
}
M.plugins = "custom.plugins"
-- check core.mappings for table structure
M.mappings = require "custom.mappings"
return M

View File

@ -0,0 +1,17 @@
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities
local lspconfig = require "lspconfig"
-- if you just want default config for the servers then put them in a table
local servers = { "html", "cssls", "tsserver", "clangd" }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end
--
-- lspconfig.pyright.setup { blabla}

View File

@ -0,0 +1,25 @@
local present, null_ls = pcall(require, "null-ls")
if not present then
return
end
local b = null_ls.builtins
local sources = {
-- webdev stuff
b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast!
b.formatting.prettier.with { filetypes = { "html", "markdown", "css" } }, -- so prettier works only on these filetypes
-- Lua
b.formatting.stylua,
-- cpp
b.formatting.clang_format,
}
null_ls.setup {
debug = true,
sources = sources,
}

View File

@ -0,0 +1,59 @@
local M = {}
M.treesitter = {
ensure_installed = {
"vim",
"lua",
"html",
"css",
"javascript",
"typescript",
"tsx",
"c",
"markdown",
"markdown_inline",
},
indent = {
enable = true,
-- disable = {
-- "python"
-- },
},
}
M.mason = {
ensure_installed = {
-- lua stuff
"lua-language-server",
"stylua",
-- web dev stuff
"css-lsp",
"html-lsp",
"typescript-language-server",
"deno",
"prettier",
-- c/cpp stuff
"clangd",
"clang-format",
},
}
-- git support in nvimtree
M.nvimtree = {
git = {
enable = true,
},
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
},
},
}
return M

19
lua/custom/highlights.lua Normal file
View File

@ -0,0 +1,19 @@
-- To find any highlight groups: "<cmd> Telescope highlights"
-- Each highlight group can take a table with variables fg, bg, bold, italic, etc
-- base30 variable names can also be used as colors
local M = {}
---@type Base46HLGroupsList
M.override = {
Comment = {
italic = true,
},
}
---@type HLTable
M.add = {
NvimTreeOpenedFolderName = { fg = "green", bold = true },
}
return M

7
lua/custom/init.lua Normal file
View File

@ -0,0 +1,7 @@
-- local autocmd = vim.api.nvim_create_autocmd
-- Auto resize panes when resizing nvim window
-- autocmd("VimResized", {
-- pattern = "*",
-- command = "tabdo wincmd =",
-- })

12
lua/custom/mappings.lua Normal file
View File

@ -0,0 +1,12 @@
---@type MappingsTable
local M = {}
M.general = {
n = {
[";"] = { ":", "enter command mode", opts = { nowait = true } },
},
}
-- more keybinds!
return M

65
lua/custom/plugins.lua Normal file
View File

@ -0,0 +1,65 @@
local overrides = require("custom.configs.overrides")
---@type NvPluginSpec[]
local plugins = {
-- Override plugin definition options
{
"neovim/nvim-lspconfig",
dependencies = {
-- format & linting
{
"jose-elias-alvarez/null-ls.nvim",
config = function()
require "custom.configs.null-ls"
end,
},
},
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end, -- Override to setup mason-lspconfig
},
-- override plugin configs
{
"williamboman/mason.nvim",
opts = overrides.mason
},
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
},
{
"nvim-tree/nvim-tree.lua",
opts = overrides.nvimtree,
},
-- Install a plugin
{
"max397574/better-escape.nvim",
event = "InsertEnter",
config = function()
require("better_escape").setup()
end,
},
-- To make a plugin not be loaded
-- {
-- "NvChad/nvim-colorizer.lua",
-- enabled = false
-- },
-- All NvChad plugins are lazy-loaded by default
-- For a plugin to be loaded, you will need to set either `ft`, `cmd`, `keys`, `event`, or set `lazy = false`
-- If you want a plugin to load on startup, add `lazy = false` to a plugin spec, for example
-- {
-- "mg979/vim-visual-multi",
-- lazy = false,
-- }
}
return plugins

View File

@ -3,6 +3,14 @@
local default_plugins = { local default_plugins = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
{"tpope/vim-fugitive", lazy=false},
{"rbong/vim-flog", lazy=false},
{"tpope/vim-surround", lazy=false},
{"tpope/vim-obsession", lazy=false},
{"preservim/tagbar", lazy=false},
{"ludovicchabant/vim-gutentags", lazy=false},
{"nvim-telescope/telescope-fzf-native.nvim", run="make", lazy=false},
-- nvchad plugins -- nvchad plugins
{ "NvChad/extensions", branch = "v2.0" }, { "NvChad/extensions", branch = "v2.0" },