From 19bded245ee0685120ea3d2095c0abcdf5c22692 Mon Sep 17 00:00:00 2001 From: Ian Griffin Date: Tue, 25 Mar 2025 23:13:50 +0800 Subject: [PATCH] migrated to lazy.nvim, cleanup and fixes --- README.md | 2 +- init.lua | 39 +++---- lazy-lock.json | 26 +++++ lua/defs.lua | 6 +- lua/ide.lua | 249 ---------------------------------------- lua/lazy_conf.lua | 14 +++ lua/misc.lua | 19 --- lua/plugins/10_ide.lua | 234 +++++++++++++++++++++++++++++++++++++ lua/plugins/50_ui.lua | 53 +++++++++ lua/plugins/90_misc.lua | 19 +++ lua/ui.lua | 76 ------------ 11 files changed, 366 insertions(+), 371 deletions(-) create mode 100644 lazy-lock.json delete mode 100644 lua/ide.lua create mode 100644 lua/lazy_conf.lua create mode 100644 lua/plugins/10_ide.lua create mode 100644 lua/plugins/50_ui.lua create mode 100644 lua/plugins/90_misc.lua diff --git a/README.md b/README.md index 5a3b001..627a9e7 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Some plugins require python extensions for neovim 1. Download/Clone this git repo to ```$HOME/.config/nvim``` ```sh mkdir -p $HOME/.config -git clone "https://gitlab.com/telosama/neovim-config.git" $HOME/.config/nvim +git clone "https://git.telosama.xyz/iang/neovim-config.git" $HOME/.config/nvim ``` 3. Start Neovim , then do this command: ``` diff --git a/init.lua b/init.lua index 228df9d..30db368 100644 --- a/init.lua +++ b/init.lua @@ -5,30 +5,23 @@ ---------------------------------------- -- --- Packer, a use-package like package manager +-- bootstrap lazy.nvim, declarative package manager for neovim -- - --- Bootstrap -local fn = vim.fn -local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' -if fn.empty(fn.glob(install_path)) > 0 then - Packer_bootstrap = fn.system({ - 'git', 'clone', '--depth', '1', - 'https://github.com/wbthomason/packer.nvim', - install_path - }) -end - -local packer = require 'packer' -packer.reset() -packer.init() -local pk_use = packer.use - -pk_use 'wbthomason/packer.nvim' - -if Packer_bootstrap then - packer.sync() +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) -- Leader key vim.g.mapleader = ' ' @@ -37,7 +30,7 @@ vim.g.maplocalleader = ' ' -- -- Load other files -- -require 'ide' -- Tree Sitter Settings +require 'lazy_conf' require 'ui' -- User Interface require 'defs' -- Default files/folders require 'binds' -- Keybindings and commands diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..64ffb18 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,26 @@ +{ + "aerial.nvim": { "branch": "master", "commit": "9ebc13583cff447f5493a63e99dfca526b3c3088" }, + "closetag.vim": { "branch": "master", "commit": "d0a562f8bdb107a50595aefe53b1a690460c3822" }, + "coq.artifacts": { "branch": "artifacts", "commit": "ef5f21d638ccc456cfa5b8d0ab37093cefe48c8b" }, + "coq_nvim": { "branch": "coq", "commit": "d83bc18d044cfcd65e91dc49740a353546bc143b" }, + "delimitMate": { "branch": "master", "commit": "becbd2d353a2366171852387288ebb4b33a02487" }, + "goyo.vim": { "branch": "master", "commit": "fa0263d456dd43f5926484d1c4c7022dfcb21ba9" }, + "hererocks": { "branch": "master", "commit": "c9c5444dea1e07e005484014a8231aa667be30b6" }, + "kotlin-vim": { "branch": "master", "commit": "53fe045906df8eeb07cb77b078fc93acda6c90b8" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, + "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, + "nvim-lsp-basics": { "branch": "main", "commit": "632714bd3ab355eb6e725b5a78cd8730f12d14d2" }, + "nvim-lspconfig": { "branch": "master", "commit": "200280dab91a7df2ca42fd2ab3cb4c5fab056666" }, + "nvim-treesitter": { "branch": "master", "commit": "e329e94a6a0a5ccf6ec8bfec1d10faf5eaae665f" }, + "onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "de39919a57e1a40a4c7dc5bae0de276f9c616ef3" }, + "rest.nvim": { "branch": "main", "commit": "2ded89dbda1fd3c1430685ffadf2df8beb28336d" }, + "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, + "uxntal.vim": { "branch": "main", "commit": "2ba479268252510cc7741c0cf67051feb0e82203" }, + "vim-css-color": { "branch": "master", "commit": "14fd934cdd9ca1ac0e53511094e612eb9bace373" }, + "vim-indent-guides": { "branch": "master", "commit": "a1e1390c0136e63e813d051de2003bf0ee18ae30" }, + "vim-visual-multi": { "branch": "master", "commit": "a6975e7c1ee157615bbc80fc25e4392f71c344d4" } +} diff --git a/lua/defs.lua b/lua/defs.lua index 11c5c3e..cf02255 100644 --- a/lua/defs.lua +++ b/lua/defs.lua @@ -1,7 +1,7 @@ return { template_dir = '~/templates', - external_term = 'kgx', - external_filemgr = 'nautilus', - external_pdfviewer = 'evince', + external_term = 'xfce4-terminal', + external_filemgr = 'thunar', + external_pdfviewer = 'atril', lsp_path = vim.env.HOME .. '/.local/share/lsp_servers' } diff --git a/lua/ide.lua b/lua/ide.lua deleted file mode 100644 index 4a1d252..0000000 --- a/lua/ide.lua +++ /dev/null @@ -1,249 +0,0 @@ --- --- IDE-like features --- - --- Load required tools -local pk_use = require 'packer'.use - --- --- Tree Sitter --- -pk_use { - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate', - config = function() - require('nvim-treesitter.configs').setup { - ensure_installed = { - "bash", - "bibtex", - "c", - "cpp", - "css", - "go", - "html", - "http", - "javascript", - "json", - "latex", - "lua", - "python", - "typescript", - "tsx", - "vim", - }, - sync_install = false, - highlight = { - enable = true, - } - } - end -} - --- --- Autocompletion --- -pk_use { - 'ms-jpq/coq_nvim', - branch = 'coq', - config = function() - vim.cmd([[autocmd VimEnter * COQnow -s]]) - end -} - -pk_use { - 'ms-jpq/coq.artifacts', - branch = 'artifacts' -} - --- --- Language Configurations --- -pk_use 'ap/vim-css-color' --- close tags in html languages -pk_use { - 'alvan/closetag.vim', - ft = { "html", "vue", "typescriptreact" } -} - --- pk_use { --- 'fatih/vim-go', --- ft = 'go' --- } - -pk_use { - 'udalov/kotlin-vim', - ft = 'kotlin' -} - -pk_use 'bellinitte/uxntal.vim' - --- --- Language Server --- - --- Basic commands -pk_use 'nanotee/nvim-lsp-basics' - --- Show Code Outline/Symbols tree window -pk_use { - 'stevearc/aerial.nvim', - config = function() - require('conftool').map('n', 'e', ':AerialToggle') - require('aerial').setup({ - backends = { 'lsp', 'markdown', 'man' }, - layout = { - min_width = 25 - } - }) - end -} - --- Language Server Installer -pk_use { - 'williamboman/mason.nvim', - config = function() - require('mason').setup { - ui = { - icons = { - package_installed = "i", - package_pending = "p", - package_uninstalled = "u" - } - } - } - end -} -pk_use { - 'williamboman/mason-lspconfig.nvim', - requires = { - 'neovim/nvim-lspconfig', - 'williamboman/mason.nvim', - 'ms-jpq/coq_nvim', - 'stevearc/aerial.nvim' - }, - config = function() - local masonlsp = require 'mason-lspconfig' - --[[ - masonlsp.setup { - ensure_installed = { - "bashls", - "clangd", - "html", - "jsonls", - "lua_ls", - "pyright", - "texlab", - "tsserver" - }, - } - --]] - masonlsp.setup_handlers { - function(server_name) - require('lspconfig')[server_name].setup(require('coq').lsp_ensure_capabilities { - on_attach = function(client, bufnr) - local basics = require('lsp_basics') - basics.make_lsp_commands(client, bufnr) - basics.make_lsp_mappings(client, bufnr) - end - }) - end - } - end -} - -pk_use { - 'neovim/nvim-lspconfig', - config = function() - -- disable inline error messages - vim.diagnostic.config({ virtual_text = false }) - end -} - --- Show code diagnostics in a separate buffer window -pk_use { - 'folke/trouble.nvim', - config = function() - require('trouble').setup { - height = 6, - icons = false, - fold_open = "v", - fold_closed = ">", - signs = { - error = "E:", - warning = "W:", - hint = "H:", - information = "I:" - }, - use_diagnostic_signs = false - } - - require('conftool').map('n', 't', ':TroubleToggle') - end -} - ---[[ --- Latex Live Preview --- -pk_use { - 'xuhdev/vim-latex-live-preview', - ft = 'tex', - setup = function() - vim.g.livepreview_previewer = require('defs').external_pdfviewer - vim.g.livepreview_engine = "xelatex" - end -}]] - --- --- Markdown Live Preview --- -pk_use { - "iamcco/markdown-preview.nvim", - ft = 'markdown', - run = function() - vim.fn["mkdp#util#install"]() - end, - config = function() - vim.g.mkdp_theme = 'light' - end -} - --- Debugger Adapter Protocol ---[[ -pk_use { - 'mfussenegger/nvim-dap', - config = function() - local dap = require('dap') - - end -} ---]] - --- --- Misc --- -pk_use { - "rest-nvim/rest.nvim", - requires = { "nvim-lua/plenary.nvim" }, - config = function() - - -- commands - local ct = require('conftool') - ct.defcmd('RestNvim', 'lua require(\'rest-nvim\').run()') - ct.defcmd('RestNvimPreview', 'lua require(\'rest-nvim\').run(true)') - ct.defcmd('RestNvimLast', 'lua require(\'rest-nvim\').last()') - - ct.map('n', 'r', 'RestNvim') - ct.map('n', 'R', 'RestNvimLast') - ct.map('n', '', 'RestNvimPreview') - - require("rest-nvim").setup({ - -- Open request results in a horizontal split - result_split_horizontal = true, - -- Keep the http file buffer above|left when split horizontal|vertical - result_split_in_place = true, - result = { - show_curl_command = false, - } - }) - end -} diff --git a/lua/lazy_conf.lua b/lua/lazy_conf.lua new file mode 100644 index 0000000..5398756 --- /dev/null +++ b/lua/lazy_conf.lua @@ -0,0 +1,14 @@ +require("lazy").setup({ + defaults = { + lazy = true, + }, + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "onedark" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/misc.lua b/lua/misc.lua index abe5d07..1fe2c30 100644 --- a/lua/misc.lua +++ b/lua/misc.lua @@ -1,5 +1,4 @@ local ct = require('conftool') -local pk_use = require('packer').use -- -- Encoding @@ -29,23 +28,6 @@ ct.augroup('AutoSaveFolds', { -- ct.set({'spelllang', {'en', 'cjk', 'id'}}) ct.set({'spellsuggest', {'best', 5}}) - --- --- Focus Mode --- -pk_use { - 'junegunn/goyo.vim', - cmd = 'Goyo' -} - --- --- Multi-cursor --- -pk_use { - 'mg979/vim-visual-multi', - keys = {"", ""} -} - -- -- Netrw built-in file manager -- @@ -66,4 +48,3 @@ vim.cmd('autocmd BufEnter * silent! lcd %:p:h') -- highlighting for other langs in markdown docs vim.g.markdown_fenced_languages = {'html', 'vim', 'python', 'c', 'bash=sh'} -- auto close delimiters (eg. parentheses, brackets) -pk_use 'Raimondi/delimitMate' diff --git a/lua/plugins/10_ide.lua b/lua/plugins/10_ide.lua new file mode 100644 index 0000000..73ae12f --- /dev/null +++ b/lua/plugins/10_ide.lua @@ -0,0 +1,234 @@ +return { + { + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + event = { "VeryLazy" }, + lazy = vim.fn.argc(-1) == 0, + opts = { + ensure_installed = { + "bash", + "bibtex", + "c", + "cpp", + "css", + "go", + "html", + "http", + "javascript", + "json", + "latex", + "lua", + "python", + "typescript", + "tsx", + "vim", + }, + sync_install = false, + highlight = { + enable = true, + }, + }, + }, + + -- + -- Autocompletion + -- + { + 'ms-jpq/coq.artifacts', + branch = 'artifacts' + }, + { + 'ms-jpq/coq_nvim', + dependencies = { 'ms-jpq/coq.artifacts' }, + branch = 'coq', + build = ':COQdeps', + config = function() + vim.cmd([[autocmd VimEnter * COQnow -s]]) + end + }, + + -- + -- Language Configurations + -- + { 'ap/vim-css-color', lazy = false }, + -- close tags in html languages + { + 'alvan/closetag.vim', + ft = { "html", "vue", "typescriptreact" }, + }, + + { + 'udalov/kotlin-vim', + ft = 'kotlin' + }, + + { 'bellinitte/uxntal.vim', lazy = false }, + + -- + -- Language Server + -- + + -- Show Code Outline/Symbols tree window + { + 'stevearc/aerial.nvim', + opts = { + backends = { 'lsp', 'markdown', 'man' }, + layout = { + min_width = 25 + }, + }, + keys = { + {'e', ':AerialToggle'}, + } + }, + + -- Language Server Installer + { + 'williamboman/mason.nvim', + cmd = { + "Mason", + "MasonInstall", + "MasonUpdate", + + }, + opts = { + ui = { + icons = { + package_installed = "i", + package_pending = "p", + package_uninstalled = "u" + }, + }, + }, + }, + { + 'neovim/nvim-lspconfig', + config = function() + -- disable inline error messages + vim.diagnostic.config({ virtual_text = false }) + end + }, + { + 'williamboman/mason-lspconfig.nvim', + dependencies = { + 'ms-jpq/coq_nvim', + 'nanotee/nvim-lsp-basics', + 'neovim/nvim-lspconfig', + 'stevearc/aerial.nvim', + 'williamboman/mason.nvim', + }, + opts = { + ensure_installed = { + "bashls", + "clangd", + "ast_grep", + "gopls", + "html", + "jsonls", + "lua_ls", + "pyright", + "texlab", + "tsserver" + }, + }, + ft = { + "bash", + "c", + "cpp", + "dart", + "go", + "html", + "javascript", + "javascriptreact", + "json", + "lua", + "python", + "tex", + "typescript", + "typescriptreact", + }, + config = function() + local masonlsp = require 'mason-lspconfig' + --[[ + masonlsp.setup + --]] + masonlsp.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup(require('coq').lsp_ensure_capabilities { + on_attach = function(client, bufnr) + local basics = require('lsp_basics') + basics.make_lsp_commands(client, bufnr) + basics.make_lsp_mappings(client, bufnr) + end + }) + end + } + end + }, + + -- Show code diagnostics in a separate buffer window + { + 'folke/trouble.nvim', + opts = { + height = 6, + icons = false, + fold_open = "v", + fold_closed = ">", + signs = { + error = "E:", + warning = "W:", + hint = "H:", + information = "I:" + }, + use_diagnostic_signs = false + }, + + cmd = { + "TroubleToggle", + }, + + keys = { + {'t', ':TroubleToggle'}, + } + }, + -- + -- Markdown Live Preview + -- + { + "iamcco/markdown-preview.nvim", + ft = 'markdown', + config = function() + vim.fn["mkdp#util#install"]() + vim.g.mkdp_theme = 'light' + end + }, + + -- + -- Misc + -- + { + "rest-nvim/rest.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { + -- Open request results in a horizontal split + result_split_horizontal = true, + -- Keep the http file buffer above|left when split horizontal|vertical + result_split_in_place = true, + result = { + show_curl_command = false, + }, + }, + keys = { + {'r', 'RestNvim'}, + {'R', 'RestNvimLast'}, + {'', 'RestNvimPreview'}, + }, + config = function() + -- commands + local ct = require('conftool') + ct.defcmd('RestNvim', 'lua require(\'rest-nvim\').run()') + ct.defcmd('RestNvimPreview', 'lua require(\'rest-nvim\').run(true)') + ct.defcmd('RestNvimLast', 'lua require(\'rest-nvim\').last()') + end, + }, +} diff --git a/lua/plugins/50_ui.lua b/lua/plugins/50_ui.lua new file mode 100644 index 0000000..1382bf1 --- /dev/null +++ b/lua/plugins/50_ui.lua @@ -0,0 +1,53 @@ +return { + -- + -- Theme + -- + { + 'navarasu/onedark.nvim', + lazy = false, + config = function() + local ct = require('conftool') + ct.set({'background', 'light'}) + vim.cmd [[colo onedark]] + end, + keys = { + { + 'c', + function() + if vim.o.background == 'light' then + vim.o.background = 'dark' + else + vim.o.background = 'light' + -- vim.api.nvim_set_hl(0, 'ColorColumn', {bg = '#c0bfbc'}) + vim.cmd('redraw') + vim.cmd('redraw') + end + end, + desc = 'toggle color themes' + }, + }, + + }, + + -- + -- Indentation + -- + { + 'nathanaelkane/vim-indent-guides', + lazy = false, + setup = function() + vim.g.indent_guides_guide_size = 1 + vim.g.indent_guides_tab_guides = 0 + vim.g.indent_guides_start_level = 2 + vim.g.indent_guides_enable_on_vim_startup = 1 + end + }, + -- + -- Delimiters + -- + { + 'hiphish/rainbow-delimiters.nvim', + lazy = false, + } + +} diff --git a/lua/plugins/90_misc.lua b/lua/plugins/90_misc.lua new file mode 100644 index 0000000..41acb67 --- /dev/null +++ b/lua/plugins/90_misc.lua @@ -0,0 +1,19 @@ +return { + -- + -- Focus Mode + -- + { + 'junegunn/goyo.vim', + cmd = 'Goyo' + }, + + -- + -- Multi-cursor + -- + { + 'mg979/vim-visual-multi', + lazy = false + }, + { 'Raimondi/delimitMate', lazy = false } +} + diff --git a/lua/ui.lua b/lua/ui.lua index c9c0bfb..f856e00 100644 --- a/lua/ui.lua +++ b/lua/ui.lua @@ -1,67 +1,5 @@ -local pk_use = require 'packer'.use local ct = require 'conftool' --- --- Theme --- - -pk_use { - 'Mofiqul/adwaita.nvim', - config = function() - local ct = require('conftool') - ct.set({'background', 'dark'}) - -- vim.g.adwaita_darker = true - vim.cmd [[colo adwaita]] - vim.keymap.set( - 'n', - 'c', - function() - if vim.o.background == 'light' then - vim.o.background = 'dark' - else - vim.o.background = 'light' - vim.api.nvim_set_hl(0, 'ColorColumn', {bg = '#c0bfbc'}) - vim.cmd('redraw') - vim.cmd('redraw') - end - end, - {noremap = true} - ) - - end -} - - --- --- Buffer Bar --- ---[[ -pk_use { - 'romgrk/barbar.nvim', - config = function() - require('bufferline').setup { - animation = false, - auto_hide = true, - icons = { - filetype = { - custom_colors = false, - enabled = false - }, - inactive = {left = ' '}, - modified = {button = '*'}, - -- separator = {left = '|'}, - pinned = {button = '!'}, - button = 'X' - }, - sidebar_filetypes = { - aerial = true, - netrw = true - } - } - end -} ---]] - -- -- Indentation -- @@ -74,15 +12,6 @@ ct.set({'tabstop', 5}, {'shiftwidth', 5}) -- vim.opt.list = true --vim.cmd([[set lcs=tab:\|\ ]]) -pk_use { - 'nathanaelkane/vim-indent-guides', - setup = function() - vim.g.indent_guides_guide_size = 1 - vim.g.indent_guides_tab_guides = 0 - vim.g.indent_guides_start_level = 2 - vim.g.indent_guides_enable_on_vim_startup = 1 - end -} -- -- Misc. @@ -98,11 +27,6 @@ ct.set( {'wrapmargin', 0} ) --- Rainbow Delimiters -pk_use { - 'hiphish/rainbow-delimiters.nvim', -} - -- dont show line number in terminal window vim.cmd('autocmd TermOpen * setlocal nonu') -- turn on mouse