commit 96071b7d6fe9f0a8815262c84fcbcfc86b2fe12f
Author: Tonton <tonterface@proton.me>
Date: Wed, 22 Jul 2026 14:28:25 +0200
functional config with LSP
Diffstat:
16 files changed, 393 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -0,0 +1,6 @@
+# Tonton's neovim config
+
+## Dependencies
+*fzf
+*tree-sitter-cli
+*patched nerd font
diff --git a/init.lua b/init.lua
@@ -0,0 +1,52 @@
+-- custom neovim config
+
+-- auto install vim-plug and plugins, if not found
+local data_dir = vim.fn.stdpath('data')
+if vim.fn.empty(vim.fn.glob(data_dir .. '/site/autoload/plug.vim')) == 1 then
+ vim.cmd('silent !curl -fLo ' .. data_dir .. '/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
+ vim.o.runtimepath = vim.o.runtimepath
+ vim.cmd('autocmd VimEnter * PlugInstall --sync | source $MYVIMRC')
+end
+
+local vim = vim
+local Plug = vim.fn['plug#']
+
+vim.g.start_time = vim.fn.reltime()
+vim.loader.enable() -- SPEEEEEEEEEEED
+
+-- load plugins
+vim.call('plug#begin')
+Plug('nvim-tree/nvim-tree.lua') --file explorer
+Plug('nvim-treesitter/nvim-treesitter') --improved syntax
+Plug('ellisonleao/gruvbox.nvim', { ['as'] = 'gruvbox' }) --colorscheme
+Plug('nvim-lualine/lualine.nvim') --statusline
+Plug('romgrk/barbar.nvim') --bufferline
+Plug('windwp/nvim-autopairs') -- autopairs
+Plug('lewis6991/gitsigns.nvim') -- gitsigns
+Plug('nvim-tree/nvim-web-devicons') --devicons
+Plug('folke/which-key.nvim') -- keymap help
+Plug('ibhagwan/fzf-lua') -- fuzzyfind
+Plug('MeanderingProgrammer/render-markdown.nvim') -- render markdown
+Plug('neovim/nvim-lspconfig')
+
+-- lsp
+Plug('clangd/clangd')
+vim.call('plug#end')
+
+-- configs
+require("config.theme")
+require("config.mappings")
+require("config.options")
+require("config.autocmd")
+
+-- plugin configs
+require("plugins.nvim-tree")
+require("plugins.treesitter")
+require("plugins.lualine")
+require("plugins.barbar")
+require("plugins.autopairs")
+require("plugins.gitsigns")
+require("plugins.whichkey")
+require("plugins.fzf-lua")
+require("plugins.render-markdown")
+require("plugins.nvim-lspconfig")
diff --git a/lua/config/autocmd.lua b/lua/config/autocmd.lua
@@ -0,0 +1,11 @@
+-- various functions
+
+-- close nvim-tree if it's last buffer
+vim.api.nvim_create_autocmd("BufEnter", {
+ pattern = "*",
+ callback = function()
+ if #vim.api.nvim_list_bufs() == 1 and vim.bo.filetype == "NvimTree" then
+ vim.cmd("quit")
+ end
+ end,
+})
diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua
@@ -0,0 +1,50 @@
+-- mappings
+
+local function map(m, k, v)
+ vim.keymap.set(m, k, v, { noremap = true, silent = true } )
+end
+
+-- leader
+map("", "<Space>", "<Nop>")
+vim.g.mapleader = " "
+vim.g.maplocalleader = " "
+
+-- buffers
+map('n', "<S-k>", ":bnext<CR>")
+map('n', "<S-j>", ":bprevious<CR>")
+map('n', "<leader>x", ":BufferClose<CR>")
+map('n', "<leader>vv", ":vsplit<CR>:bnext<CR>")
+map('n', "<leader>vt", ":vs | wincmd l | term<CR>") -- vertical terminal
+map('n', "<leader>ht", ":sp | wincmd j | term<CR>") -- horizontal terminal
+
+-- windows
+-- navigation
+map('n', "<C-h>", "<C-w>h")
+map('n', "<C-j>", "<C-w>j")
+map('n', "<C-k>", "<C-w>k")
+map('n', "<C-l>", "<C-w>l")
+-- resize
+map('n', "<F5>", ":resize +2<CR>")
+map('n', "<F6>", ":resize -2<CR>")
+map('n', "<F7>", ":vertical resize +2<CR>")
+map('n', "<F8>", ":vertical resize -2<CR>")
+
+map('i', "<Tab>", "<Down>")
+-- fzf
+map('n', "<leader>f", ":lua require('fzf-lua').files()<CR>")
+map('n', "<leader>g", ":lua require('fzf-lua').grep()<CR>")
+
+-- misc
+map("n", "<C-n>", ":NvimTreeToggle<CR>") -- file explorer
+map("n", "<leader>C", ":so %<CR>") -- reload nvim config
+map("v", "<leader>i", "=gv") -- auto indent
+
+-- toggle relative or absolute line numbers
+map("n", "<leader>nn", function() --toggle relative vs absolute line numbers
+ if vim.wo.relativenumber then
+ vim.wo.relativenumber = false
+ vim.wo.number = true
+ else
+ vim.wo.relativenumber = true
+ end
+end)
diff --git a/lua/config/options.lua b/lua/config/options.lua
@@ -0,0 +1,19 @@
+local options = {
+ showmode = false,
+ cursorline = true,
+ ttyfast = true,
+ title = true,
+ undofile = true,
+
+ number = true, -- line numbers
+
+ tabstop = 8, -- indent size
+}
+
+for k, v in pairs(options) do
+ vim.opt[k] = v
+end
+
+vim.diagnostic.config({
+ signs = false,
+})
diff --git a/lua/config/theme.lua b/lua/config/theme.lua
@@ -0,0 +1,25 @@
+require("gruvbox").setup({
+ terminal_colors = true, -- add neovim terminal colors
+ undercurl = true,
+ underline = true,
+ bold = true,
+ italic = {
+ strings = true,
+ emphasis = true,
+ comments = true,
+ operators = false,
+ folds = true,
+ },
+ strikethrough = true,
+ invert_selection = false,
+ invert_signs = false,
+ invert_tabline = false,
+ inverse = true, -- invert background for search, diffs, statuslines and errors
+ contrast = "", -- can be "hard", "soft" or empty string
+ palette_overrides = {},
+ overrides = {},
+ dim_inactive = false,
+ transparent_mode = true,
+})
+
+vim.cmd("colorscheme gruvbox")
diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua
@@ -0,0 +1,13 @@
+require('nvim-autopairs').setup({
+ disable_in_macro = true, -- disable when recording or executing a macro
+ disable_in_visualblock = false, -- disable when insert after visual block mode
+ disable_in_replace_mode = true,
+ ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=],
+ enable_moveright = true,
+ enable_afterquote = true, -- add bracket pairs after quote
+ enable_check_bracket_line = true, --- check bracket in same line
+ enable_bracket_in_quote = true, --
+ enable_abbr = false, -- trigger abbreviation
+ break_undo = true, -- switch for basic rule break undo sequence
+ check_ts = false,
+ })
diff --git a/lua/plugins/barbar.lua b/lua/plugins/barbar.lua
@@ -0,0 +1,59 @@
+vim.g.barbar_auto_setup = false -- disable auto-setup
+require("barbar").setup({
+ animation = false,
+
+ -- Enable/disable current/total tabpages indicator (top right corner)
+ tabpages = true,
+
+ -- A buffer to this direction will be focused (if it exists) when closing the current buffer.
+ -- Valid options are 'left' (the default), 'previous', and 'right'
+ focus_on_close = 'left',
+
+ -- Hide inactive buffers and file extensions. Other options are `alternate`, `current`, and `visible`.
+ hide = {extensions = false, inactive = false},
+
+ icons = {
+ buffer_index = false,
+ buffer_number = false,
+ button = '',
+ diagnostics = {
+ [vim.diagnostic.severity.ERROR] = {enabled = true, icon = ' '},
+ },
+ gitsigns = {
+ added = {enabled = true, icon = ' '},
+ changed = {enabled = true, icon = ' '},
+ deleted = {enabled = true, icon = ' '},
+ },
+ separator = {left = '▎', right = ''},
+
+ -- If true, add an additional separator at the end of the buffer list
+ separator_at_end = true,
+
+ -- Configure the icons on the bufferline when modified or pinned.
+ -- Supports all the base icon options.
+ modified = {button = '●'},
+ pinned = {button = '', filename = true},
+
+ -- Configure the icons on the bufferline based on the visibility of a buffer.
+ -- Supports all the base icon options, plus `modified` and `pinned`.
+ alternate = {filetype = {enabled = false}},
+ current = {buffer_index = true},
+ inactive = {button = '×'},
+ visible = {modified = {buffer_number = false}},
+ },
+
+ sidebar_filetypes = { -- Set the filetypes which barbar will offset itself for
+ -- Use the default values: {event = 'BufWinLeave', text = '', align = 'left'}
+ NvimTree = true,
+ -- Or, specify the text used for the offset:
+ undotree = {
+ text = 'undotree',
+ align = 'left', -- *optionally* specify an alignment (either 'left', 'center', or 'right')
+ },
+ -- Or, specify the event which the sidebar executes when leaving:
+ ['neo-tree'] = {event = 'BufWipeout'},
+ -- Or, specify all three
+ Outline = {event = 'BufWinLeave', text = 'symbols-outline', align = 'right'},
+ },
+ maximum_length = 25, -- Sets the maximum buffer name length.
+})
diff --git a/lua/plugins/fzf-lua.lua b/lua/plugins/fzf-lua.lua
diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua
@@ -0,0 +1,19 @@
+require('gitsigns').setup {
+ signs = {
+ add = { text = '┃' },
+ change = { text = '┃' },
+ delete = { text = '_' },
+ topdelete = { text = '‾' },
+ changedelete = { text = '~' },
+ untracked = { text = '┆' },
+ },
+ signs_staged = {
+ add = { text = '┃' },
+ change = { text = '┃' },
+ delete = { text = '_' },
+ topdelete = { text = '‾' },
+ changedelete = { text = '~' },
+ untracked = { text = '┆' },
+ },
+ signs_staged_enable = true,
+}
diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua
@@ -0,0 +1,62 @@
+local lualine = require('lualine')
+
+local diagnostics = {
+ "diagnostics",
+ sources = { "nvim_diagnostic" },
+ sections = { "error", "warn" },
+ symbols = { error = " ", warn = " " },
+ colored = true,
+ update_in_insert = false,
+ always_visible = true,
+ cond = function()
+ return vim.bo.filetype ~= "markdown"
+ end,
+}
+
+local diff = {
+ "diff",
+ colored = true,
+ symbols = { added = " ", modified = " ", removed = " " },
+}
+
+local mode = {
+ "mode",
+ fmt = function(str)
+ return "-- " .. str .. " --"
+ end,
+}
+
+local branch = {
+ "branch",
+ icon = "",
+}
+
+local progress = function()
+ local current_line = vim.fn.line(".")
+ local total_lines = vim.fn.line("$")
+ local chars = { "", "", "" } --adding more chars will still work
+ local line_ratio = current_line / total_lines
+ local index = math.ceil(line_ratio * #chars)
+ return chars[index] .. " " .. math.floor(line_ratio * 100) .. "%%"
+end
+
+lualine.setup({
+options = {
+ icons_enabled = true,
+ theme = "auto", --auto allows for theme switching
+ component_separators = { left = "", right = "" },
+ section_separators = { left = "", right = "" },
+ disabled_filetypes = { "alpha", "dashboard" },
+ always_divide_middle = true,
+ },
+
+sections = {
+ lualine_a = { branch },
+ lualine_b = { mode },
+ lualine_c = { diagnostics },
+ lualine_x = { diff, "fileformat", "filetype" },
+ lualine_y = { "location" },
+ lualine_z = { progress },
+ },
+ extensions = { 'nvim-tree' },
+})
diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua
@@ -0,0 +1,15 @@
+vim.cmd[[set completeopt+=menuone,noselect,popup]]
+vim.lsp.config('clangd', {
+ on_attach = function(client, bufnr)
+ local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
+ client.server_capabilities.completionProvider.triggerCharacters = chars
+ vim.lsp.completion.enable(true, client.id, bufnr, {
+ autotrigger = true,
+ convert = function(item)
+ return { abbr = item.label:gsub('%b()', '')}
+ end,
+ })
+ end,
+})
+
+vim.lsp.enable('clangd')
diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua
@@ -0,0 +1,30 @@
+require("nvim-tree").setup({
+ renderer = {
+ icons = {
+ show = {
+ file = true,
+ folder = false,
+ git = true,
+ },
+ glyphs = {
+ git = {
+ staged = " ",
+ unstaged = " ",
+ unmerged = " ",
+ renamed = " ",
+ deleted = " ",
+ untracked = " ",
+ ignored = " ",
+ },
+ },
+ },
+
+ },
+ view = {
+ width = 25,
+ side = 'left',
+ },
+
+})
+
+vim.g.nvim_tree_respect_buf_cwd = 1
diff --git a/lua/plugins/render-markdown.lua b/lua/plugins/render-markdown.lua
@@ -0,0 +1 @@
+
diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua
@@ -0,0 +1,20 @@
+return {
+ "nvim-treesitter/nvim-treesitter",
+ lazy = false,
+ build = ":TSUpdate",
+ config = function ()
+ local treesitter = require("nvim-treesitter")
+ treesitter.setup()
+
+ treesitter.install = { "asm", "bash", "c", "css", "cpp", "html", "json", "lua", "markdown", "markdown_inline", "latex" },
+
+ vim.api.nvim_create_autocmd('FileType', {
+ pattern = { "asm", "bash", "c", "css", "cpp", "html", "json", "lua", "markdown", "markdown_inline", "tex" },
+
+ callback = function()
+ vim.treesitter.start()
+ vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
+ end,
+ })
+ end
+}
diff --git a/lua/plugins/whichkey.lua b/lua/plugins/whichkey.lua
@@ -0,0 +1,11 @@
+local wk = require("which-key")
+wk.add({
+ {"<leader>nn", desc = "toggle relative number"},
+ {"<leader>x", desc = "Close buffer"},
+ {"<leader>C", desc = "Reload nvim config"},
+ {"<leader>vv", desc = "vsplit next buf"},
+ {"<leader>f", desc = "fuzzy search cwd"},
+ {"<leader>g", desc = "grep"},
+ {"<leader>vt", desc = "Open vertical terminal"},
+ {"<leader>ht", desc = "Open horizontal terminal"},
+})