diff --git a/Internal/os_nvim_init.lua b/Internal/os_nvim_init.lua new file mode 100644 index 0000000..18c5909 --- /dev/null +++ b/Internal/os_nvim_init.lua @@ -0,0 +1,512 @@ +-- ============================================================================ +-- Modern Neovim Configuration (lazy.nvim) +-- ============================================================================ + +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +-- ============================================================================ +-- Plugin Specifications +-- ============================================================================ +require("lazy").setup({ + -- File tree + { + 'scrooloose/nerdtree', + cmd = 'NERDTreeToggle', + }, + + -- Build/async tools + 'tpope/vim-dispatch', + + -- Git integration + 'tpope/vim-fugitive', + + -- Text manipulation + 'tpope/vim-abolish', + + -- Large file handling + { + 'LunarVim/bigfile.nvim', + config = function() + require('bigfile').setup() + end, + }, + + -- FZF + { 'junegunn/fzf' }, + { + 'ibhagwan/fzf-lua', + branch = 'main', + config = function() + require('fzf-lua').setup({ + winopts = { + height = 0.95, + width = 0.95 + } + }) + end, + }, + 'nvim-tree/nvim-web-devicons', + + -- Alignment + { + 'junegunn/vim-easy-align', + init = function() + vim.g.easy_align_delimiters = { + ['>'] = { pattern = '>>\\|=>\\|>' }, + ['/'] = { + pattern = '//\\+\\|/\\*\\|\\*/', + delimiter_align = 'l', + ignore_groups = {'!Comment'} + }, + [']'] = { + pattern = '[[\\]]', + left_margin = 0, + right_margin = 0, + stick_to_left = 0 + }, + [')'] = { + pattern = '[)]', + left_margin = 0, + right_margin = 0, + stick_to_left = 0 + }, + ['('] = { + pattern = '[(]', + left_margin = 0, + right_margin = 0, + stick_to_left = 0 + }, + } + end, + }, + + -- File picker + { + 'dmtrKovalenko/fff.nvim', + build = function() + -- this will download prebuild binary or try to use existing rustup toolchain to build from source + -- (if you are using lazy you can use gb for rebuilding a plugin if needed) + require("fff.download").download_or_build_binary() + end, + -- No need to lazy-load with lazy.nvim. + -- This plugin initializes itself lazily. + lazy = false, + keys = { + { + "f", + function() require('fff').find_files() end, + desc = 'FFFind files', + }, + { + "r", + function() require('fff').live_grep() end, + desc = 'LiFFFe grep', + }, + { + "fz", + function() require('fff').live_grep({ + grep = { + modes = { 'fuzzy', 'plain' } + } + }) end, + desc = 'Live fffuzy grep', + }, + { + "R", + function() require('fff').live_grep({ query = vim.fn.expand("") }) end, + desc = 'Search current word', + }, + } + }, + + -- C++ syntax highlighting + { + 'bfrg/vim-cpp-modern', + init = function() + vim.g.cpp_function_highlight = 1 + vim.g.cpp_attributes_highlight = 1 + vim.g.cpp_member_highlight = 0 + vim.g.cpp_simple_highlight = 1 + end, + }, + + -- Motion + { + url = 'https://codeberg.org/andyg/leap.nvim', + lazy = false, + config = function() + vim.keymap.set({'n', 'x', 'o'}, '', '(leap)') + vim.keymap.set({'n', 'x', 'o'}, '', '(leap-from-window)') + -- Highly recommended: define a preview filter to reduce visual noise + -- and the blinking effect after the first keypress + -- (see `:h leap.opts.preview`). + -- For example, skip preview if the first character of the match is + -- whitespace or is in the middle of an alphabetic word: + require('leap').opts.preview = function(ch0, ch1, ch2) + return not ( + ch1:match('%s') + or (ch0:match('%a') and ch1:match('%a') and ch2:match('%a')) + ) + end + + -- Define equivalence classes for brackets and quotes, in addition to + -- the default whitespace group: + require('leap').opts.equivalence_classes = { ' \t\r\n', '([{', ')]}', '\'"`' } + + -- Use the traversal keys to repeat the previous motion without + -- explicitly invoking Leap: + require('leap.user').set_repeat_keys('', '') + + -- Automatic paste after remote yank operations: + vim.api.nvim_create_autocmd('User', { + pattern = 'RemoteOperationDone', + group = vim.api.nvim_create_augroup('LeapRemote', {}), + callback = function(event) + if vim.v.operator == 'y' and event.data.register == '"' then + vim.cmd('normal! p') + end + end, + }) + end + }, + + -- Theme + { + 'sainnhe/gruvbox-material', + priority = 1000, + init = function() + vim.g.gruvbox_material_background = 'hard' + vim.g.gruvbox_material_foreground = 'mix' + vim.g.gruvbox_material_disable_italic_comment = 1 + vim.g.gruvbox_material_enable_italic = 0 + vim.g.gruvbox_material_enable_bold = 0 + vim.g.gruvbox_material_diagnostic_virtual_text = 'colored' + vim.g.gruvbox_material_better_performance = 1 + end, + config = function() + vim.cmd('colorscheme gruvbox-material') + end, + }, + + -- Odin syntax + 'Tetralux/odin.vim', + + -- Treesitter + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + }, + + -- LSP + { + 'williamboman/mason.nvim', + config = function() + require('mason').setup({}) + end, + }, + { + 'williamboman/mason-lspconfig.nvim', + config = function() + require('mason-lspconfig').setup({ + ensure_installed = { "clangd" }, + automatic_enable = true, + }) + end, + }, + 'neovim/nvim-lspconfig', + + -- Completion + { + 'hrsh7th/nvim-cmp', + dependencies = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'L3MON4D3/LuaSnip', + }, + config = function() + local cmp = require('cmp') + cmp.setup({ + sources = { + { name = 'nvim_lsp' }, + { name = 'buffer' }, + { name = 'path' }, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.confirm({ select = false }), + [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + }), + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + }) + end, + }, + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'L3MON4D3/LuaSnip', + + -- Utilities + 'nvim-lua/plenary.nvim', + { + "ThePrimeagen/99", + config = function() + local _99 = require("99") + _99.setup({ + -- When setting this to something that is not inside the CWD tools + -- such as claude code or opencode will have permission issues + -- and generation will fail refer to tool documentation to resolve + -- https://opencode.ai/docs/permissions/#external-directories + -- https://code.claude.com/docs/en/permissions#read-and-edit + tmp_dir = "./tmp", + provider = _99.Providers.OpenCodeProvider, + model = "kimi-k2.5", + }) + + -- take extra note that i have visual selection only in v mode + -- technically whatever your last visual selection is, will be used + -- so i have this set to visual mode so i dont screw up and use an + -- old visual selection + -- + -- likely ill add a mode check and assert on required visual mode + -- so just prepare for it now + vim.keymap.set("v", "9v", function() _99.visual() end) + + --- if you have a request you dont want to make any changes, just cancel it + vim.keymap.set("n", "9x", function() _99.stop_all_requests() end) + vim.keymap.set("n", "9s", function() _99.search() end) + end, + }, +}, { + install = { + colorscheme = { "gruvbox-material" }, + }, + checker = { + enabled = false, + }, +}) + +-- ============================================================================ +-- Options +-- ============================================================================ +vim.opt.autowrite = true +vim.opt.colorcolumn = { 80, 100 } +vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } +vim.opt.cpoptions:append('$') +vim.opt.cursorline = true +vim.opt.expandtab = true +vim.opt.guifont = { 'JetBrains_Mono:h9', 'Consolas:h9', 'InputMonoCondensed:h9' } +vim.opt.hlsearch = false +vim.opt.ignorecase = true +vim.opt.linebreak = true +vim.opt.list = true +vim.opt.listchars:append('tab:>-,trail:■,extends:»,precedes:«') +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.shiftwidth = 4 +vim.opt.splitright = true +vim.opt.swapfile = false +vim.opt.textwidth = 80 +vim.opt.visualbell = true +vim.opt.wrap = false +vim.opt.signcolumn = 'no' + +-- Setup undo and backup directories +vim.opt.undofile = true +vim.opt.undodir = vim.fn.stdpath('config') .. '/undo' +vim.opt.backupdir = vim.fn.stdpath('config') .. '/backup' + +-- Status line +vim.opt.statusline = '%<%F%h%m%r [%{&ff}] (%{strftime("%H:%M %d/%m/%Y",getftime(expand("%:p")))})%=%l,%c%V %P' + +-- Wild ignore +vim.opt.wildignore:append('*.class,*.o,*\\tmp\\*,*.swp,*.zip,*.exe,*.obj,*.vcxproj,*.pdb,*.idb') + +-- Mouse support +vim.opt.mouse = 'a' + +-- Spelling +vim.opt.spell = true + +-- ============================================================================ +-- LSP Configuration +-- ============================================================================ +local opts = { noremap = true, silent = true } +vim.keymap.set("n", "", vim.lsp.buf.rename, opts) +vim.keymap.set("n", "", vim.lsp.buf.code_action, opts) +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) +vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + +-- Diagnostic configuration +vim.diagnostic.config({ + signs = false, + virtual_text = true, +}) + +-- Spelling highlight +vim.api.nvim_create_autocmd("LspAttach", { + callback = function() + vim.cmd("highlight SpellBad gui=underline guifg=#d3869b") + end, +}) + +-- ============================================================================ +-- Vim Dispatch Configuration +-- ============================================================================ +if vim.fn.has('win64') == 1 or vim.fn.has('win32') == 1 or vim.fn.has('win16') == 1 then + if os.getenv('SHELL') ~= nil then + vim.o.shellcmdflag = '-c' + vim.o.makeprg = "./build.sh" + else + vim.o.makeprg = "build.bat" + end +else + vim.o.makeprg = "./build.sh" +end + +-- ============================================================================ +-- Autocommands +-- ============================================================================ + +-- Automatically scroll to bottom of quickfix window when opened +vim.api.nvim_create_autocmd("FileType", { + pattern = "qf", + callback = function() + vim.cmd('normal! G') + end, +}) + +-- Per-Project Bindings - load project file on buffer enter +vim.api.nvim_create_autocmd("BufEnter", { + callback = function() + local project_file = vim.fn.getcwd() .. '/project_nvim.lua' + if vim.fn.filereadable(project_file) == 1 then + vim.cmd('luafile ' .. vim.fn.fnameescape(project_file)) + end + end, +}) + +-- Formatting options +vim.api.nvim_create_augroup("persistent_settings", { clear = true }) +vim.api.nvim_create_autocmd("BufEnter", { + group = "persistent_settings", + pattern = "*", + command = "set formatoptions=q1j", +}) + +-- ============================================================================ +-- Functions +-- ============================================================================ +local function raddbg_open_file() + local filepath = vim.fn.expand("%:p"):gsub('\\', '/') + vim.fn.system("dev raddbg --ipc open " .. filepath) + vim.fn.system("dev raddbg --ipc goto_line " .. vim.fn.line(".")) + vim.fn.system("powershell -Command Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::AppActivate('The RAD Debugger')") +end + +local function raddbg_start_debugging() + vim.fn.system("dev raddbg --ipc run") +end + +local function raddbg_stop_debugging() + vim.fn.system("dev raddbg --ipc kill_all") +end + +local function raddbg_run_to_cursor() + local filepath = vim.fn.expand("%:p"):gsub('\\', '/') + vim.fn.system("dev raddbg --ipc open " .. filepath) + vim.fn.system("dev raddbg --ipc goto_line " .. vim.fn.line(".")) + vim.fn.system("dev raddbg --ipc run_to_cursor " .. filepath .. ":" .. vim.fn.line(".")) + vim.fn.system("powershell -Command Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::AppActivate('The RAD Debugger')") +end + +local function raddbg_add_breakpoint() + local filepath = vim.fn.expand("%:p"):gsub('\\', '/') + vim.fn.system("dev raddbg --ipc open " .. filepath) + vim.fn.system("dev raddbg --ipc goto_line " .. vim.fn.line(".")) + vim.fn.system("dev raddbg --ipc toggle_breakpoint " .. filepath .. ":" .. vim.fn.line(".")) + vim.fn.system("powershell -Command Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::AppActivate('The RAD Debugger')") +end + +-- ============================================================================ +-- Keymaps +-- ============================================================================ + +-- Font size adjustment (GUI only) +vim.keymap.set('n', '', function() + vim.opt.guifont = vim.fn.substitute(vim.opt.guifont:get()[1] or '', ':h\\zs\\d\\+', function(m) + return tostring(tonumber(m) + 1) + end, 'g') +end, { silent = true }) + +vim.keymap.set('n', '', function() + vim.opt.guifont = vim.fn.substitute(vim.opt.guifont:get()[1] or '', ':h\\zs\\d\\+', function(m) + return tostring(tonumber(m) - 1) + end, 'g') +end, { silent = true }) + +-- FZF Bindings +vim.keymap.set('n', 'h', 'FzfLua oldfiles') +vim.keymap.set('n', 't', 'FzfLua lsp_live_workspace_symbols') +vim.keymap.set('n', 'T', 'FzfLua lsp_finder') +vim.keymap.set('n', 'b', 'FzfLua buffers') +vim.keymap.set('n', '', 'FzfLua') + +-- Window navigation +vim.keymap.set('n', '', 'h', { silent = true }) +vim.keymap.set('n', '', 'j', { silent = true }) +vim.keymap.set('n', '', 'k', { silent = true }) +vim.keymap.set('n', '', 'l', { silent = true }) + +-- Move by wrapped lines +vim.keymap.set('n', 'j', 'gj') +vim.keymap.set('n', 'k', 'gk') +vim.keymap.set('n', 'gj', 'j') +vim.keymap.set('n', 'gk', 'k') + +-- NERDTree +vim.keymap.set('n', '', ':NERDTreeToggle') + +-- Change to current buffer's directory +vim.keymap.set('n', 'cd', function() + vim.cmd('cd ' .. vim.fn.expand('%:p:h')) +end) + +-- Buffer splitting +vim.keymap.set('n', 's', ':vs') + +-- Quickfix navigation +vim.keymap.set('n', '', ':cn') +vim.keymap.set('n', '', ':cp') + +-- Terminal escape +vim.keymap.set('t', '', '') + +-- Make (Vim Dispatch) +vim.keymap.set('n', '', ':Make', { noremap = true }) + +-- Easy-Align +vim.keymap.set('x', 'a', '(LiveEasyAlign)') + +-- RAD Debugger +vim.keymap.set('n', '', function() raddbg_open_file() end, { silent = true }) +vim.keymap.set('n', '', function() raddbg_start_debugging() end, { silent = true }) +vim.keymap.set('n', '', function() raddbg_stop_debugging() end, { silent = true }) +vim.keymap.set('n', '', function() raddbg_add_breakpoint() end, { silent = true }) +vim.keymap.set('n', '', function() raddbg_run_to_cursor() end, { silent = true }) diff --git a/Internal/os_nvim_init.vim b/Internal/os_nvim_init.vim deleted file mode 100644 index 0563639..0000000 --- a/Internal/os_nvim_init.vim +++ /dev/null @@ -1,429 +0,0 @@ -" Plugins ////////////////////////////////////////////////////////////////////////////////////////// -call plug#begin(stdpath('config') . '/plugged') - " nerdtree provides a file tree explorer - " vim-dispatch allows running async jobs in vim (i.e. builds in the background) - Plug 'https://github.com/scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } - Plug 'https://github.com/tpope/vim-dispatch' - Plug 'https://github.com/tpope/vim-fugitive' - Plug 'https://github.com/tpope/vim-abolish' - Plug 'https://github.com/LunarVim/bigfile.nvim' - - " FZF - Plug 'junegunn/fzf' - Plug 'ibhagwan/fzf-lua', {'branch': 'main'} - Plug 'nvim-tree/nvim-web-devicons' - - " Other //////////////////////////////////////////////////////////////////////////////////////// - " TODO: 2022-06-19 Treesitter is too slow on large C++ files - " Plug 'https://github.com/nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} - Plug 'junegunn/vim-easy-align' - Plug 'https://github.com/bfrg/vim-cpp-modern' - Plug 'https://codeberg.org/andyg/leap.nvim' - Plug 'https://github.com/sainnhe/gruvbox-material' - Plug 'https://github.com/Tetralux/odin.vim' "Odin Syntax highlighting - - " NOTE: LLM - Plug 'nvim-treesitter/nvim-treesitter' - Plug 'nvim-lua/plenary.nvim' - Plug 'olimorris/codecompanion.nvim' - - " lsp-zero begin - " LSP Support - Plug 'williamboman/mason.nvim' - Plug 'williamboman/mason-lspconfig.nvim' - Plug 'neovim/nvim-lspconfig' - Plug 'hrsh7th/nvim-cmp' - Plug 'hrsh7th/cmp-nvim-lsp' - Plug 'L3MON4D3/LuaSnip' - Plug 'hrsh7th/cmp-buffer' - Plug 'hrsh7th/cmp-path' - " lsp-zero end -call plug#end() - -" Lua Setup //////////////////////////////////////////////////////////////////////////////////////// -lua <', '(leap)') - vim.keymap.set({'n', 'x', 'o'}, '', '(leap-from-window)') - - require('bigfile').setup() - require('fzf-lua').setup{ - winopts = { - height=0.95, - width=0.95 - } - } - - -- Vim Dispatch ////////////////////////////////////////////////////////////////////////////////// - if vim.fn.has('win64') or vim.fn.has('win32') or vim.fn.has('win16') then - if os.getenv('SHELL') ~= nil then - vim.o.shellcmdflag = '-c' - vim.o.makeprg = "./build.sh" - else - vim.o.makeprg = "build.bat" - end - else - vim.o.makeprg = "./build.sh" - end - vim.api.nvim_set_keymap('n', '', ':Make', {noremap = true}) - - -- LSP Setup ///////////////////////////////////////////////////////////////////////////////////// - require('mason').setup({}) - require('mason-lspconfig').setup({ - ensure_installed = { "clangd" }, - automatic_enable = true - }) - - local opts = { noremap = true, silent = true } - vim.keymap.set("n", "", vim.lsp.buf.rename, opts) - vim.keymap.set("n", "", vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) - - local cmp = require('cmp') - cmp.setup({ - sources = { - {name = 'nvim_lsp'}, - {name = 'buffer'}, - {name = 'path'}, - - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.confirm({select = false}), - [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - }), - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - --- (Optional) Show source name in completion menu - formatting = cmp_format, - }) - - require("codecompanion").setup({ - display = { - chat = { - auto_scroll = false, - fold_context = true, - show_settings = true, - show_header_separator = true, - } - }, - adapters = { - http = { - opts = { - show_defaults = false, - }, - llamafile = function() - return require("codecompanion.adapters").extend("openai_compatible", { - env = { - url = "http://127.0.0.1:7483", -- optional: default value is ollama url http://127.0.0.1:11434 - chat_url = "/v1/chat/completions", -- optional: default value, override if different - -- api_key = "OpenAI_API_KEY", -- optional: if your endpoint is authenticated - -- models_endpoint = "/v1/models", -- optional: attaches to the end of the URL to form the endpoint to retrieve models - }, - -- schema = { - -- model = { - -- default = "deepseek-r1-671b", -- define llm model to be used - -- }, - -- temperature = { - -- order = 2, - -- mapping = "parameters", - -- type = "number", - -- optional = true, - -- default = 0.8, - -- desc = "What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.", - -- validate = function(n) - -- return n >= 0 and n <= 2, "Must be between 0 and 2" - -- end, - -- }, - -- max_completion_tokens = { - -- order = 3, - -- mapping = "parameters", - -- type = "integer", - -- optional = true, - -- default = nil, - -- desc = "An upper bound for the number of tokens that can be generated for a completion.", - -- validate = function(n) - -- return n > 0, "Must be greater than 0" - -- end, - -- }, - -- stop = { - -- order = 4, - -- mapping = "parameters", - -- type = "string", - -- optional = true, - -- default = nil, - -- desc = "Sets the stop sequences to use. When this pattern is encountered the LLM will stop generating text and return. Multiple stop patterns may be set by specifying multiple separate stop parameters in a modelfile.", - -- validate = function(s) - -- return s:len() > 0, "Cannot be an empty string" - -- end, - -- }, - -- logit_bias = { - -- order = 5, - -- mapping = "parameters", - -- type = "map", - -- optional = true, - -- default = nil, - -- desc = "Modify the likelihood of specified tokens appearing in the completion. Maps tokens (specified by their token ID) to an associated bias value from -100 to 100. Use https://platform.openai.com/tokenizer to find token IDs.", - -- subtype_key = { - -- type = "integer", - -- }, - -- subtype = { - -- type = "integer", - -- validate = function(n) - -- return n >= -100 and n <= 100, "Must be between -100 and 100" - -- end, - -- }, - -- }, - -- }, - }) - end, - } - }, - strategies = { - chat = { - adapter = "llamafile" - }, - inline = { - adapter = "llamafile" - }, - cmd = { - adapter = "llamafile" - }, - } - }) - - -- Set spelling errors in a purple hint - vim.opt.spell = true - vim.api.nvim_create_autocmd("LspAttach", { - callback = function() - vim.cmd("highlight SpellBad gui=underline guifg=#d3869b") - -- Highlight uncapitalised sentences - -- vim.cmd("highlight SpellCap gui=underline guifg=Blue") - end, - }) - - -- Per-Project Bindings ///////////////////////////////////////////////////////////////////////////// - -- Automatically load project file on buffer enter - vim.api.nvim_create_autocmd({"BufEnter"}, { - callback = function(ev) - local project_file = vim.fn.getcwd() .. '/project_nvim.lua' - if vim.fn.filereadable(project_file) == 1 then - vim.cmd('luafile ' .. vim.fn.fnameescape(project_file)) - end - end - }) - - -- Vim Options /////////////////////////////////////////////////////////////////////////////////// - vim.opt.autowrite=true -- Automatically save before cmds like :next and :prev - vim.opt.colorcolumn={80, 100} -- Set a 80 and 100 char column ruler - vim.opt.completeopt={'menu', 'menuone', 'noselect'} - vim.opt.cpoptions:append('$') -- $ as end marker for the change operator - vim.opt.cursorline=true -- Highlight current line - vim.opt.expandtab=true -- Replace tabs with spaces - vim.opt.guifont='JetBrains_Mono:h9','Consolas:h9','InputMonoCondensed:h9' - vim.opt.hlsearch=false -- Highlight just the first match on search - vim.opt.ignorecase=true -- Search is not case sensitive - vim.opt.linebreak=true -- On wrapped lines, break on the wrapping word intelligently - vim.opt.list=true -- Show the 'listchar' characters on trailing spaces, tabs e.t.c === - vim.opt.listchars:append('tab:>-,trail:■,extends:»,precedes:«') - vim.opt.number=true -- Show line numbers - vim.opt.relativenumber=true -- Show relative line numbers - vim.opt.shiftwidth=4 -- Number of spaces for each autoindent step - vim.opt.splitright=true -- Open new splits to the right of the current one - vim.opt.swapfile=false -- Disable swapfile (stores the things changed in a file) - vim.opt.textwidth=80 -- On format, format to 80 char long lines - vim.opt.visualbell=true -- Flash the screen on error - vim.opt.wrap=false -- Don't wrap lines of text automatically - vim.opt.signcolumn = 'no' - - vim.diagnostic.config({ - -- Turn off the diagnostics signs on the line number. In LSP mode, editing - -- a C++ buffer constantly toggles the sign column on and off as you change - -- modes which is very visually distracting. - signs = false, - virtual_text = true - }) - - -- Automatically scroll to bottom of quickfix window when opened - vim.cmd([[ - autocmd FileType qf lua vim.cmd('normal! G') - ]]) -EOF - -" Theme //////////////////////////////////////////////////////////////////////////////////////////// -let g:gruvbox_material_background='hard' -let g:gruvbox_material_foreground='mix' -let g:gruvbox_material_disable_italic_comment=1 -let g:gruvbox_material_enable_italic=0 -let g:gruvbox_material_enable_bold=0 -let g:gruvbox_material_diagnostic_virtual_text='colored' -let g:gruvbox_material_better_performance=1 -colorscheme gruvbox-material - -" Vim-cpp-modern customisation -" Disable function highlighting (affects both C and C++ files) -let g:cpp_function_highlight = 1 - -" Enable highlighting of C++11 attributes -let g:cpp_attributes_highlight = 1 - -" Highlight struct/class member variables (affects both C and C++ files) -let g:cpp_member_highlight = 0 - -" Put all standard C and C++ keywords under Vim's highlight group 'Statement' -" (affects both C and C++ files) -let g:cpp_simple_highlight = 1 - -" Options ////////////////////////////////////////////////////////////////////////////////////////// -" Show EOL type and last modified timestamp, right after the filename -set statusline=%<%F%h%m%r\ [%{&ff}]\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))})%=%l,%c%V\ %P - -" File patterns to ignore in command line auto complete -set wildignore+=*.class,*.o,*\\tmp\\*,*.swp,*.zip,*.exe,*.obj,*.vcxproj,*.pdb,*.idb - -" Setup undo file -set undofile -let &undodir=stdpath('config') . '/undo' - -" Setup backup directory -let &backupdir=stdpath('config') . '/backup' - -" Enable mouse support -if has('mouse') - set mouse=a -endif - -" Functions //////////////////////////////////////////////////////////////////////////////////////// -" Increase font size using (Ctrl+Up Arrow) or (Ctrl+Down Arrow) if we are using -" gvim Otherwise font size is determined in terminal -nnoremap :silent! let &guifont = substitute( - \ &guifont, - \ ':h\zs\d\+', - \ '\=eval(submatch(0)+1)', - \ 'g') -nnoremap :silent! let &guifont = substitute( - \ &guifont, - \ ':h\zs\d\+', - \ '\=eval(submatch(0)-1)', - \ 'g') - -" Formatting options (see :h fo-table) -augroup persistent_settings - au! - au bufenter * :set formatoptions=q1j -augroup end - -function! RADDbgOpenFile() - execute("!dev raddbg --ipc open " . substitute(expand("%:p"), '\\', '/', 'g')) - execute("!dev raddbg --ipc goto_line " . line(".")) - execute("!powershell -Command Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::AppActivate('The RAD Debugger')") -endfunction -command RADDbgOpenFile call RADDbgOpenFile() - -function! RADDbgStartDebugging() - execute("!dev raddbg --ipc run") -endfunction -command RADDbgStartDebugging call RADDbgStartDebugging() - -function! RADDbgStopDebugging() - execute("!dev raddbg --ipc kill_all") -endfunction -command RADDbgStopDebugging call RADDbgStopDebugging() - -function! RADDbgRunToCursor() - execute("!dev raddbg --ipc open " . substitute(expand("%:p"), '\\', '/', 'g')) - execute("!dev raddbg --ipc goto_line " . line(".")) - execute("!dev raddbg --ipc run_to_cursor " . substitute(expand("%:p"), '\\', '/', 'g') . ":" . line(".")) - execute("!powershell -Command Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::AppActivate('The RAD Debugger')") -endfunction -command RADDbgRunToCursor call RADDbgRunToCursor() - -function! RADDbgAddBreakpointAtFile() - execute("!dev raddbg --ipc open " . substitute(expand("%:p"), '\\', '/', 'g')) - execute("!dev raddbg --ipc goto_line " . line(".")) - execute("!dev raddbg --ipc toggle_breakpoint " . substitute(expand("%:p"), '\\', '/', 'g') . ":" . line(".")) - execute("!powershell -Command Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::AppActivate('The RAD Debugger')") -endfunction -command RADDbgAddBreakpointAtFile call RADDbgAddBreakpointAtFile() - -nnoremap RADDbgOpenFile -nnoremap RADDbgStartDebugging -nnoremap RADDbgStopDebugging -nnoremap RADDbgAddBreakpointAtFile -nnoremap RADDbgRunToCursor - -" General Key Bindings ///////////////////////////////////////////////////////////////////////////// -" FZF Bindings -nnoremap h FzfLua oldfiles -nnoremap f FzfLua files -nnoremap r FzfLua live_grep -nnoremap R FzfLua grep_cword -nnoremap t FzfLua lsp_live_workspace_symbols -nnoremap T FzfLua lsp_finder -nnoremap b FzfLua buffers -nnoremap c CodeCompanionChat toggle -nnoremap FzfLua - -" Map Ctrl+HJKL to navigate buffer window -nmap :wincmd h -nmap :wincmd j -nmap :wincmd k -nmap :wincmd l - -" Move by wrapped lines instead of line numbers -nnoremap j gj -nnoremap k gk -nnoremap gj j -nnoremap gk k - -" Map NERDTree to Ctrl-N -map :NERDTreeToggle - -" Change to current buffer's directory -nmap cd :cd =expand("%:p:h") - -" Buffer Splitting -nnoremap s :vs - -" Go to next error -" Go to previous error -nnoremap :cn -nnoremap :cp - -" In Neovim terminal, pressing should go back into normal mode. -" Without this, this doesn't happen and you stay stuck in insert mode. -tnoremap - -" Easy-Align /////////////////////////////////////////////////////////////////////////////////////// -let g:easy_align_delimiters = { -\ '>': { 'pattern': '>>\|=>\|>' }, -\ '/': { -\ 'pattern': '//\+\|/\*\|\*/', -\ 'delimiter_align': 'l', -\ 'ignore_groups': ['!Comment'] }, -\ ']': { -\ 'pattern': '[[\]]', -\ 'left_margin': 0, -\ 'right_margin': 0, -\ 'stick_to_left': 0 -\ }, -\ ')': { -\ 'pattern': '[)]', -\ 'left_margin': 0, -\ 'right_margin': 0, -\ 'stick_to_left': 0 -\ }, -\ '(': { -\ 'pattern': '[(]', -\ 'left_margin': 0, -\ 'right_margin': 0, -\ 'stick_to_left': 0 -\ }, -\ } - -" Enter live-interactive easy align mode when a visual selection is active -xmap a (LiveEasyAlign) diff --git a/install.py b/install.py index 9e62bdb..41e35f4 100644 --- a/install.py +++ b/install.py @@ -245,8 +245,11 @@ if is_windows: else: nvim_init_dir = pathlib.Path(os.path.expanduser("~")) / ".config" / "nvim" -nvim_config_dest_path = nvim_init_dir / "init.vim" -nvim_config_src_path = internal_dir / "os_nvim_init.vim" +nvim_config_dest_path = nvim_init_dir / "init.lua" +nvim_config_src_path = internal_dir / "os_nvim_init.lua" + +if os.path.exists(nvim_init_dir / "init.vim"): + pathlib.Path(nvim_init_dir / "init.vim").unlink() devenver.lprint(f"Installing NVIM config to {nvim_config_dest_path}") nvim_init_dir.mkdir(parents=True, exist_ok=True)