├── .gitignore ├── init.lua ├── stylua.toml ├── lua ├── pika │ ├── init.lua │ ├── plugins │ │ ├── notes.lua │ │ ├── vcs.lua │ │ ├── colorscheme.lua │ │ ├── ft.lua │ │ ├── common.lua │ │ ├── treesitter.lua │ │ ├── picker.lua │ │ ├── lines.lua │ │ ├── completion.lua │ │ └── lsp.lua │ ├── lazy.lua │ ├── keymap.lua │ ├── autocmd.lua │ └── options.lua └── .luarc.json ├── README.md ├── lazy-lock.json └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | plugin 2 | -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | require("pika") 2 | -------------------------------------------------------------------------------- /stylua.toml: -------------------------------------------------------------------------------- 1 | indent_type = "Spaces" 2 | indent_width = 2 3 | -------------------------------------------------------------------------------- /lua/pika/init.lua: -------------------------------------------------------------------------------- 1 | require("pika.options") 2 | require("pika.keymap") 3 | require("pika.autocmd") 4 | require("pika.lazy") 5 | -------------------------------------------------------------------------------- /lua/pika/plugins/notes.lua: -------------------------------------------------------------------------------- 1 | return { 2 | "zk-org/zk-nvim", 3 | config = function() 4 | require("zk").setup({ 5 | picker = "fzf_lua", 6 | }) 7 | end, 8 | ft = { "markdown" }, 9 | } 10 | -------------------------------------------------------------------------------- /lua/.luarc.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", 3 | "Lua": { 4 | "runtime.version": "LuaJIT", 5 | "workspace.checkThirdParty": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /lua/pika/plugins/vcs.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { 3 | "mhinz/vim-signify", 4 | config = function() 5 | vim.g.signify_sign_add = "│" 6 | vim.g.signify_sign_change = "│" 7 | vim.g.signify_priority = 5 8 | end, 9 | }, 10 | } 11 | -------------------------------------------------------------------------------- /lua/pika/plugins/colorscheme.lua: -------------------------------------------------------------------------------- 1 | return { 2 | -- 'rktjmp/lush.nvim', 3 | { 4 | "olimorris/onedarkpro.nvim", 5 | lazy = false, 6 | priority = 1000, 7 | config = function() 8 | require("onedarkpro").load() 9 | end, 10 | }, 11 | } 12 | -------------------------------------------------------------------------------- /lua/pika/plugins/ft.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { "vim-python/python-syntax", ft = "python" }, 3 | { "Vimjas/vim-python-pep8-indent", ft = "python" }, 4 | { "rust-lang/rust.vim", ft = "rust" }, 5 | { "lervag/vimtex", ft = "tex" }, 6 | { "dcharbon/vim-flatbuffers", ft = "fbs" }, 7 | } 8 | -------------------------------------------------------------------------------- /lua/pika/lazy.lua: -------------------------------------------------------------------------------- 1 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" 2 | if not vim.uv.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", -- latest stable release 9 | lazypath, 10 | }) 11 | end 12 | vim.opt.rtp:prepend(lazypath) 13 | 14 | require("lazy").setup("pika.plugins", { 15 | ui = { border = "rounded" }, 16 | }) 17 | -------------------------------------------------------------------------------- /lua/pika/plugins/common.lua: -------------------------------------------------------------------------------- 1 | return { 2 | { "ntpeters/vim-better-whitespace", event = "VeryLazy" }, 3 | { "tpope/vim-abolish", event = "VeryLazy" }, 4 | { "kylechui/nvim-surround", event = "VeryLazy", config = true }, 5 | { "numToStr/Comment.nvim", event = "VeryLazy", config = true }, 6 | { 7 | "lukas-reineke/indent-blankline.nvim", 8 | event = "VeryLazy", 9 | main = "ibl", 10 | opts = { 11 | exclude = { 12 | filetypes = { "help", "man" }, 13 | buftypes = { "terminal" }, 14 | }, 15 | }, 16 | }, 17 | } 18 | -------------------------------------------------------------------------------- /lua/pika/plugins/treesitter.lua: -------------------------------------------------------------------------------- 1 | local treesitter_langs = { 2 | "c", 3 | "cpp", 4 | "python", 5 | "rust", 6 | "lua", 7 | "vim", 8 | "vimdoc", 9 | "javascript", 10 | "typescript", 11 | "html", 12 | "css", 13 | "scss", 14 | "styled", 15 | "markdown", 16 | "markdown_inline", 17 | } 18 | 19 | return { 20 | "nvim-treesitter/nvim-treesitter", 21 | build = ":TSUpdate", 22 | config = function() 23 | local configs = require("nvim-treesitter.configs") 24 | 25 | configs.setup({ 26 | ensure_installed = treesitter_langs, 27 | sync_install = false, 28 | auto_install = true, 29 | ignore_install = {}, 30 | modules = {}, 31 | highlight = { enable = true }, 32 | indent = { enable = true }, 33 | }) 34 | end, 35 | } 36 | -------------------------------------------------------------------------------- /lua/pika/plugins/picker.lua: -------------------------------------------------------------------------------- 1 | local function fzf_config() 2 | local actions = require("fzf-lua.actions") 3 | local fzf = require("fzf-lua") 4 | fzf.setup({ 5 | fzf_bin = "fzf", 6 | actions = { 7 | files = { 8 | ["default"] = actions.file_edit, 9 | }, 10 | }, 11 | }) 12 | fzf.register_ui_select() 13 | 14 | local map = function(lhs, rhs) 15 | vim.keymap.set("n", lhs, rhs) 16 | end 17 | 18 | map("ff", fzf.files) 19 | map("fb", fzf.buffers) 20 | map("fg", fzf.grep) 21 | map("fd", fzf.diagnostics_document) 22 | end 23 | 24 | return { 25 | { 26 | "ibhagwan/fzf-lua", 27 | dependencies = { 28 | -- optional for icon support 29 | "kyazdani42/nvim-web-devicons", 30 | -- { 'lotabout/skim', build = './install' } 31 | -- 'junegunn/fzf', 32 | }, 33 | config = fzf_config, 34 | event = "VeryLazy", 35 | }, 36 | } 37 | -------------------------------------------------------------------------------- /lua/pika/keymap.lua: -------------------------------------------------------------------------------- 1 | local map = vim.keymap.set 2 | local function simap(mode, lhs, rhs, opts) 3 | if opts == nil then 4 | opts = {} 5 | end 6 | opts.silent = true 7 | vim.keymap.set(mode, lhs, rhs, opts) 8 | end 9 | 10 | -- map leader 11 | vim.g.mapleader = " " 12 | vim.g.maplocalleader = " " 13 | 14 | -- Swap j <-> gj, k <-> gk. It is more intuitive when moving in long lines. 15 | map("n", "j", "gj") 16 | map("n", "k", "gk") 17 | map("n", "gj", "j") 18 | map("n", "gk", "k") 19 | -- Swap 0 <-> ^. 0 is easier to press while the original ^ is more useful. 20 | map("n", "0", "^") 21 | map("n", "^", "0") 22 | map("v", "0", "^") 23 | map("v", "^", "0") 24 | -- Make +/- be increasing/decreasing the number. 25 | map("n", "+", "") 26 | map("n", "-", "") 27 | -- Tmux uses . Let's use instead. 28 | map("i", "", "") 29 | -- Make window resizing easier. 30 | map("n", "", "2>") 31 | map("n", "", "2<") 32 | map("n", "", "+") 33 | map("n", "", "-") 34 | 35 | simap("n", "/", "nohl") 36 | simap("n", "w", "w!") 37 | simap("n", "q", "bdelete") 38 | simap("n", "", "b #") 39 | 40 | simap("n", "L", "bnext") 41 | simap("n", "H", "bprev") 42 | -------------------------------------------------------------------------------- /lua/pika/plugins/lines.lua: -------------------------------------------------------------------------------- 1 | local function bufferline_config() 2 | require("bufferline").setup({ 3 | options = { 4 | separator_style = "thick", 5 | show_buffer_close_icons = false, 6 | diagnostics = "nvim_lsp", 7 | }, 8 | }) 9 | end 10 | 11 | local function lualine_config() 12 | require("lualine").setup({ 13 | options = { theme = "onedark" }, 14 | sections = { 15 | lualine_b = { 16 | "diagnostics", 17 | }, 18 | lualine_c = { 19 | { "filename", path = 1 }, 20 | }, 21 | lualine_x = { 22 | "branch", 23 | { 24 | "signify_diff", 25 | symbols = { added = "+", modified = "~", removed = "-" }, 26 | }, 27 | }, 28 | lualine_y = { "encoding", "fileformat", "filetype" }, 29 | lualine_z = { "progress" }, 30 | }, 31 | extensions = { 32 | "quickfix", 33 | "symbols-outline", 34 | }, 35 | }) 36 | end 37 | 38 | return { 39 | { 40 | "akinsho/bufferline.nvim", 41 | dependencies = { "kyazdani42/nvim-web-devicons" }, 42 | config = bufferline_config, 43 | }, 44 | { 45 | "hoob3rt/lualine.nvim", 46 | dependencies = { 47 | "kyazdani42/nvim-web-devicons", 48 | { 49 | "chmnchiang/lualine-signify-diff", 50 | dependencies = { "mhinz/vim-signify" }, 51 | }, 52 | }, 53 | config = lualine_config, 54 | }, 55 | } 56 | -------------------------------------------------------------------------------- /lua/pika/autocmd.lua: -------------------------------------------------------------------------------- 1 | local buf_get_option = function(buf, name) 2 | return vim.api.nvim_get_option_value(name, { buf = buf }) 3 | end 4 | 5 | local function has_ignore_buftype(buf) 6 | local ignore_bts = { "quickfix", "nofile", "help" } 7 | local bt = buf_get_option(buf, "buftype") 8 | return vim.tbl_contains(ignore_bts, bt) 9 | end 10 | 11 | local function has_ignore_filetype(buf) 12 | local ft = buf_get_option(buf, "filetype") 13 | if vim.endswith(ft, "commit") or vim.endswith(ft, "rebase") then 14 | return true 15 | end 16 | return false 17 | end 18 | 19 | local group_id = vim.api.nvim_create_augroup("pika_group", {}) 20 | 21 | -- Restore the cursor to the line when reopen a file. 22 | vim.api.nvim_create_autocmd("BufWinEnter", { 23 | group = group_id, 24 | pattern = "*", 25 | callback = function(args) 26 | local buf = args.buf 27 | 28 | if has_ignore_buftype(buf) or has_ignore_filetype(buf) then 29 | return 30 | end 31 | 32 | local pos = vim.api.nvim_buf_get_mark(buf, '"')[1] 33 | local line_count = vim.api.nvim_buf_line_count(buf) 34 | if pos > 1 and pos <= line_count then 35 | vim.cmd([[normal! g`"]]) 36 | end 37 | end, 38 | }) 39 | 40 | -- Open :help vertically 41 | vim.api.nvim_create_autocmd("BufEnter", { 42 | group = group_id, 43 | pattern = "*.txt", 44 | callback = function(args) 45 | if buf_get_option(args.buf, "buftype") == "help" then 46 | vim.cmd([[wincmd L]]) 47 | end 48 | end, 49 | }) 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pika-nvim 2 | 3 | Version: 0.4.0 4 | 5 | My neovim configuration 6 | 7 | This configuration is only tested on my own environments. 8 | 9 | ## How to Use 10 | 11 | ### Dependencies 12 | 13 | - Latest [neovim][neovim] 0.10.0+. 14 | - [rg](https://github.com/BurntSushi/ripgrep) 15 | - Dependencies of [fzf-lua](https://github.com/ibhagwan/fzf-lua) 16 | 17 | ### Optional Dependencies 18 | 19 | These are needed if you want to use all features. 20 | 21 | - g++/clang (for compile c++ programs) 22 | - clangd provides LSP support. 23 | - (xe)latex compiler (for latex usage) 24 | - rust (and rust\_analyzer) 25 | - pyright 26 | 27 | ### Deploy 28 | To use this configuration, run following commands: 29 | ```console 30 | $ git clone --depth=1 -b neovim https://github.com/leomao/pika-vim.git 31 | $ ln -sr pika-vim ~/.config/nvim 32 | ``` 33 | 34 | ### Update Plugins 35 | Execute `:Lazy sync`. See [lazy.nvim][lazy.nvim] for more details. 36 | 37 | ## Common Shortcut 38 | 39 | Currently both `` and `` are ``. 40 | 41 | ### General 42 | - Save file `w` 43 | - next buffer `L` 44 | - previous buffer `H` 45 | - close buffer `q` 46 | - `:nohl` `/` 47 | 48 | ### Comment 49 | See [Comment.nvim](https://github.com/numToStr/Comment.nvim) 50 | 51 | ### vimtex 52 | - Compile `ll` 53 | - View `lv` 54 | - View error `le` 55 | - set main file: add `%! TEX root=MAINFILE_RELATIVEPATH` at the top of your file 56 | - you may want to add 57 | ``` 58 | $pdflatex = 'xelatex -synctex=1 -interaction=nonstopmode --shell-escape %O %S'; 59 | ``` 60 | in `~/.latexmkrc`. 61 | 62 | ### LSP 63 | TBD 64 | 65 | ## Acknowledgement 66 | 67 | This configuration borrowed lots of things from 68 | https://github.com/chmnchiang/vim. 69 | 70 | [neovim]: https://github.com/neovim/neovim 71 | [lazy.nvim]: https://github.com/folke/lazy.nvim 72 | -------------------------------------------------------------------------------- /lua/pika/options.lua: -------------------------------------------------------------------------------- 1 | vim.autoread = true -- Trigger autoread when files change on disk 2 | 3 | local opt = vim.opt 4 | 5 | opt.background = "dark" 6 | opt.termguicolors = true 7 | 8 | opt.confirm = true 9 | 10 | opt.mouse = "a" 11 | opt.termguicolors = true -- True color support 12 | opt.hidden = true -- Enable background buffers 13 | 14 | opt.smartcase = true -- Do not ignore case with capitals 15 | opt.ignorecase = true -- Ignore case 16 | opt.hlsearch = true 17 | opt.incsearch = true 18 | 19 | opt.joinspaces = false -- No double spaces with join 20 | opt.list = true -- Show some invisible characters 21 | 22 | opt.number = true -- Show line numbers 23 | opt.relativenumber = true -- Relative line numbers 24 | opt.signcolumn = "yes" -- Always show sign column 25 | opt.colorcolumn = "+1" -- Show textwidth column 26 | opt.ruler = true 27 | 28 | opt.encoding = "utf8" 29 | opt.fileencoding = "utf8" 30 | 31 | opt.backup = false 32 | opt.writebackup = false 33 | opt.swapfile = false 34 | 35 | opt.textwidth = 80 36 | 37 | opt.expandtab = true -- Use spaces instead of tabs 38 | opt.shiftwidth = 2 -- Size of an indent 39 | opt.tabstop = 2 -- Number of spaces tabs count for 40 | opt.softtabstop = 2 -- Number of spaces tabs count for 41 | opt.smartindent = true -- Insert indents automatically 42 | opt.shiftround = true -- Round indent 43 | 44 | opt.scrolloff = 4 -- Lines of context 45 | opt.sidescrolloff = 8 -- Columns of context 46 | 47 | opt.splitbelow = true -- Put new windows below current 48 | opt.splitright = true -- Put new windows right of current 49 | 50 | opt.wrap = false -- Disable line wrap 51 | opt.wildmode = "full" -- Command-line completion mode 52 | opt.wildignorecase = true 53 | opt.wildmenu = true 54 | opt.wildignore = "*.o,*.obj,*~,*.synctex.gz,*.pdf" 55 | 56 | opt.updatetime = 100 57 | opt.timeoutlen = 300 58 | opt.ttimeoutlen = 20 59 | 60 | opt.showmode = false 61 | opt.showcmd = true 62 | 63 | opt.foldenable = true 64 | opt.foldmethod = "marker" 65 | 66 | -- Remove the annoying preview window 67 | opt.completeopt:remove("preview") 68 | opt.pumheight = 15 69 | 70 | opt.inccommand = "nosplit" -- Incremental replace with preview 71 | 72 | opt.grepformat = "%f:%l:%c:%m" 73 | opt.grepprg = "rg --vimgrep" 74 | 75 | opt.winborder = "rounded" 76 | -------------------------------------------------------------------------------- /lua/pika/plugins/completion.lua: -------------------------------------------------------------------------------- 1 | local function nvim_cmp_config() 2 | local cmp = require("cmp") 3 | local lspkind = require("lspkind") 4 | 5 | local lspkind_format = lspkind.cmp_format({ 6 | with_text = true, 7 | menu = { 8 | buffer = "[Buffer]", 9 | nvim_lsp = "[LSP]", 10 | path = "[Path]", 11 | }, 12 | }) 13 | vim.api.nvim_set_hl(0, "CmpItemAbbr", { fg = "#b0b0b0" }) 14 | 15 | local format = function(entry, vim_item) 16 | local function trim(s, max_len) 17 | if string.len(s) <= max_len then 18 | return s 19 | else 20 | return string.sub(s, 1, max_len - 1) .. "…" 21 | end 22 | end 23 | 24 | vim_item.abbr = trim(vim_item.abbr, 80) 25 | return lspkind_format(entry, vim_item) 26 | end 27 | 28 | cmp.setup({ 29 | snippet = { 30 | expand = function(args) 31 | require("snippy").expand_snippet(args.body) 32 | end, 33 | }, 34 | mapping = cmp.mapping.preset.insert({ 35 | [""] = cmp.mapping.scroll_docs(-4), 36 | [""] = cmp.mapping.scroll_docs(4), 37 | [""] = cmp.mapping.complete(), 38 | [""] = cmp.mapping.abort(), 39 | [""] = cmp.mapping.confirm({ select = true }), 40 | }), 41 | sources = { 42 | { name = "nvim_lsp" }, 43 | { name = "buffer" }, 44 | { name = "path" }, 45 | { name = "snippy" }, 46 | }, 47 | formatting = { format = format }, 48 | sorting = { 49 | comparators = { 50 | cmp.config.compare.offset, 51 | cmp.config.compare.exact, 52 | require("clangd_extensions.cmp_scores"), 53 | cmp.config.compare.score, 54 | cmp.config.compare.recently_used, 55 | cmp.config.compare.locality, 56 | cmp.config.compare.kind, 57 | cmp.config.compare.length, 58 | cmp.config.compare.order, 59 | }, 60 | }, 61 | }) 62 | cmp.setup.cmdline("/", { 63 | mapping = cmp.mapping.preset.cmdline(), 64 | sources = { { name = "buffer" } }, 65 | }) 66 | cmp.setup.cmdline(":", { 67 | mapping = cmp.mapping.preset.cmdline(), 68 | sources = cmp.config.sources({ { name = "path" } }, { { name = "cmdline" } }), 69 | }) 70 | end 71 | 72 | return { 73 | { 74 | "hrsh7th/nvim-cmp", 75 | dependencies = { 76 | "onsails/lspkind-nvim", 77 | "hrsh7th/cmp-nvim-lsp", 78 | "hrsh7th/cmp-buffer", 79 | "hrsh7th/cmp-path", 80 | "hrsh7th/cmp-cmdline", 81 | { 82 | "dcampos/cmp-snippy", 83 | dependencies = { "dcampos/nvim-snippy" }, 84 | }, 85 | }, 86 | config = nvim_cmp_config, 87 | event = { "InsertEnter", "CmdlineEnter" }, 88 | }, 89 | } 90 | -------------------------------------------------------------------------------- /lazy-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, 3 | "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, 4 | "clangd_extensions.nvim": { "branch": "main", "commit": "db28f29be928d18cbfb86fbfb9f83f584f658feb" }, 5 | "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, 6 | "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, 7 | "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, 8 | "cmp-path": { "branch": "main", "commit": "e52e640b7befd8113b3350f46e8cfcfe98fcf730" }, 9 | "cmp-snippy": { "branch": "master", "commit": "6e39210aa3a74e2bf6462f492eaf0d436cd2b7d3" }, 10 | "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, 11 | "fzf-lua": { "branch": "main", "commit": "f972ad787ee8d3646d30000a0652e9b168a90840" }, 12 | "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, 13 | "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, 14 | "lsp_signature.nvim": { "branch": "master", "commit": "d9c39937e4e0977357530e988aa8940078bb231f" }, 15 | "lspkind-nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, 16 | "lualine-signify-diff": { "branch": "main", "commit": "ef4a3217e632d1961991080b2b45d553cab94227" }, 17 | "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, 18 | "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, 19 | "nvim-lspconfig": { "branch": "master", "commit": "5bb3fb4a63eb38361f3f992618f65dd4fa52e72b" }, 20 | "nvim-snippy": { "branch": "master", "commit": "6e5a522e74595b0b2d45359a00b199dca4981236" }, 21 | "nvim-surround": { "branch": "main", "commit": "8dd9150ca7eae5683660ea20cec86edcd5ca4046" }, 22 | "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, 23 | "nvim-web-devicons": { "branch": "master", "commit": "0422a19d9aa3aad2c7e5cca167e5407b13407a9d" }, 24 | "onedarkpro.nvim": { "branch": "main", "commit": "5ffd45b3602bc1ed75f0b2be6c5c1f6ba5c6b796" }, 25 | "python-syntax": { "branch": "master", "commit": "2cc00ba72929ea5f9456a26782db57fb4cc56a65" }, 26 | "rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, 27 | "rustaceanvim": { "branch": "master", "commit": "c86d5d36456fdaa91a3a9dddb4bac09c58fc8cd3" }, 28 | "symbols-outline.nvim": { "branch": "master", "commit": "564ee65dfc9024bdde73a6621820866987cbb256" }, 29 | "vim-abolish": { "branch": "master", "commit": "dcbfe065297d31823561ba787f51056c147aa682" }, 30 | "vim-better-whitespace": { "branch": "master", "commit": "de99b55a6fe8c96a69f9376f16b1d5d627a56e81" }, 31 | "vim-flatbuffers": { "branch": "master", "commit": "ecd75c33576d982f3c83545dff7b3c9245285e75" }, 32 | "vim-python-pep8-indent": { "branch": "master", "commit": "60ba5e11a61618c0344e2db190210145083c91f8" }, 33 | "vim-signify": { "branch": "master", "commit": "8670143f9e12ed1cd3c9b2c54f345cdd9a4baac3" }, 34 | "vimtex": { "branch": "master", "commit": "7f2633027c8f496a85284de0c11aa32f1e07e049" }, 35 | "zk-nvim": { "branch": "main", "commit": "b18782530b23ad118d578c0fa0e4d0b8d386db4c" } 36 | } 37 | -------------------------------------------------------------------------------- /lua/pika/plugins/lsp.lua: -------------------------------------------------------------------------------- 1 | local function lsp_on_attach(client, bufnr) 2 | require("lsp_signature").on_attach({}, bufnr) 3 | 4 | if vim.lsp.formatexpr then 5 | vim.api.nvim_set_option_value("formatexpr", "v:lua.vim.lsp.formatexpr", { 6 | buf = bufnr, 7 | }) 8 | end 9 | if vim.lsp.tagfunc then 10 | vim.api.nvim_set_option_value("tagfunc", "v:lua.vim.lsp.tagfunc", { 11 | buf = bufnr, 12 | }) 13 | end 14 | 15 | local function map(mode, lhs, rhs) 16 | vim.keymap.set(mode, lhs, rhs, { buffer = true, silent = true }) 17 | end 18 | 19 | map("n", "D", vim.lsp.buf.declaration) 20 | map("n", "K", vim.lsp.buf.hover) 21 | map("n", "k", vim.lsp.buf.signature_help) 22 | map("n", "e", vim.diagnostic.open_float) 23 | map("n", "R", vim.lsp.buf.rename) 24 | map("n", "[g", function() 25 | vim.diagnostic.jump({ count = -1, float = true }) 26 | end) 27 | map("n", "]g", function() 28 | vim.diagnostic.jump({ count = 1, float = true }) 29 | end) 30 | map("n", "a", vim.lsp.buf.code_action) 31 | 32 | map("n", "d", vim.lsp.buf.definition) 33 | map("n", "i", vim.lsp.buf.implementation) 34 | map("n", "t", vim.lsp.buf.type_definition) 35 | map("n", "r", vim.lsp.buf.references) 36 | 37 | -- Set some keybinds conditional on server capabilities 38 | if client.server_capabilities.document_formatting then 39 | map("n", "F", vim.lsp.buf.formatting) 40 | end 41 | if client.server_capabilities.document_range_formatting then 42 | map("v", "F", vim.lsp.buf.range_formatting) 43 | end 44 | 45 | -- Set autocommands conditional on server_capabilities 46 | if client.server_capabilities.document_highlight then 47 | vim.api.nvim_set_hl(0, "LspReferenceRead", { link = "Search" }) 48 | vim.api.nvim_set_hl(0, "LspReferenceText", { link = "Search" }) 49 | vim.api.nvim_set_hl(0, "LspReferenceWrite", { link = "Search" }) 50 | local group_id = vim.api.nvim_create_augroup("lsp_document_highlight", {}) 51 | vim.api.nvim_create_autocmd("CursorHold", { 52 | group = group_id, 53 | buffer = bufnr, 54 | callback = vim.lsp.buf.document_highlight, 55 | }) 56 | vim.api.nvim_create_autocmd("CursorMoved", { 57 | group = group_id, 58 | buffer = bufnr, 59 | callback = vim.lsp.buf.clear_references, 60 | }) 61 | end 62 | end 63 | 64 | vim.api.nvim_create_autocmd("LspAttach", { 65 | group = vim.api.nvim_create_augroup("UserLspConfig", {}), 66 | callback = function(args) 67 | local bufnr = args.buf 68 | local client = vim.lsp.get_client_by_id(args.data.client_id) 69 | lsp_on_attach(client, bufnr) 70 | end, 71 | }) 72 | 73 | local function lsp_config() 74 | vim.lsp.config("*", { 75 | capabilities = require("cmp_nvim_lsp").default_capabilities(), 76 | root_markers = { ".git" }, 77 | }) 78 | 79 | local runtime_path = vim.split(package.path, ";") 80 | table.insert(runtime_path, "lua/?.lua") 81 | table.insert(runtime_path, "lua/?/init.lua") 82 | 83 | vim.lsp.config("lua_ls", { 84 | settings = { 85 | Lua = { 86 | runtime = { version = "LuaJIT", path = runtime_path }, 87 | diagnostics = { globals = { "vim" } }, 88 | workspace = { library = vim.api.nvim_get_runtime_file("", true) }, 89 | telemetry = { enable = false }, 90 | }, 91 | }, 92 | }) 93 | 94 | vim.lsp.enable("clangd") 95 | vim.lsp.enable("pyright") 96 | vim.lsp.enable("ruff") 97 | vim.lsp.enable("texlab") 98 | vim.lsp.enable("lua_ls") 99 | vim.lsp.enable("ts_ls") 100 | end 101 | 102 | return { 103 | { 104 | "ray-x/lsp_signature.nvim", 105 | lazy = true, 106 | }, 107 | { 108 | "j-hui/fidget.nvim", 109 | opts = {}, 110 | event = "LspAttach", 111 | }, 112 | { 113 | "neovim/nvim-lspconfig", 114 | dependencies = { 115 | "hrsh7th/cmp-nvim-lsp", 116 | }, 117 | config = lsp_config, 118 | }, 119 | { 120 | "simrat39/symbols-outline.nvim", 121 | init = function() 122 | vim.g.symbols_outline = { auto_preview = false } 123 | end, 124 | cmd = { "SymbolsOutline" }, 125 | }, 126 | -- Language specific packages 127 | { 128 | "p00f/clangd_extensions.nvim", 129 | lazy = true, 130 | }, 131 | { 132 | "mrcjkb/rustaceanvim", 133 | version = "^6", -- Recommended 134 | lazy = false, -- This plugin is already lazy 135 | }, 136 | } 137 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2022-2025 Leo Mao 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------