├── lua ├── config │ ├── autocmds.lua │ ├── options.lua │ ├── keymaps.lua │ └── lazy.lua └── plugins │ ├── extralang.lua │ ├── luasnip.lua │ ├── catppuccin.lua │ ├── parinfer.lua │ ├── telescope.lua │ ├── alpha.lua │ ├── mason.lua │ ├── core.lua │ ├── treesitter.lua │ ├── peek.lua │ ├── cmp.lua │ └── jdtls.lua ├── init.lua ├── .gitignore ├── .editorconfig └── README.md /lua/config/autocmds.lua: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | require("config.lazy") 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .netrwhist 2 | /plugged 3 | /plugin 4 | lazy-lock.json 5 | 6 | -------------------------------------------------------------------------------- /lua/plugins/extralang.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { "elkowar/yuck.vim", ft = "yuck" } 3 | } 4 | -------------------------------------------------------------------------------- /lua/config/options.lua: -------------------------------------------------------------------------------- 1 | local opt = vim.opt 2 | opt.shiftwidth = 4 3 | opt.tabstop = 4 4 | opt.clipboard = "" 5 | -------------------------------------------------------------------------------- /lua/plugins/luasnip.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "L3MON4D3/LuaSnip", 3 | keys = function() 4 | return {} 5 | end, 6 | } 7 | -------------------------------------------------------------------------------- /lua/plugins/catppuccin.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { 3 | "catppuccin/nvim", 4 | lazy = true, 5 | name = "catppuccin", 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /lua/plugins/parinfer.lua: -------------------------------------------------------------------------------- 1 | -- better lisp editing 2 | return { 3 | "eraserhd/parinfer-rust", 4 | ft = { "lisp", "scheme" }, 5 | build = "cargo build --release", 6 | } 7 | -------------------------------------------------------------------------------- /lua/plugins/telescope.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "nvim-telescope/telescope.nvim", 3 | opts = { 4 | defaults = { 5 | path_display = { "smart" } 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /lua/plugins/alpha.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "goolord/alpha-nvim", 3 | opts = function() 4 | local dashboard = require("alpha.themes.dashboard") 5 | dashboard.section.header.val = "¯\\_( ͡° ͜ʖ ͡°)_/¯" 6 | end, 7 | } 8 | -------------------------------------------------------------------------------- /lua/plugins/mason.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "williamboman/mason.nvim", 3 | opts = { 4 | ensure_installed = { 5 | "clangd", 6 | "jdtls", 7 | "python-lsp-server", 8 | }, 9 | }, 10 | } 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | # Using Unix style 3 | end_of_line = lf 4 | # use 4 space as tab size 5 | tab_width = 4 6 | indent_size = 4 7 | # use space as indent 8 | indent_style = space 9 | [*.lua] 10 | quote_style = double 11 | call_arg_parentheses = keep 12 | -------------------------------------------------------------------------------- /lua/plugins/core.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { 3 | "LazyVim/LazyVim", 4 | opts = { 5 | colorscheme = "catppuccin-frappe", 6 | } 7 | }, 8 | -- disable some plugins 9 | { "folke/tokyonight.nvim", enabled = false }, 10 | { "vim-startuptime", enabled = false }, 11 | } 12 | -------------------------------------------------------------------------------- /lua/config/keymaps.lua: -------------------------------------------------------------------------------- 1 | local Util = require("lazyvim.util") 2 | 3 | local function map(mode, lhs, rhs, opts) 4 | local keys = require("lazy.core.handler").handlers.keys 5 | ---@cast keys LazyKeysHandler 6 | if not keys.active[keys.parse({ lhs, mode = mode }).id] then 7 | opts = opts or {} 8 | opts.silent = opts.silent ~= false 9 | vim.keymap.set(mode, lhs, rhs, opts) 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # neovim config with [LazyVim](https://github.com/LazyVim/LazyVim) 2 | 3 | ## Prerequisite 4 | 5 | 1. [neovim](https://github.com/neovim/neovim) 0.8 or higher 6 | 2. [bat](https://github.com/sharkdp/bat) for preview text in telescope search dialog 7 | 3. [fd](https://github.com/sharkdp/fd) for find files by file name 8 | 4. [ripgrep](https://github.com/BurntSushi/ripgrep) for find files by contents in files 9 | 5. patched fonts. (e.g. [nerd-fonts](https://github.com/ryanoasis/nerd-fonts)) 10 | 6. `rustup` for rust-analyzer to work 11 | 7. `cargo` for `parinfer-rust` plugin compile 12 | 8. `deno` for `peek` plugin compile 13 | 10. `webkit2gtk` for `peek` plugin run 14 | 11. some lsp server installed by `Mason` needs package managers such as `npm` and `pip` or download tool such as `wget` and `curl`. 15 | 16 | ## Installation 17 | 18 | 1. clone this repo to personal neovim config folder (e.g. $HOME/.config/nvim) 19 | 2. launch neovim via command `nvim` 20 | 21 | -------------------------------------------------------------------------------- /lua/plugins/treesitter.lua: -------------------------------------------------------------------------------- 1 | -- treesitter config 2 | return { 3 | "nvim-treesitter/nvim-treesitter", 4 | opts = function(_, opts) 5 | opts.matchup = { enable = true } 6 | if type(opts.ensure_installed) == "table" then 7 | vim.list_extend(opts.ensure_installed, { 8 | "bash", 9 | "c", 10 | "cmake", 11 | "cpp", 12 | "css", 13 | "go", 14 | "html", 15 | "java", 16 | "json5", 17 | "jsonc", 18 | "kotlin", 19 | "rust", 20 | "scheme", 21 | "scss", 22 | "svelte", 23 | "typescript", 24 | "vue", 25 | }) 26 | end 27 | end, 28 | dependencies = { 29 | -- better matchup which can be intergreted to treesitter 30 | "andymass/vim-matchup", 31 | }, 32 | } 33 | -------------------------------------------------------------------------------- /lua/plugins/peek.lua: -------------------------------------------------------------------------------- 1 | -- markdown support 2 | return { 3 | "toppair/peek.nvim", 4 | ft = "markdown", 5 | config = function() 6 | -- default config: 7 | require("peek").setup({ 8 | auto_load = true, -- whether to automatically load preview when 9 | -- entering another markdown buffer 10 | close_on_bdelete = true, -- close preview window on buffer delete 11 | syntax = true, -- enable syntax highlighting, affects performance 12 | theme = "dark", -- 'dark' or 'light' 13 | update_on_change = true, 14 | -- relevant if update_on_change is true 15 | throttle_at = 200000, -- start throttling when file exceeds this 16 | -- amount of bytes in size 17 | throttle_time = "auto", -- minimum amount of time in milliseconds 18 | -- that has to pass before starting new render 19 | }) 20 | vim.api.nvim_create_user_command('PeekOpen', require('peek').open, {}) 21 | vim.api.nvim_create_user_command('PeekClose', require('peek').close, {}) 22 | end, 23 | build = "deno task --quiet build:fast" 24 | } 25 | -------------------------------------------------------------------------------- /lua/config/lazy.lua: -------------------------------------------------------------------------------- 1 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" 2 | if not vim.loop.fs_stat(lazypath) then 3 | vim.fn.system({ 4 | "git", 5 | "clone", 6 | "--filter=blob:none", 7 | "https://github.com/folke/lazy.nvim.git", 8 | "--branch=stable", 9 | lazypath, 10 | }) 11 | end 12 | vim.opt.rtp:prepend(vim.env.LAZY or lazypath) 13 | 14 | require("lazy").setup({ 15 | spec = { 16 | { 17 | "LazyVim/LazyVim", 18 | import = "lazyvim.plugins", 19 | }, 20 | { import = "lazyvim.plugins.extras.dap" }, 21 | { import = "lazyvim.plugins.extras.test" }, 22 | { import = "lazyvim.plugins.extras.lang.go" }, 23 | { import = "lazyvim.plugins.extras.lang.json" }, 24 | { import = "lazyvim.plugins.extras.lang.tailwind" }, 25 | { import = "lazyvim.plugins.extras.lang.typescript" }, 26 | { import = "lazyvim.plugins.extras.util.project" }, 27 | { import = "plugins" }, 28 | }, 29 | defaults = { 30 | lazy = false, 31 | version = false, 32 | }, 33 | checker = { enabled = false }, 34 | performance = { 35 | rtp = { 36 | -- disable some rtp plugins 37 | disabled_plugins = { 38 | "gzip", 39 | "matchit", 40 | "matchparen", 41 | "netrwPlugin", 42 | "tarPlugin", 43 | "tohtml", 44 | "tutor", 45 | "zipPlugin", 46 | }, 47 | }, 48 | }, 49 | }) 50 | -------------------------------------------------------------------------------- /lua/plugins/cmp.lua: -------------------------------------------------------------------------------- 1 | -- auto completion 2 | return { 3 | "hrsh7th/nvim-cmp", 4 | opts = function(_, opts) 5 | local has_words_before = function() 6 | unpack = unpack or table.unpack 7 | local line, col = unpack(vim.api.nvim_win_get_cursor(0)) 8 | return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil 9 | end 10 | local luasnip = require("luasnip") 11 | local cmp = require("cmp") 12 | opts.mapping = vim.tbl_extend("force", opts.mapping, { 13 | [""] = cmp.mapping(function() 14 | luasnip.jump(1) 15 | end, { "i", "s" }), 16 | [""] = cmp.mapping(function() 17 | luasnip.jump( -1) 18 | end, { "i", "s" }), 19 | [""] = cmp.mapping(function(fallback) 20 | if cmp.visible() then 21 | cmp.confirm({ select = true }) 22 | elseif luasnip.expand_or_locally_jumpable() then 23 | luasnip.expand_or_jump() 24 | elseif has_words_before() then 25 | cmp.complete() 26 | else 27 | fallback() 28 | end 29 | end, { "i", "s" }), 30 | [""] = cmp.mapping(function(fallback) 31 | if cmp.visible() then 32 | cmp.select_prev_item() 33 | elseif luasnip.jumpable( -1) then 34 | luasnip.jump( -1) 35 | else 36 | fallback() 37 | end 38 | end, { "i", "s" }), 39 | }) 40 | end, 41 | } 42 | -------------------------------------------------------------------------------- /lua/plugins/jdtls.lua: -------------------------------------------------------------------------------- 1 | -- java lsp 2 | return { 3 | { 4 | "neovim/nvim-lspconfig", 5 | opts = { 6 | setup = { 7 | -- disable jdtls config from lspconfig 8 | jdtls = function() 9 | return true 10 | end, 11 | } 12 | } 13 | }, 14 | { 15 | "mfussenegger/nvim-jdtls", 16 | ft = "java", 17 | config = function() 18 | local on_attach = function(client, bufnr) 19 | require("jdtls").setup_dap() 20 | require("lazyvim.plugins.lsp.keymaps").on_attach(client, bufnr) 21 | end 22 | 23 | local capabilities = require("cmp_nvim_lsp").default_capabilities() 24 | local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") 25 | -- calculate workspace dir 26 | local workspace_dir = vim.fn.stdpath("data") .. "/site/java/workspace-root/" .. project_name 27 | 28 | -- get the current OS 29 | local os 30 | if vim.fn.has "mac" == 1 then 31 | os = "mac" 32 | elseif vim.fn.has "unix" == 1 then 33 | os = "linux" 34 | elseif vim.fn.has "win32" == 1 then 35 | os = "win" 36 | end 37 | -- ensure that OS is valid 38 | if not os or os == "" then 39 | return 40 | end 41 | 42 | -- get the mason install path 43 | local install_path = require("mason-registry").get_package("jdtls"):get_install_path() 44 | -- local debug_install_path = require("mason-registry").get_package("java-debug-adapter"):get_install_path() 45 | local config = { 46 | cmd = { 47 | "java", 48 | "-Declipse.application=org.eclipse.jdt.ls.core.id1", 49 | "-Dosgi.bundles.defaultStartLevel=4", 50 | "-Declipse.product=org.eclipse.jdt.ls.core.product", 51 | "-Dlog.protocol=true", 52 | "-Dlog.level=ALL", 53 | "-javaagent:" .. install_path .. "/lombok.jar", 54 | "-Xms1g", 55 | "--add-modules=ALL-SYSTEM", 56 | "--add-opens", 57 | "java.base/java.util=ALL-UNNAMED", 58 | "--add-opens", 59 | "java.base/java.lang=ALL-UNNAMED", 60 | "-jar", 61 | vim.fn.glob(install_path .. "/plugins/org.eclipse.equinox.launcher_*.jar"), 62 | "-configuration", 63 | install_path .. "/config_" .. os, 64 | "-data", 65 | workspace_dir, 66 | }, 67 | on_attach = on_attach, 68 | capabilities = capabilities, 69 | root_dir = vim.fs.dirname( 70 | vim.fs.find({ ".gradlew", ".git", "mvnw", "pom.xml", "build.gradle" }, { upward = true })[1] 71 | ), 72 | settings = { 73 | java = {} 74 | }, 75 | init_options = { 76 | bundles = { 77 | vim.fn.glob( 78 | require("mason-registry").get_package("java-debug-adapter"):get_install_path() 79 | .. "/extension/server/com.microsoft.java.debug.plugin-*.jar" 80 | ), 81 | -- unpack remaining bundles 82 | (table.unpack or unpack)( 83 | vim.split( 84 | vim.fn.glob( 85 | require("mason-registry").get_package("java-test"):get_install_path() .. 86 | "/extension/server/*.jar" 87 | ), 88 | "\n", 89 | {} 90 | ) 91 | ), 92 | }, 93 | }, 94 | filetypes = { "java" }, 95 | } 96 | vim.api.nvim_create_autocmd("FileType", { 97 | pattern = "java", 98 | callback = function() 99 | require("jdtls").start_or_attach(config) 100 | end, 101 | }) 102 | end, 103 | } 104 | } 105 | --------------------------------------------------------------------------------