Created
          October 8, 2025 16:35 
        
      - 
      
- 
        Save lcheylus/512f70918b6667ca0fcc679a57063097 to your computer and use it in GitHub Desktop. 
    Minimal configuration file for Neovim
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | -- Minimal configuration file for Neovim | |
| -- Check if needed commands are available | |
| local function is_command_available(cmd) | |
| -- os.execute returns true (or exit code 0) if the command exists | |
| local result = os.execute('command -v ' .. cmd .. ' >/dev/null 2>&1') | |
| -- Lua 5.2+ returns true on success, or nil/false on failure | |
| -- Lua 5.1 returns status code shifted left (e.g., 0 = success) | |
| if result == true or result == 0 then | |
| return true | |
| else | |
| return false | |
| end | |
| end | |
| local commands = { 'git', 'tar', 'curl', 'tree-sitter' } | |
| for _, cmd in ipairs(commands) do | |
| if not is_command_available(cmd) then | |
| vim.api.nvim_echo({ | |
| { "ERROR: '" .. cmd .. "' command not available, install it first\n", 'ErrorMsg' }, | |
| { '\nPress any key to exit...' }, | |
| }, true, {}) | |
| vim.fn.getchar() | |
| os.exit(1) | |
| end | |
| end | |
| -- Bootstrap lazy.nvim | |
| local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' | |
| if not (vim.uv or vim.loop).fs_stat(lazypath) then | |
| local lazyrepo = 'https://github.com/folke/lazy.nvim.git' | |
| local out = vim.fn.system({ 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }) | |
| if vim.v.shell_error ~= 0 then | |
| vim.api.nvim_echo({ | |
| { 'Failed to clone lazy.nvim:\n', 'ErrorMsg' }, | |
| { out, 'WarningMsg' }, | |
| { '\nPress any key to exit...' }, | |
| }, true, {}) | |
| vim.fn.getchar() | |
| os.exit(1) | |
| end | |
| end | |
| vim.opt.rtp:prepend(lazypath) | |
| -- Make sure to setup `mapleader` and `maplocalleader` before | |
| -- loading lazy.nvim so that mappings are correct. | |
| vim.g.mapleader = ' ' | |
| vim.g.maplocalleader = '\\' | |
| -- Languages for tree-sitter plugin | |
| local languages = { | |
| 'c', | |
| 'cpp', | |
| 'bash', | |
| 'cmake', | |
| 'make', | |
| 'lua', | |
| 'markdown', | |
| 'markdown_inline', | |
| 'vim', | |
| 'vimdoc', | |
| 'html', | |
| 'json', | |
| 'json5', | |
| 'java', | |
| 'llvm', | |
| 'python', | |
| 'perl', | |
| 'go', | |
| 'gomod', | |
| 'php', | |
| 'rust', | |
| 'zig', | |
| 'v', | |
| 'toml', | |
| 'yaml', | |
| } | |
| -- Setup lazy.nvim | |
| require('lazy').setup({ | |
| -- import plugins | |
| spec = { | |
| -- monokai-pro theme | |
| { | |
| 'loctvl842/monokai-pro.nvim', | |
| lazy = false, -- make sure we load this during startup if it is your main colorscheme | |
| priority = 1000, -- make sure to load this before all the other start plugins | |
| config = function() | |
| require('monokai-pro').setup({ | |
| styles = { | |
| comment = { italic = false }, | |
| keyword = { italic = false }, | |
| type = { italic = false }, | |
| storageclass = { italic = false }, | |
| structure = { italic = false }, | |
| parameter = { italic = false }, | |
| annotation = { italic = false }, | |
| tag_attribute = { italic = false }, | |
| }, | |
| }) | |
| vim.cmd([[colorscheme monokai-pro]]) | |
| -- Highlight Search with background Yellow | |
| vim.api.nvim_set_hl(0, 'Search', { fg = '#26292C', bg = '#fcfa26' }) | |
| end, | |
| }, | |
| { | |
| 'nvim-lualine/lualine.nvim', | |
| dependencies = { 'nvim-tree/nvim-web-devicons' }, | |
| }, | |
| { | |
| 'nvim-treesitter/nvim-treesitter', | |
| lazy = false, | |
| branch = 'main', | |
| build = ':TSUpdate', | |
| config = function() | |
| require('nvim-treesitter').install(languages) | |
| require('nvim-treesitter').setup({ | |
| -- Directory to install parsers and queries to | |
| install_dir = vim.fn.stdpath('data') .. '/site', | |
| }) | |
| end, | |
| }, | |
| }, | |
| -- colorscheme that will be used when installing plugins. | |
| install = { colorscheme = { 'monokai-pro' } }, | |
| -- automatically check for plugin updates | |
| checker = { enabled = true }, | |
| rocks = { enabled = false }, | |
| }) | |
| -- Setup plugins | |
| require('lualine').setup() | |
| -- Enable highlight with tree-sitter for languages | |
| vim.api.nvim_create_autocmd('FileType', { | |
| desc = 'Enable highlight with tree-sitter', | |
| pattern = languages, | |
| callback = function() | |
| vim.treesitter.start() | |
| end, | |
| }) | |
| -- Options | |
| vim.opt.history = 1000 -- Size for history of commands | |
| vim.opt.mouse = '' -- Disable mouse support in all modes | |
| vim.opt.formatoptions = 'tcqj' -- See :help fo-table - Auto-wrap text and comment using textwidth | |
| -- Allows formatting of comments with "gq" | |
| vim.opt.showmode = false -- Don't show the mode, since it's already in the status line | |
| vim.opt.scrolloff = 10 -- Minimal number of screen lines to keep above and below the cursor | |
| vim.opt.clipboard = 'unnamedplus' -- Sync clipboard between OS and Neovim | |
| vim.opt.breakindent = true -- Every wrapped line will continue visually indented | |
| vim.opt.undofile = true -- Automatically saves undo history to an undo file | |
| vim.opt.updatetime = 250 -- Decrease update time (swap file written automatically on disk) | |
| vim.opt.timeoutlen = 300 -- Decrease mapped sequence wait time. Displays which-key popup sooner | |
| -- Sets how neovim will display certain whitespace characters in the editor. | |
| vim.opt.list = true | |
| vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } | |
| vim.opt.fileencoding = 'utf-8' -- the encoding written to a file | |
| vim.opt.textwidth = 80 | |
| -- Options for colors | |
| vim.opt.background = 'dark' | |
| vim.opt.termguicolors = true | |
| -- Set title for Terminal | |
| vim.opt.title = true | |
| -- Python provider | |
| local os = vim.loop.os_uname().sysname | |
| if os == 'OpenBSD' then | |
| vim.g.python3_host_prog = '/usr/local/bin/python3' | |
| elseif os == 'FreeBSD' then | |
| vim.g.python3_host_prog = '/usr/local/bin/python' | |
| else | |
| vim.g.python3_host_prog = '/usr/bin/python3' | |
| end | |
| -- Commands | |
| local autocmd = vim.api.nvim_create_autocmd | |
| local augroup = vim.api.nvim_create_augroup | |
| -- General settings | |
| augroup('general_settings', { clear = true }) | |
| autocmd('VimLeave', { | |
| group = 'general_settings', | |
| desc = 'General settings - Restore cursor shape (vertical bar) on exit', | |
| pattern = '*', | |
| callback = function() | |
| vim.cmd('set guicursor=a:ver25') | |
| end, | |
| }) | |
| autocmd('Filetype', { | |
| group = 'general_settings', | |
| desc = 'General settings - Close with q', | |
| pattern = { 'help', 'man', 'qf', 'lspinfo', 'notify' }, | |
| callback = function() | |
| vim.api.nvim_set_keymap('n', 'q', '<cmd>quit<CR>', { noremap = true, silent = true }) | |
| end, | |
| }) | |
| autocmd('TextYankPost', { | |
| group = 'general_settings', | |
| desc = 'Hightlight selection on yank', | |
| pattern = '*', | |
| callback = function() | |
| vim.highlight.on_yank({ higroup = 'IncSearch', timeout = 500 }) | |
| end, | |
| }) | |
| -- Last positon jump (see :help last-position-jump) | |
| autocmd('BufRead', { | |
| group = augroup('last_position_jump', { clear = true }), | |
| desc = 'Jump to last position', | |
| pattern = '*', | |
| callback = function() | |
| local ft = vim.opt_local.filetype:get() | |
| -- don't apply to git messages | |
| if ft:match('commit') or ft:match('rebase') then | |
| return | |
| end | |
| -- get position of last saved edit | |
| local markpos = vim.api.nvim_buf_get_mark(0, '"') | |
| local line = markpos[1] | |
| local col = markpos[2] | |
| -- if in range, go there | |
| if (line > 1) and (line <= vim.api.nvim_buf_line_count(0)) then | |
| vim.api.nvim_win_set_cursor(0, { line, col }) | |
| end | |
| end, | |
| }) | |
| -- disable hlsearch automatically when your search done and enable on next searching | |
| local ns = vim.api.nvim_create_namespace('toggle_hlsearch') | |
| local function toggle_hlsearch(char) | |
| if vim.fn.mode() == 'n' then | |
| local keys = { '<CR>', 'n', 'N', '*', '#', '?', '/' } | |
| local new_hlsearch = vim.tbl_contains(keys, vim.fn.keytrans(char)) | |
| if vim.opt.hlsearch:get() ~= new_hlsearch then | |
| vim.opt.hlsearch = new_hlsearch | |
| end | |
| end | |
| end | |
| vim.on_key(toggle_hlsearch, ns) | |
| -- Keymaps | |
| -- Remap space as leader key | |
| vim.api.nvim_set_keymap('', '<Space>', '<Nop>', { desc = 'Leader', noremap = true, silent = true }) | |
| vim.g.mapleader = ' ' | |
| vim.g.maplocalleader = '\\' | |
| -- Better window navigation | |
| vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', { desc = 'Move to left split', noremap = true, silent = true }) | |
| vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', { desc = 'Move to below split', noremap = true, silent = true }) | |
| vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', { desc = 'Move to above split', noremap = true, silent = true }) | |
| vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', { desc = 'Move to right split', noremap = true, silent = true }) | |
| -- Indent in Visual mode | |
| vim.api.nvim_set_keymap('v', '<', '<gv', { desc = 'unindent line', noremap = true, silent = true }) | |
| vim.api.nvim_set_keymap('v', '>', '>gv', { desc = 'indent line', noremap = true, silent = true }) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment