From bb35f98a3e2507b04e92abc82bff27d07dd0a74a Mon Sep 17 00:00:00 2001 From: george Date: Tue, 2 Jun 2026 15:03:10 +0100 Subject: [PATCH] strip down --- README.md | 191 ----------------------------------- init.vim | 70 +++++-------- lua/init.lua | 276 --------------------------------------------------- 3 files changed, 24 insertions(+), 513 deletions(-) delete mode 100644 README.md delete mode 100644 lua/init.lua diff --git a/README.md b/README.md deleted file mode 100644 index ad0e077..0000000 --- a/README.md +++ /dev/null @@ -1,191 +0,0 @@ -# Neovim Config - -This is a vim-plug based Neovim config with: - -- LSP via `nvim-lspconfig` -- Completion via `nvim-cmp` and LuaSnip -- Search via Telescope -- File browsing via Oil -- LaTeX workflow via VimTeX and TexLab -- Formatting via LSP, `latexindent`, and `neoformat` fallback - -## Main Files - -- `init.vim`: plugin list and Vimscript globals -- `lua/init.lua`: Lua setup, keymaps, completion, LSP, and plugin config - -## Plugin Manager - -This config uses `vim-plug`. - -Common commands: - -- `:PlugInstall` -- `:PlugUpdate` -- `:PlugClean` - -## Required External Software - -### LSP Servers - -These are the language servers configured in `lua/init.lua` and the binaries they expect to find on `PATH`. - -| LSP config | Expected binary or package | -| --- | --- | -| `ts_ls` | `typescript-language-server` and `typescript` | -| `clangd` | `clangd` | -| `gopls` | `gopls` | -| `pyright` | `pyright` | -| `texlab` | `texlab` | -| `rust_analyzer` | `rust-analyzer` | -| `kotlin-language-server` | `kotlin-language-server` | -| `cmake` | `cmake-language-server` | -| `html` | `vscode-html-language-server` from `vscode-langservers-extracted` | -| `glsl_analyzer` | `glsl_analyzer` | -| `lua_ls` | `lua-language-server` | -| `zls` | `zls` | - -### LaTeX Toolchain - -These are used by the current LaTeX setup. - -| Tool | Purpose | -| --- | --- | -| `pdflatex` | TeX engine | -| `latexmk` | Project-aware TeX build runner | -| `latexindent` | TeX formatter | -| `texlab` | LaTeX LSP | -| `zathura` | Optional PDF viewer with SyncTeX support | -| `xdg-open` | Generic PDF opener fallback | - -### Other Useful Runtime Tools - -| Tool | Purpose | -| --- | --- | -| `cargo` | Used here to install `texlab` | -| `git` | Required by vim-plug and Telescope git search | - -## Leaders - -- `Leader` = `` -- `LocalLeader` = `,` - -## Key Shortcuts - -## Search And Buffers - -| Mode | Shortcut | Action | -| --- | --- | --- | -| Normal | `` | Search tracked git files | -| Normal | `` | Search all files | -| Normal | `f` | Grep the project | -| Normal | `/` | Fuzzy search the current buffer | -| Normal | `fh` | Search help tags | -| Normal | `fr` | Open recent files | -| Normal | `fu` | Open undo history in Telescope | -| Normal | `` | Switch buffers | - -## File Browsing - -| Mode | Shortcut | Action | -| --- | --- | --- | -| Normal | `-` | Open parent directory in Oil | -| Normal | `e` | Open Oil file explorer | -| Normal | `E` | Open the current file's directory in Oil | - -## LSP And Diagnostics - -| Mode | Shortcut | Action | -| --- | --- | --- | -| Normal | `gd` | Go to definition | -| Normal | `gr` | List references | -| Normal | `gi` | List implementations | -| Normal | `K` | Show hover documentation | -| Normal | `L` | Show diagnostics in a float | -| Normal, Visual | `ca` | Run a code action | -| Normal | `rn` | Rename symbol | -| Normal | `[d` | Jump to previous diagnostic | -| Normal | `]d` | Jump to next diagnostic | -| Normal | `q` | Send diagnostics to the location list | -| Normal | `fm` | Format the current buffer | - -## LaTeX Workflow - -| Mode | Shortcut | Action | -| --- | --- | --- | -| Normal | `tc` | Compile TeX document | -| Normal | `tk` | Stop TeX compilation | -| Normal | `tv` | Open or refresh TeX PDF viewer | -| Normal | `to` | Show TeX compiler output | -| Normal | `tt` | Toggle TeX table of contents | -| Normal | `te` | Show TeX errors | -| Normal | `tl` | Clean TeX build files | - -## Editing And Movement - -| Mode | Shortcut | Action | -| --- | --- | --- | -| Normal, Visual | `y` | Yank to system clipboard | -| Normal | `u` | Toggle Undotree | -| Normal, Visual, Operator-pending | `s` | Jump with Flash | -| Normal, Visual, Operator-pending | `S` | Jump to Tree-sitter targets with Flash | - -## Completion - -### Insert Mode - -| Shortcut | Action | -| --- | --- | -| `` | Scroll completion documentation up | -| `` | Scroll completion documentation down | -| `` | Open completion menu | -| `` | Abort completion | -| `` | Confirm selected completion item | - -### Command Line And Search - -| Mode | Shortcut | Action | -| --- | --- | --- | -| `/` command line | `` and completion menu | Complete from current buffer | -| `:` command line | `` and completion menu | Complete paths and commands | - -## Plugin Defaults Still Enabled - -### Comment.nvim - -| Mode | Shortcut | Action | -| --- | --- | --- | -| Normal | `gcc` | Toggle comment on current line | -| Visual | `gc` | Toggle comment on selection | -| Operator-pending | `gc{motion}` | Toggle comment over a motion | - -### vim-surround - -| Mode | Shortcut | Action | -| --- | --- | --- | -| Normal | `ys{motion}{char}` | Add surrounding characters | -| Normal | `yss{char}` | Surround current line | -| Normal | `cs{old}{new}` | Change surrounding characters | -| Normal | `ds{char}` | Delete surrounding characters | -| Visual | `S{char}` | Surround the selection | - -### VimTeX Common Defaults - -| Mode | Shortcut | Action | -| --- | --- | --- | -| Normal | `ll` | Start or toggle VimTeX compilation | -| Normal | `lk` | Stop VimTeX compilation | -| Normal | `lc` | Clean auxiliary files | -| Normal | `lv` | Open or forward-search the PDF | -| Normal | `lo` | Open compiler output | -| Normal | `lt` | Open VimTeX table of contents | -| Normal | `[[` / `]]` | Move between section boundaries | -| Normal | `[m` / `]m` | Move between environment boundaries | -| Visual, Operator-pending | `ie` / `ae` | Select inside or around a LaTeX environment | -| Visual, Operator-pending | `i$` / `a$` | Select inside or around math | - -## Notes - -- TeX formatting uses `latexindent` when editing `*.tex` files. -- The generic format key is still `fm`; it switches to `latexindent` automatically for TeX buffers. -- `vimtex` provides many more text objects, motions, and local mappings than listed here. Use `:help vimtex-default-mappings` and `:help vimtex` for the full set. \ No newline at end of file diff --git a/init.vim b/init.vim index 7cdebfc..396098a 100644 --- a/init.vim +++ b/init.vim @@ -26,55 +26,33 @@ set list call plug#begin("~/.nvim/plugged") -Plug 'rust-lang/rust.vim' " Rust filetype support -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Tree-sitter highlighting -Plug 'neovim/nvim-lspconfig' " LSP client configs -Plug 'mbbill/undotree' " Undo history browser -Plug 'sbdchd/neoformat' " Formatter fallback -Plug 'folke/tokyonight.nvim', { 'branch': 'main' } " Active colour scheme -Plug 'nvim-lua/plenary.nvim' " Lua utility library -Plug 'nvim-telescope/telescope.nvim' " Fuzzy finder UI -Plug 'nvim-telescope/telescope-fzy-native.nvim' " Telescope sorter -Plug 'nvim-telescope/telescope-ui-select.nvim' " Telescope vim.ui.select bridge -Plug 'debugloop/telescope-undo.nvim' " Undo history picker -Plug 'psliwka/vim-smoothie' " Smooth scrolling -Plug 'darrikonn/vim-gofmt', { 'do': ':GoUpdateBinaries' } " Go formatting helpers -Plug 'stevearc/oil.nvim' " Primary file explorer -Plug 'nvim-tree/nvim-web-devicons' " Filetype icons -Plug 'udalov/kotlin-vim' " Kotlin syntax support -Plug 'hrsh7th/cmp-nvim-lsp' " LSP completion source -Plug 'hrsh7th/cmp-buffer' " Buffer completion source -Plug 'hrsh7th/cmp-path' " Path completion source -Plug 'hrsh7th/cmp-cmdline' " Command-line completion source -Plug 'hrsh7th/nvim-cmp' " Completion engine -Plug 'L3MON4D3/LuaSnip' " Snippet engine -Plug 'rafamadriz/friendly-snippets' " Community snippet pack -Plug 'lervag/vimtex' " LaTeX workflow plugin -Plug 'windwp/nvim-autopairs' " Auto-close brackets and quotes -Plug 'numToStr/Comment.nvim' " Comment toggles -Plug 'tpope/vim-surround' " Surround text objects -Plug 'itchyny/lightline.vim' " Statusline -Plug 'tpope/vim-fugitive' " Git commands -Plug 'simrat39/rust-tools.nvim' " Extra Rust tooling - -let maplocalleader = "," -let g:tex_flavor = 'latex' -let g:vimtex_compiler_method = 'latexmk' -let g:vimtex_quickfix_method = 'latexlog' - -if executable('zathura') - let g:vimtex_view_method = 'zathura' -elseif executable('xdg-open') - let g:vimtex_view_method = 'general' - let g:vimtex_view_general_viewer = 'xdg-open' - let g:vimtex_view_general_options = '@pdf' -endif +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Treesitter highlighting +Plug 'folke/tokyonight.nvim', {'branch': 'main' } " Active colour scheme +Plug 'stevearc/oil.nvim' +Plug 'akinsho/toggleterm.nvim' +Plug 'ibhagwan/fzf-lua' call plug#end() -colorscheme tokyonight -syntax off +packadd matchit let mapleader = " " -lua require("init") +lua require('treesitter') +lua require('man-config') +lua require('fzf-config') +lua require('oil-config') +lua require('toggleterm').setup({ direction = "horizontal", size = 15 }) + +command! Cheats edit ~/.config/nvim/cheats.md + +nnoremap h :nohlsearch + +nnoremap lua require('toggleterm').toggle(1, 15, vim.fn.expand('%:p:h'), 'horizontal') +tnoremap lua require('toggleterm').toggle(1, 15, vim.fn.expand('%:p:h'), 'horizontal') + +nnoremap y "+y +vnoremap y "+y +nnoremap p "+p + +colorscheme tokyonight-night diff --git a/lua/init.lua b/lua/init.lua deleted file mode 100644 index 85f6c33..0000000 --- a/lua/init.lua +++ /dev/null @@ -1,276 +0,0 @@ -local cmp = require("cmp") -local luasnip = require("luasnip") -local cmp_nvim_lsp = require("cmp_nvim_lsp") -local telescope = require("telescope") -local builtin = require("telescope.builtin") -local themes = require("telescope.themes") -local map = vim.keymap.set - -local ok_autopairs, autopairs = pcall(require, "nvim-autopairs") -local ok_cmp_autopairs, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp") -local ok_comment, comment = pcall(require, "Comment") -local ok_flash, flash = pcall(require, "flash") -local ok_oil, oil = pcall(require, "oil") - -vim.opt.completeopt = { "menu", "menuone", "noselect" } - -vim.filetype.add({ - extension = { - jai = "jai", - }, -}) - -local function format_tex_buffer() - local result = vim.system({ "latexindent" }, { - stdin = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n") .. "\n", - text = true, - }):wait() - - if result.code ~= 0 then - vim.notify(result.stderr ~= "" and result.stderr or "latexindent failed", vim.log.levels.ERROR) - return - end - - local formatted = vim.split(result.stdout or "", "\n", { plain = true, trimempty = false }) - if formatted[#formatted] == "" then - table.remove(formatted, #formatted) - end - - local view = vim.fn.winsaveview() - vim.api.nvim_buf_set_lines(0, 0, -1, false, formatted) - vim.fn.winrestview(view) -end - -local function format_buffer() - if vim.bo.filetype == "tex" and vim.fn.executable("latexindent") == 1 then - format_tex_buffer() - return - end - - vim.lsp.buf.format({ async = true }) -end - -luasnip.config.setup({}) -require("luasnip.loaders.from_vscode").lazy_load() - -if ok_autopairs then - autopairs.setup({}) -end - -if ok_comment then - comment.setup() -end - -if ok_flash then - flash.setup() -end - -if ok_oil then - oil.setup({ - default_file_explorer = true, - skip_confirm_for_simple_edits = true, - view_options = { - show_hidden = true, - }, - }) -end - -telescope.setup({ - extensions = { - ["ui-select"] = themes.get_dropdown({}), - undo = { - layout_strategy = "vertical", - layout_config = { - preview_height = 0.6, - }, - side_by_side = true, - }, - }, -}) - -pcall(telescope.load_extension, "ui-select") -pcall(telescope.load_extension, "undo") - --- Completion shortcuts. -local cmp_insert_mappings = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), -- Accept the selected completion. -}) - -local cmp_cmdline_mappings = cmp.mapping.preset.cmdline() - --- Search and buffers. -map("n", "", builtin.git_files, { desc = "Search tracked files", silent = true }) -map("n", "", builtin.find_files, { desc = "Search all files", silent = true }) -map("n", "f", builtin.live_grep, { desc = "Grep project", silent = true }) -map("n", "/", function() - builtin.current_buffer_fuzzy_find(themes.get_dropdown({ previewer = false, winblend = 10 })) -end, { desc = "Search current buffer", silent = true }) -map("n", "fh", builtin.help_tags, { desc = "Search help", silent = true }) -map("n", "fr", builtin.oldfiles, { desc = "Recent files", silent = true }) -map("n", "fu", "Telescope undo", { desc = "Undo history", silent = true }) -map("n", "", builtin.buffers, { desc = "Switch buffers", silent = true }) - --- File browsing. -map("n", "-", "Oil", { desc = "Open parent directory", silent = true }) -map("n", "e", "Oil", { desc = "Open file explorer", silent = true }) -map("n", "E", function() - require("oil").open(vim.fn.expand("%:p:h")) -end, { desc = "Open current file directory", silent = true }) - --- LSP and diagnostics. -map("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition", silent = true }) -map("n", "gr", builtin.lsp_references, { desc = "List references", silent = true }) -map("n", "gi", builtin.lsp_implementations, { desc = "List implementations", silent = true }) -map("n", "K", vim.lsp.buf.hover, { desc = "Hover docs", silent = true }) -map("n", "L", vim.diagnostic.open_float, { desc = "Show diagnostics", silent = true }) -map({ "n", "v" }, "ca", vim.lsp.buf.code_action, { desc = "Code action", silent = true }) -map("n", "rn", vim.lsp.buf.rename, { desc = "Rename symbol", silent = true }) -map("n", "[d", function() - vim.diagnostic.jump({ count = -1, float = true }) -end, { desc = "Previous diagnostic", silent = true }) -map("n", "]d", function() - vim.diagnostic.jump({ count = 1, float = true }) -end, { desc = "Next diagnostic", silent = true }) -map("n", "q", vim.diagnostic.setloclist, { desc = "Diagnostics list", silent = true }) -map("n", "fm", format_buffer, { desc = "Format buffer", silent = true }) - --- LaTeX workflow. -map("n", "tc", "VimtexCompile", { desc = "Compile TeX", silent = true }) -map("n", "tk", "VimtexStop", { desc = "Stop TeX compile", silent = true }) -map("n", "tv", "VimtexView", { desc = "Open TeX PDF", silent = true }) -map("n", "to", "VimtexCompileOutput", { desc = "TeX compiler output", silent = true }) -map("n", "tt", "VimtexTocToggle", { desc = "TeX table of contents", silent = true }) -map("n", "te", "VimtexErrors", { desc = "TeX errors", silent = true }) -map("n", "tl", "VimtexClean", { desc = "Clean TeX build files", silent = true }) - --- Editing and utility shortcuts. -map({ "n", "v" }, "y", '"+y', { desc = "Yank to clipboard", silent = true }) -map("n", "u", "UndotreeToggle", { desc = "Toggle undo tree", silent = true }) - -cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp_insert_mappings, - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - }, { - { name = "buffer" }, - }), -}) - -cmp.setup.cmdline("/", { - mapping = cmp_cmdline_mappings, - sources = { - { name = "buffer" }, - }, -}) - -cmp.setup.cmdline(":", { - mapping = cmp_cmdline_mappings, - sources = cmp.config.sources({ - { name = "path" }, - }, { - { name = "cmdline" }, - }), -}) - -if ok_cmp_autopairs then - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) -end - -vim.diagnostic.config({ - virtual_text = true, - signs = true, - underline = true, - update_in_insert = true, -}) - -local capabilities = cmp_nvim_lsp.default_capabilities() -local servers = { - ts_ls = {}, - clangd = {}, - gopls = { - cmd = { "gopls", "serve" }, - settings = { - gopls = { - analyses = { - unusedparams = true, - }, - staticcheck = true, - }, - }, - }, - pyright = {}, - texlab = { - settings = { - texlab = { - build = { - executable = "latexmk", - args = { - "-pdf", - "-interaction=nonstopmode", - "-synctex=1", - "-file-line-error", - "%f", - }, - onSave = true, - forwardSearchAfter = false, - }, - chktex = { - onOpenAndSave = false, - onEdit = false, - }, - }, - }, - }, - rust_analyzer = { - cmd = { "rust-analyzer" }, - settings = { - ["rust-analyzer"] = { - checkOnSave = { - allFeatures = true, - overrideCommand = { - "cargo", - "clippy", - "--workspace", - "--message-format=json", - "--all-targets", - "--all-features", - }, - }, - }, - }, - }, - ["kotlin-language-server"] = { - cmd = { "kotlin-language-server" }, - filetypes = { "kotlin" }, - }, - cmake = {}, - html = {}, - glsl_analyzer = {}, - lua_ls = {}, - zls = {}, -} - -for server, config in pairs(servers) do - config.capabilities = capabilities - vim.lsp.config(server, config) - vim.lsp.enable(server) -end - -vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("UserTreesitterHighlight", { clear = true }), - callback = function(args) - pcall(vim.treesitter.start, args.buf) - end, - desc = "Start Tree-sitter highlighting when a parser is available", -})