mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
85 Commits
eaddee0c5c
...
v0.9.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a4d71db88 | ||
|
|
dc597004df | ||
|
|
644993a89e | ||
|
|
164d6129f8 | ||
|
|
cde21f6f67 | ||
|
|
8746c7eb11 | ||
|
|
7c44997289 | ||
|
|
bfdb3f5a26 | ||
|
|
76ced0e265 | ||
|
|
e84d18a204 | ||
|
|
6429e8364c | ||
|
|
f2c6900a8d | ||
|
|
116aaa0675 | ||
|
|
12f3ca9d1f | ||
|
|
7e7944a30c | ||
|
|
53c17aea96 | ||
|
|
43c1615822 | ||
|
|
509a8bce8c | ||
|
|
8b10be60d4 | ||
|
|
074d2bbdfd | ||
|
|
7f9af87185 | ||
|
|
bb0b0c5e25 | ||
|
|
7bb12e4b70 | ||
|
|
41da56b823 | ||
|
|
82f2332281 | ||
|
|
075326ee2e | ||
|
|
baa8f26bc2 | ||
|
|
e9760ae9b8 | ||
|
|
0d50eb723f | ||
|
|
b893bdc099 | ||
|
|
2073f72e67 | ||
|
|
364be4b5dc | ||
|
|
d30d402128 | ||
|
|
fc144e0895 | ||
|
|
18abfa7754 | ||
|
|
6c1dbdf8fc | ||
|
|
202a9a088d | ||
|
|
d939cc75c6 | ||
|
|
26921309ec | ||
|
|
a6f716558b | ||
|
|
3539207913 | ||
|
|
d8b92965e8 | ||
|
|
ebf7170916 | ||
|
|
696466469b | ||
|
|
7a5be43600 | ||
|
|
3b39067097 | ||
|
|
e6b3be0777 | ||
|
|
acb423984a | ||
|
|
d40d87cb61 | ||
|
|
81663c8f3c | ||
|
|
2c7e4aa87a | ||
|
|
07dd60206b | ||
|
|
c3d4eb371b | ||
|
|
597a2aba80 | ||
|
|
f1f6d0b351 | ||
|
|
e1930ba153 | ||
|
|
a8db734e75 | ||
|
|
4026baef19 | ||
|
|
f63152f79b | ||
|
|
5229c460ea | ||
|
|
f308ccad7b | ||
|
|
09dd81bf67 | ||
|
|
5ecb74ad85 | ||
|
|
773003b71b | ||
|
|
f5097b44b9 | ||
|
|
238886c136 | ||
|
|
2fccb59293 | ||
|
|
830297a973 | ||
|
|
1f3fcc604a | ||
|
|
7f5bf5a1b2 | ||
|
|
81bc5e46f1 | ||
|
|
b4c3b7eba0 | ||
|
|
4203410878 | ||
|
|
9f58c3b7a5 | ||
|
|
45d0d68b9e | ||
|
|
74a9767018 | ||
|
|
ab25bfc9c4 | ||
|
|
ebbdb27d01 | ||
|
|
1b1f0199da | ||
|
|
40fa9aab1c | ||
|
|
6e8e61e53a | ||
|
|
89effe8b17 | ||
|
|
aaeb6a813a | ||
|
|
9ba728e201 | ||
|
|
e5f1b4d224 |
@@ -3,4 +3,4 @@ line_endings = "Unix"
|
|||||||
indent_type = "Spaces"
|
indent_type = "Spaces"
|
||||||
indent_width = 2
|
indent_width = 2
|
||||||
quote_style = "AutoPreferDouble"
|
quote_style = "AutoPreferDouble"
|
||||||
no_call_parentheses = true
|
call_parentheses= "NoSingleTable"
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018-2022 jdhao
|
Copyright (c) 2018-2023 jdhao
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
36
README.md
36
README.md
@@ -9,24 +9,27 @@
|
|||||||
<a>
|
<a>
|
||||||
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
|
<img alt="Windows" src="https://img.shields.io/badge/Windows-%23.svg?style=flat-square&logo=windows&color=0078D6&logoColor=white" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/jdhao/nvim-config/commits">
|
|
||||||
<img src="https://badgen.net/github/commits/jdhao/nvim-config" alt="Commit number" />
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/jdhao/nvim-config/network">
|
|
||||||
<img alt="Forks" src="https://badgen.net/github/forks/jdhao/nvim-config">
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/jdhao/nvim-config/stargazers">
|
|
||||||
<img alt="Stars" src="https://badgen.net/github/stars/jdhao/nvim-config">
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/jdhao/nvim-config/releases/latest">
|
<a href="https://github.com/jdhao/nvim-config/releases/latest">
|
||||||
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
<a href="https://github.com/neovim/neovim/releases/tag/stable">
|
||||||
<img src="https://img.shields.io/badge/Neovim-0.7.2-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
<img src="https://img.shields.io/badge/Neovim-0.8.1-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
|
<a href="https://github.com/jdhao/nvim-config/search?l=vim-script">
|
||||||
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
|
<img src="https://img.shields.io/github/languages/top/jdhao/nvim-config" alt="Top languages"/>
|
||||||
</a>
|
</a>
|
||||||
|
<a href="https://github.com/jdhao/nvim-config/graphs/commit-activity">
|
||||||
|
<img src="https://img.shields.io/github/commit-activity/m/jdhao/nvim-config?style=flat-square" />
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/jdhao/nvim-config/releases/tag/v0.8.1">
|
||||||
|
<img src="https://img.shields.io/github/commits-since/jdhao/nvim-config/v0.8.1?style=flat-square" />
|
||||||
|
</a>
|
||||||
|
<a href="https://github.com/jdhao/nvim-config/graphs/contributors">
|
||||||
|
<img src="https://img.shields.io/github/contributors/jdhao/nvim-config?style=flat-square" />
|
||||||
|
</a>
|
||||||
|
<a>
|
||||||
|
<img src="https://img.shields.io/github/repo-size/jdhao/nvim-config?style=flat-square" />
|
||||||
|
</a>
|
||||||
<a href="https://github.com/jdhao/nvim-config/blob/master/LICENSE">
|
<a href="https://github.com/jdhao/nvim-config/blob/master/LICENSE">
|
||||||
<img src="https://img.shields.io/github/license/jdhao/nvim-config?style=flat-square&logo=GNU&label=License" alt="License"/>
|
<img src="https://img.shields.io/github/license/jdhao/nvim-config?style=flat-square&logo=GNU&label=License" alt="License"/>
|
||||||
</a>
|
</a>
|
||||||
@@ -58,7 +61,7 @@ and how to set up on different platforms (Linux, macOS, and Windows).
|
|||||||
+ Code, snippet, word auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp).
|
+ Code, snippet, word auto-completion via [nvim-cmp](https://github.com/hrsh7th/nvim-cmp).
|
||||||
+ Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
|
+ Language server protocol (LSP) support via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig).
|
||||||
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
|
+ Git integration via [vim-fugitive](https://github.com/tpope/vim-fugitive).
|
||||||
+ Better escaping from insert mode via [better-escape.vim](https://github.com/jdhao/better-escape.vim).
|
+ Better escaping from insert mode via [better-escape.vim](https://github.com/nvim-zh/better-escape.vim).
|
||||||
+ Ultra-fast project-wide fuzzy searching via [LeaderF](https://github.com/Yggdroot/LeaderF).
|
+ Ultra-fast project-wide fuzzy searching via [LeaderF](https://github.com/Yggdroot/LeaderF).
|
||||||
+ Faster code commenting via [vim-commentary](https://github.com/tpope/vim-commentary).
|
+ Faster code commenting via [vim-commentary](https://github.com/tpope/vim-commentary).
|
||||||
+ Faster matching pair insertion and jump via [delimitMate](https://github.com/Raimondi/delimitMate).
|
+ Faster matching pair insertion and jump via [delimitMate](https://github.com/Raimondi/delimitMate).
|
||||||
@@ -66,7 +69,7 @@ and how to set up on different platforms (Linux, macOS, and Windows).
|
|||||||
+ Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim).
|
+ Fast buffer jump via [hop.nvim](https://github.com/phaazon/hop.nvim).
|
||||||
+ Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
|
+ Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
|
||||||
+ Beautiful statusline via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
|
+ Beautiful statusline via [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim).
|
||||||
+ File tree explorer via [nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua).
|
+ File tree explorer via [nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua).
|
||||||
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
|
+ Better quickfix list with [nvim-bqf](https://github.com/kevinhwang91/nvim-bqf).
|
||||||
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
|
+ Show search index and count with [nvim-hlslens](https://github.com/kevinhwang91/nvim-hlslens).
|
||||||
+ Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim).
|
+ Command line auto-completion via [wilder.nvim](https://github.com/gelguy/wilder.nvim).
|
||||||
@@ -75,10 +78,9 @@ and how to set up on different platforms (Linux, macOS, and Windows).
|
|||||||
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
||||||
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
|
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
|
||||||
+ Beautiful colorscheme via [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material) and other colorschemes.
|
+ Beautiful colorscheme via [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material) and other colorschemes.
|
||||||
+ Markdown writing and previewing via [vim-markdown](https://github.com/plasticboy/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
|
+ Markdown writing and previewing via [vim-markdown](https://github.com/preservim/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
|
||||||
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
|
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex)
|
||||||
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
|
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
|
||||||
+ Smooth scroll experience via [neoscroll](https://github.com/karb94/neoscroll.nvim).
|
|
||||||
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
|
+ Tags navigation via [vista](https://github.com/liuchengxu/vista.vim).
|
||||||
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
|
+ Code formatting via [Neoformat](https://github.com/sbdchd/neoformat).
|
||||||
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
|
+ Undo management via [vim-mundo](https://github.com/simnalamburt/vim-mundo)
|
||||||
@@ -167,6 +169,8 @@ Some of the shortcuts I use frequently are listed here. In the following shortcu
|
|||||||
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
| `<leader>gc` | Normal | Linux/macOS/Win | Run git commit |
|
||||||
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
| `<leader>gpl` | Normal | Linux/macOS/Win | Run git pull |
|
||||||
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
| `<leader>gpu` | Normal | Linux/macOS/Win | Run git push |
|
||||||
|
| `<leader>gl` | Normal/Visual | Linux/macOS/Win | Get perm link for current/visually-select lines
|
||||||
|
| `<leader>gb` | Normal | macOS | Browse current git repo in browser
|
||||||
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
|
| `<F9>` | Normal | Linux/macOS/Win | Compile&run current source file (for C++, LaTeX, Lua, Python) |
|
||||||
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
| `<F11>` | Normal | Linux/macOS/Win | Toggle spell checking |
|
||||||
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
| `<F12>` | Normal | Linux/macOS/Win | Toggle paste mode |
|
||||||
@@ -212,5 +216,3 @@ You may also be interested in my posts on configuring Nvim:
|
|||||||
+ [Config nvim on Linux for Python development](https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/)
|
+ [Config nvim on Linux for Python development](https://jdhao.github.io/2018/12/24/centos_nvim_install_use_guide_en/)
|
||||||
+ [Nvim config on Windows 10](https://jdhao.github.io/2018/11/15/neovim_configuration_windows/)
|
+ [Nvim config on Windows 10](https://jdhao.github.io/2018/11/15/neovim_configuration_windows/)
|
||||||
+ [Nvim-qt config on Windows 10](https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/)
|
+ [Nvim-qt config on Windows 10](https://jdhao.github.io/2019/01/17/nvim_qt_settings_on_windows/)
|
||||||
|
|
||||||
<b id="f1">1:</b> Not enabled for Linux, you need to tweak [`lua/plugins.lua`](lua/plugins.lua) and change the condition for installing vimtex.[↩](#a1)
|
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
set commentstring=//\ %s
|
set commentstring=//\ %s
|
||||||
|
|
||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|
||||||
" Disable inserting comment leader after hitting o or O or <Enter>
|
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||||
set formatoptions-=o
|
set formatoptions-=o
|
||||||
set formatoptions-=r
|
set formatoptions-=r
|
||||||
|
|||||||
1
after/ftplugin/gitconfig.vim
Normal file
1
after/ftplugin/gitconfig.vim
Normal file
@@ -0,0 +1 @@
|
|||||||
|
set commentstring=#\ %s
|
||||||
@@ -1,8 +1,3 @@
|
|||||||
" Disable inserting comment leader after hitting o or O or <Enter>
|
" Disable inserting comment leader after hitting o or O or <Enter>
|
||||||
set formatoptions-=o
|
set formatoptions-=o
|
||||||
set formatoptions-=r
|
set formatoptions-=r
|
||||||
|
|
||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|||||||
@@ -2,12 +2,7 @@
|
|||||||
set formatoptions-=o
|
set formatoptions-=o
|
||||||
set formatoptions-=r
|
set formatoptions-=r
|
||||||
|
|
||||||
set tabstop=2 " number of visual spaces per TAB
|
nnoremap <buffer><silent> <F9> :luafile %<CR>
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|
||||||
nnoremap <silent> <F9> :luafile %<CR>
|
|
||||||
|
|
||||||
" For delimitMate
|
" For delimitMate
|
||||||
let b:delimitMate_matchpairs = "(:),[:],{:}"
|
let b:delimitMate_matchpairs = "(:),[:],{:}"
|
||||||
|
|||||||
@@ -8,5 +8,10 @@ set sidescroll=5
|
|||||||
set sidescrolloff=2
|
set sidescrolloff=2
|
||||||
set colorcolumn=100
|
set colorcolumn=100
|
||||||
|
|
||||||
|
set tabstop=4 " number of visual spaces per TAB
|
||||||
|
set softtabstop=4 " number of spaces in tab when editing
|
||||||
|
set shiftwidth=4 " number of spaces to use for autoindent
|
||||||
|
set expandtab " expand tab to spaces so that tabs are spaces
|
||||||
|
|
||||||
" For delimitMate
|
" For delimitMate
|
||||||
let b:delimitMate_matchpairs = "(:),[:],{:}"
|
let b:delimitMate_matchpairs = "(:),[:],{:}"
|
||||||
|
|||||||
1
after/ftplugin/sql.vim
Normal file
1
after/ftplugin/sql.vim
Normal file
@@ -0,0 +1 @@
|
|||||||
|
set commentstring=--\ %s
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|||||||
@@ -12,9 +12,4 @@ set foldmethod=expr foldexpr=utils#VimFolds(v:lnum) foldtext=utils#MyFoldText()
|
|||||||
" see `:h K` and https://stackoverflow.com/q/15867323/6064933
|
" see `:h K` and https://stackoverflow.com/q/15867323/6064933
|
||||||
set keywordprg=:help
|
set keywordprg=:help
|
||||||
|
|
||||||
set tabstop=2 " number of visual spaces per TAB
|
nnoremap <buffer><silent> <F9> :source %<CR>
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|
||||||
nnoremap <silent> <F9> :source %<CR>
|
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
set tabstop=2 " number of visual spaces per TAB
|
|
||||||
set softtabstop=2 " number of spaces in tab when editing
|
|
||||||
set shiftwidth=2 " number of spaces to use for autoindent
|
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
|
||||||
|
|
||||||
" Turn off syntax highlighting for large YAML files.
|
" Turn off syntax highlighting for large YAML files.
|
||||||
if line('$') > 500
|
if line('$') > 500
|
||||||
setlocal syntax=OFF
|
setlocal syntax=OFF
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
--- This module will load a random colorscheme on nvim startup process.
|
--- This module will load a random colorscheme on nvim startup process.
|
||||||
|
|
||||||
local utils = require('utils')
|
local utils = require("utils")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- Colorscheme to its directory name mapping, because colorscheme repo name is not necessarily
|
-- Colorscheme to its directory name mapping, because colorscheme repo name is not necessarily
|
||||||
-- the same as the colorscheme name itself.
|
-- the same as the colorscheme name itself.
|
||||||
M.colorscheme2dir = {
|
M.colorscheme2dir = {
|
||||||
gruvbox8 = "vim-gruvbox8",
|
onedark = "onedark.nvim",
|
||||||
onedark = 'onedark.nvim',
|
edge = "edge",
|
||||||
edge = 'edge',
|
sonokai = "sonokai",
|
||||||
sonokai = 'sonokai',
|
gruvbox_material = "gruvbox-material",
|
||||||
gruvbox_material = 'gruvbox-material',
|
nord = "nord.nvim",
|
||||||
nord = 'nord.nvim',
|
everforest = "everforest",
|
||||||
doom_one = 'doom-one.nvim',
|
nightfox = "nightfox.nvim",
|
||||||
everforest = 'everforest',
|
kanagawa = "kanagawa.nvim",
|
||||||
nightfox = 'nightfox.nvim',
|
catppuccin = "catppuccin",
|
||||||
kanagawa = 'kanagawa.nvim',
|
rose_pine = "rose-pine",
|
||||||
catppuccin = 'catppuccin'
|
onedarkpro = "onedarkpro.nvim",
|
||||||
|
monokai = "monokai.nvim",
|
||||||
|
material = "material.nvim",
|
||||||
}
|
}
|
||||||
|
|
||||||
M.gruvbox8 = function()
|
M.gruvbox8 = function()
|
||||||
@@ -28,57 +30,59 @@ M.gruvbox8 = function()
|
|||||||
vim.g.gruvbox_filetype_hi_groups = 1
|
vim.g.gruvbox_filetype_hi_groups = 1
|
||||||
vim.g.gruvbox_plugin_hi_groups = 1
|
vim.g.gruvbox_plugin_hi_groups = 1
|
||||||
|
|
||||||
vim.cmd [[colorscheme gruvbox8_hard]]
|
vim.cmd([[colorscheme gruvbox8_hard]])
|
||||||
end
|
end
|
||||||
|
|
||||||
M.onedark = function()
|
M.onedark = function()
|
||||||
vim.cmd [[colorscheme onedark]]
|
vim.cmd([[colorscheme onedark]])
|
||||||
end
|
end
|
||||||
|
|
||||||
M.edge = function()
|
M.edge = function()
|
||||||
vim.g.edge_enable_italic = 1
|
vim.g.edge_enable_italic = 1
|
||||||
vim.g.edge_better_performance = 1
|
vim.g.edge_better_performance = 1
|
||||||
|
|
||||||
vim.cmd [[colorscheme edge]]
|
vim.cmd([[colorscheme edge]])
|
||||||
end
|
end
|
||||||
|
|
||||||
M.sonokai = function()
|
M.sonokai = function()
|
||||||
vim.g.sonokai_enable_italic = 1
|
vim.g.sonokai_enable_italic = 1
|
||||||
vim.g.sonokai_better_performance = 1
|
vim.g.sonokai_better_performance = 1
|
||||||
|
|
||||||
vim.cmd [[colorscheme sonokai]]
|
vim.cmd([[colorscheme sonokai]])
|
||||||
end
|
end
|
||||||
|
|
||||||
M.gruvbox_material = function()
|
M.gruvbox_material = function()
|
||||||
|
-- foreground option can be material, mix, or original
|
||||||
|
vim.g.gruvbox_material_foreground = "material"
|
||||||
|
--background option can be hard, medium, soft
|
||||||
|
vim.g.gruvbox_material_background = "soft"
|
||||||
vim.g.gruvbox_material_enable_italic = 1
|
vim.g.gruvbox_material_enable_italic = 1
|
||||||
vim.g.gruvbox_material_better_performance = 1
|
vim.g.gruvbox_material_better_performance = 1
|
||||||
|
|
||||||
vim.cmd [[colorscheme gruvbox-material]]
|
vim.cmd([[colorscheme gruvbox-material]])
|
||||||
end
|
end
|
||||||
|
|
||||||
M.nord = function()
|
M.nord = function()
|
||||||
vim.cmd [[colorscheme nord]]
|
vim.cmd([[colorscheme nord]])
|
||||||
end
|
end
|
||||||
|
|
||||||
M.doom_one = function()
|
M.doom_one = function()
|
||||||
|
vim.cmd([[colorscheme doom-one]])
|
||||||
vim.cmd [[colorscheme doom-one]]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
M.everforest = function()
|
M.everforest = function()
|
||||||
vim.g.everforest_enable_italic = 1
|
vim.g.everforest_enable_italic = 1
|
||||||
vim.g.everforest_better_performance = 1
|
vim.g.everforest_better_performance = 1
|
||||||
|
|
||||||
vim.cmd [[colorscheme everforest]]
|
vim.cmd([[colorscheme everforest]])
|
||||||
end
|
end
|
||||||
|
|
||||||
M.nightfox = function()
|
M.nightfox = function()
|
||||||
vim.cmd [[colorscheme nordfox]]
|
vim.cmd([[colorscheme nordfox]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
M.kanagawa = function()
|
M.kanagawa = function()
|
||||||
vim.cmd [[colorscheme kanagawa]]
|
vim.cmd([[colorscheme kanagawa]])
|
||||||
end
|
end
|
||||||
|
|
||||||
M.catppuccin = function()
|
M.catppuccin = function()
|
||||||
@@ -87,17 +91,40 @@ M.catppuccin = function()
|
|||||||
|
|
||||||
require("catppuccin").setup()
|
require("catppuccin").setup()
|
||||||
|
|
||||||
vim.cmd [[colorscheme catppuccin]]
|
vim.cmd([[colorscheme catppuccin]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.rose_pine = function()
|
||||||
|
require('rose-pine').setup({
|
||||||
|
--- @usage 'main' | 'moon'
|
||||||
|
dark_variant = 'moon',
|
||||||
|
})
|
||||||
|
|
||||||
|
-- set colorscheme after options
|
||||||
|
vim.cmd('colorscheme rose-pine')
|
||||||
|
end
|
||||||
|
|
||||||
|
M.onedarkpro = function()
|
||||||
|
-- set colorscheme after options
|
||||||
|
vim.cmd('colorscheme onedark_vivid')
|
||||||
|
end
|
||||||
|
|
||||||
|
M.monokai = function()
|
||||||
|
vim.cmd('colorscheme monokai_pro')
|
||||||
|
end
|
||||||
|
|
||||||
|
M.material = function ()
|
||||||
|
vim.g.material_style = "oceanic"
|
||||||
|
vim.cmd('colorscheme material')
|
||||||
|
end
|
||||||
|
|
||||||
--- Use a random colorscheme from the pre-defined list of colorschemes.
|
--- Use a random colorscheme from the pre-defined list of colorschemes.
|
||||||
M.rand_colorscheme = function ()
|
M.rand_colorscheme = function()
|
||||||
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme2dir))
|
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme2dir))
|
||||||
|
|
||||||
if not vim.tbl_contains(vim.tbl_keys(M), colorscheme) then
|
if not vim.tbl_contains(vim.tbl_keys(M), colorscheme) then
|
||||||
local msg = "Invalid colorscheme: " .. colorscheme
|
local msg = "Invalid colorscheme: " .. colorscheme
|
||||||
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" })
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -107,7 +134,7 @@ M.rand_colorscheme = function ()
|
|||||||
|
|
||||||
if not status then
|
if not status then
|
||||||
local msg = string.format("Colorscheme %s is not installed. Run PackerSync to install.", colorscheme)
|
local msg = string.format("Colorscheme %s is not installed. Run PackerSync to install.", colorscheme)
|
||||||
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" })
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -115,10 +142,10 @@ M.rand_colorscheme = function ()
|
|||||||
-- Load the colorscheme and its settings
|
-- Load the colorscheme and its settings
|
||||||
M[colorscheme]()
|
M[colorscheme]()
|
||||||
|
|
||||||
if vim.g.logging_level == 'debug' then
|
if vim.g.logging_level == "debug" then
|
||||||
local msg = "Colorscheme: " .. colorscheme
|
local msg = "Colorscheme: " .. colorscheme
|
||||||
|
|
||||||
vim.notify(msg, vim.log.levels.DEBUG, { title = 'nvim-config' })
|
vim.notify(msg, vim.log.levels.DEBUG, { title = "nvim-config" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
75
core/globals.lua
Normal file
75
core/globals.lua
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
local fn = vim.fn
|
||||||
|
local api = vim.api
|
||||||
|
|
||||||
|
local utils = require('utils')
|
||||||
|
|
||||||
|
-- Inspect something
|
||||||
|
function _G.inspect(item)
|
||||||
|
vim.print(item)
|
||||||
|
end
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- custom variables --
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
vim.g.is_win = (utils.has("win32") or utils.has("win64")) and true or false
|
||||||
|
vim.g.is_linux = (utils.has("unix") and (not utils.has("macunix"))) and true or false
|
||||||
|
vim.g.is_mac = utils.has("macunix") and true or false
|
||||||
|
|
||||||
|
vim.g.logging_level = "info"
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- builtin variables --
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
vim.g.loaded_perl_provider = 0 -- Disable perl provider
|
||||||
|
vim.g.loaded_ruby_provider = 0 -- Disable ruby provider
|
||||||
|
vim.g.loaded_node_provider = 0 -- Disable node provider
|
||||||
|
vim.g.did_install_default_menus = 1 -- do not load menu
|
||||||
|
|
||||||
|
if utils.executable('python3') then
|
||||||
|
if vim.g.is_win then
|
||||||
|
vim.g.python3_host_prog = fn.substitute(fn.exepath("python3"), ".exe$", '', 'g')
|
||||||
|
else
|
||||||
|
vim.g.python3_host_prog = fn.exepath("python3")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
api.nvim_err_writeln("Python3 executable not found! You must install Python3 and set its PATH correctly!")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Custom mapping <leader> (see `:h mapleader` for more info)
|
||||||
|
vim.g.mapleader = ','
|
||||||
|
|
||||||
|
-- Enable highlighting for lua HERE doc inside vim script
|
||||||
|
vim.g.vimsyn_embed = 'l'
|
||||||
|
|
||||||
|
-- Use English as main language
|
||||||
|
vim.cmd [[language en_US.UTF-8]]
|
||||||
|
|
||||||
|
-- Disable loading certain plugins
|
||||||
|
|
||||||
|
-- Whether to load netrw by default, see https://github.com/bling/dotvim/issues/4
|
||||||
|
vim.g.loaded_netrw = 1
|
||||||
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
vim.g.netrw_liststyle = 3
|
||||||
|
if vim.g.is_win then
|
||||||
|
vim.g.netrw_http_cmd = "curl --ssl-no-revoke -Lo"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Do not load tohtml.vim
|
||||||
|
vim.g.loaded_2html_plugin = 1
|
||||||
|
|
||||||
|
-- Do not load zipPlugin.vim, gzip.vim and tarPlugin.vim (all these plugins are
|
||||||
|
-- related to checking files inside compressed files)
|
||||||
|
vim.g.loaded_zipPlugin = 1
|
||||||
|
vim.g.loaded_gzip = 1
|
||||||
|
vim.g.loaded_tarPlugin = 1
|
||||||
|
|
||||||
|
-- Do not load the tutor plugin
|
||||||
|
vim.g.loaded_tutor_mode_plugin = 1
|
||||||
|
|
||||||
|
-- Do not use builtin matchit.vim and matchparen.vim since we use vim-matchup
|
||||||
|
vim.g.loaded_matchit = 1
|
||||||
|
vim.g.loaded_matchparen = 1
|
||||||
|
|
||||||
|
-- Disable sql omni completion, it is broken.
|
||||||
|
vim.g.loaded_sql_completion = 1
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
"{ Global Variable
|
|
||||||
"{{ Custom variables
|
|
||||||
let g:is_win = (has('win32') || has('win64')) ? v:true : v:false
|
|
||||||
let g:is_linux = (has('unix') && !has('macunix')) ? v:true : v:false
|
|
||||||
let g:is_mac = has('macunix') ? v:true : v:false
|
|
||||||
let g:logging_level = 'info'
|
|
||||||
"}}
|
|
||||||
|
|
||||||
"{{ Builtin variables
|
|
||||||
" Disable perl provider
|
|
||||||
let g:loaded_perl_provider = 0
|
|
||||||
|
|
||||||
" Disable ruby provider
|
|
||||||
let g:loaded_ruby_provider = 0
|
|
||||||
|
|
||||||
" Disable node provider
|
|
||||||
let g:loaded_node_provider = 0
|
|
||||||
|
|
||||||
let g:did_install_default_menus = 1 " do not load menu
|
|
||||||
|
|
||||||
" Path to Python 3 interpreter (must be an absolute path), make startup
|
|
||||||
" faster. See https://neovim.io/doc/user/provider.html.
|
|
||||||
if executable('python')
|
|
||||||
if g:is_win
|
|
||||||
let g:python3_host_prog=substitute(exepath('python'), '.exe$', '', 'g')
|
|
||||||
elseif g:is_linux || g:is_mac
|
|
||||||
let g:python3_host_prog=exepath('python')
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
echoerr 'Python 3 executable not found! You must install Python 3 and set its PATH correctly!'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Custom mapping <leader> (see `:h mapleader` for more info)
|
|
||||||
let g:mapleader = ','
|
|
||||||
|
|
||||||
" Enable highlighting for lua HERE doc inside vim script
|
|
||||||
let g:vimsyn_embed = 'l'
|
|
||||||
|
|
||||||
" Use English as main language
|
|
||||||
if !g:is_mac
|
|
||||||
language en_US.utf-8
|
|
||||||
endif
|
|
||||||
|
|
||||||
" use filetype.lua instead of filetype.vim
|
|
||||||
let g:do_filetype_lua = 1
|
|
||||||
let g:did_load_filetypes = 0
|
|
||||||
"}}
|
|
||||||
|
|
||||||
"{{ Disable loading certain plugins
|
|
||||||
" Whether to load netrw by default, see
|
|
||||||
" https://github.com/bling/dotvim/issues/4
|
|
||||||
let g:loaded_netrw = 1
|
|
||||||
let g:loaded_netrwPlugin = 1
|
|
||||||
let g:netrw_liststyle = 3
|
|
||||||
if g:is_win
|
|
||||||
let g:netrw_http_cmd = 'curl --ssl-no-revoke -Lo'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Do not load tohtml.vim
|
|
||||||
let g:loaded_2html_plugin = 1
|
|
||||||
|
|
||||||
" Do not load zipPlugin.vim, gzip.vim and tarPlugin.vim (all these plugins are
|
|
||||||
" related to checking files inside compressed files)
|
|
||||||
let g:loaded_zipPlugin = 1
|
|
||||||
let loaded_gzip = 1
|
|
||||||
let g:loaded_tarPlugin = 1
|
|
||||||
|
|
||||||
let g:loaded_tutor_mode_plugin = 1 " do not load the tutor plugin
|
|
||||||
|
|
||||||
" Do not use builtin matchit.vim and matchparen.vim since we use vim-matchup
|
|
||||||
let g:loaded_matchit = 1
|
|
||||||
let g:loaded_matchparen = 1
|
|
||||||
"}}
|
|
||||||
|
|
||||||
" Disable sql omni completion, it is broken.
|
|
||||||
let g:loaded_sql_completion = 1
|
|
||||||
"}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local api = vim.api
|
local api = vim.api
|
||||||
|
local uv = vim.loop
|
||||||
|
|
||||||
-- Save key strokes (now we do not need to press shift to enter command mode).
|
-- Save key strokes (now we do not need to press shift to enter command mode).
|
||||||
keymap.set({ "n", "x" }, ";", ":")
|
keymap.set({ "n", "x" }, ";", ":")
|
||||||
@@ -8,33 +9,33 @@ keymap.set({ "n", "x" }, ";", ":")
|
|||||||
keymap.set("i", "<c-u>", "<Esc>viwUea")
|
keymap.set("i", "<c-u>", "<Esc>viwUea")
|
||||||
|
|
||||||
-- Turn the current word into title case
|
-- Turn the current word into title case
|
||||||
keymap.set("i", "<c-u>", "<Esc>b~lea")
|
keymap.set("i", "<c-t>", "<Esc>b~lea")
|
||||||
|
|
||||||
-- Paste non-linewise text above or below current line, see https://stackoverflow.com/a/1346777/6064933
|
-- Paste non-linewise text above or below current line, see https://stackoverflow.com/a/1346777/6064933
|
||||||
keymap.set("n", "<leader>p", "m`o<ESC>p``", { desc = "paste below current line", })
|
keymap.set("n", "<leader>p", "m`o<ESC>p``", { desc = "paste below current line" })
|
||||||
keymap.set("n", "<leader>P", "m`O<ESC>p``", { desc = "paste above current line", })
|
keymap.set("n", "<leader>P", "m`O<ESC>p``", { desc = "paste above current line" })
|
||||||
|
|
||||||
-- Shortcut for faster save and quit
|
-- Shortcut for faster save and quit
|
||||||
keymap.set("n", "<leader>w", "<cmd>update<cr>", { silent = true, desc = "save buffer", })
|
keymap.set("n", "<leader>w", "<cmd>update<cr>", { silent = true, desc = "save buffer" })
|
||||||
|
|
||||||
-- Saves the file if modified and quit
|
-- Saves the file if modified and quit
|
||||||
keymap.set("n", "<leader>q", "<cmd>x<cr>", { silent = true, desc = "quit current window" })
|
keymap.set("n", "<leader>q", "<cmd>x<cr>", { silent = true, desc = "quit current window" })
|
||||||
|
|
||||||
-- Quit all opened buffers
|
-- Quit all opened buffers
|
||||||
keymap.set("n", "<leader>Q", "<cmd>qa!<cr>", { silent = true, desc = "quit nvim", })
|
keymap.set("n", "<leader>Q", "<cmd>qa!<cr>", { silent = true, desc = "quit nvim" })
|
||||||
|
|
||||||
-- Navigation in the location and quickfix list
|
-- Navigation in the location and quickfix list
|
||||||
keymap.set("n", "[l", "<cmd>lprevious<cr>zv", { silent = true, desc = "previous location item", })
|
keymap.set("n", "[l", "<cmd>lprevious<cr>zv", { silent = true, desc = "previous location item" })
|
||||||
keymap.set("n", "]l", "<cmd>lnext<cr>zv", { silent = true, desc = "next location item", })
|
keymap.set("n", "]l", "<cmd>lnext<cr>zv", { silent = true, desc = "next location item" })
|
||||||
|
|
||||||
keymap.set("n", "[L", "<cmd>lfirst<cr>zv", { silent = true, desc = "first location item", })
|
keymap.set("n", "[L", "<cmd>lfirst<cr>zv", { silent = true, desc = "first location item" })
|
||||||
keymap.set("n", "]L", "<cmd>llast<cr>zv", { silent = true, desc = "last location item", })
|
keymap.set("n", "]L", "<cmd>llast<cr>zv", { silent = true, desc = "last location item" })
|
||||||
|
|
||||||
keymap.set("n", "[q", "<cmd>cprevious<cr>zv", { silent = true, desc = "previous qf item", })
|
keymap.set("n", "[q", "<cmd>cprevious<cr>zv", { silent = true, desc = "previous qf item" })
|
||||||
keymap.set("n", "]q", "<cmd>cnext<cr>zv", { silent = true, desc = "next qf item", })
|
keymap.set("n", "]q", "<cmd>cnext<cr>zv", { silent = true, desc = "next qf item" })
|
||||||
|
|
||||||
keymap.set("n", "[Q", "<cmd>cfirst<cr>zv", { silent = true, desc = "first qf item", })
|
keymap.set("n", "[Q", "<cmd>cfirst<cr>zv", { silent = true, desc = "first qf item" })
|
||||||
keymap.set("n", "]Q", "<cmd>clast<cr>zv", { silent = true, desc = "last qf item", })
|
keymap.set("n", "]Q", "<cmd>clast<cr>zv", { silent = true, desc = "last qf item" })
|
||||||
|
|
||||||
-- Close location list or quickfix list if they are present, see https://superuser.com/q/355325/736190
|
-- Close location list or quickfix list if they are present, see https://superuser.com/q/355325/736190
|
||||||
keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", {
|
keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", {
|
||||||
@@ -85,16 +86,15 @@ keymap.set("n", "<leader>ev", "<cmd>tabnew $MYVIMRC <bar> tcd %:h<cr>", {
|
|||||||
desc = "open init.lua",
|
desc = "open init.lua",
|
||||||
})
|
})
|
||||||
|
|
||||||
keymap.set("n", "<leader>sv", "", {
|
keymap.set("n", "<leader>sv", function()
|
||||||
silent = true,
|
vim.cmd([[
|
||||||
desc = "reload init.lua",
|
|
||||||
callback = function()
|
|
||||||
vim.cmd [[
|
|
||||||
update $MYVIMRC
|
update $MYVIMRC
|
||||||
source $MYVIMRC
|
source $MYVIMRC
|
||||||
]]
|
]])
|
||||||
vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
|
vim.notify("Nvim config successfully reloaded!", vim.log.levels.INFO, { title = "nvim-config" })
|
||||||
end,
|
end, {
|
||||||
|
silent = true,
|
||||||
|
desc = "reload init.lua",
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
|
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
|
||||||
@@ -111,14 +111,14 @@ keymap.set("n", "/", [[/\v]])
|
|||||||
|
|
||||||
-- Change current working directory locally and print cwd after that,
|
-- Change current working directory locally and print cwd after that,
|
||||||
-- see https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file
|
-- see https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file
|
||||||
keymap.set("n", "<leader>cd", "<cmd>lcd %:p:h<cr><cmd>pwd<cr>", { desc = "change cwd", })
|
keymap.set("n", "<leader>cd", "<cmd>lcd %:p:h<cr><cmd>pwd<cr>", { desc = "change cwd" })
|
||||||
|
|
||||||
-- Use Esc to quit builtin terminal
|
-- Use Esc to quit builtin terminal
|
||||||
keymap.set("t", "<Esc>", [[<c-\><c-n>]])
|
keymap.set("t", "<Esc>", [[<c-\><c-n>]])
|
||||||
|
|
||||||
-- Toggle spell checking
|
-- Toggle spell checking
|
||||||
keymap.set("n", "<F11>", "<cmd>set spell!<cr>", { desc = "toggle spell", })
|
keymap.set("n", "<F11>", "<cmd>set spell!<cr>", { desc = "toggle spell" })
|
||||||
keymap.set("i", "<F11>", "<c-o><cmd>set spell!<cr>", { desc = "toggle spell", })
|
keymap.set("i", "<F11>", "<c-o><cmd>set spell!<cr>", { desc = "toggle spell" })
|
||||||
|
|
||||||
-- Change text without putting it into the vim register,
|
-- Change text without putting it into the vim register,
|
||||||
-- see https://stackoverflow.com/q/54255/6064933
|
-- see https://stackoverflow.com/q/54255/6064933
|
||||||
@@ -128,25 +128,25 @@ keymap.set("n", "cc", '"_cc')
|
|||||||
keymap.set("x", "c", '"_c')
|
keymap.set("x", "c", '"_c')
|
||||||
|
|
||||||
-- Remove trailing whitespace characters
|
-- Remove trailing whitespace characters
|
||||||
keymap.set("n", "<leader><space>", "<cmd>StripTrailingWhitespace<cr>", { desc = "remove trailing space", })
|
keymap.set("n", "<leader><space>", "<cmd>StripTrailingWhitespace<cr>", { desc = "remove trailing space" })
|
||||||
|
|
||||||
-- check the syntax group of current cursor position
|
-- check the syntax group of current cursor position
|
||||||
keymap.set("n", "<leader>st", "<cmd>call utils#SynGroup()<cr>", { desc = "check syntax group", })
|
keymap.set("n", "<leader>st", "<cmd>call utils#SynGroup()<cr>", { desc = "check syntax group" })
|
||||||
|
|
||||||
-- Copy entire buffer.
|
-- Copy entire buffer.
|
||||||
keymap.set("n", "<leader>y", "<cmd>%yank<cr>", { desc = "yank entire buffer", })
|
keymap.set("n", "<leader>y", "<cmd>%yank<cr>", { desc = "yank entire buffer" })
|
||||||
|
|
||||||
-- Toggle cursor column
|
-- Toggle cursor column
|
||||||
keymap.set("n", "<leader>cl", "<cmd>call utils#ToggleCursorCol()<cr>", { desc = "toggle cursor column", })
|
keymap.set("n", "<leader>cl", "<cmd>call utils#ToggleCursorCol()<cr>", { desc = "toggle cursor column" })
|
||||||
|
|
||||||
-- Move current line up and down
|
-- Move current line up and down
|
||||||
keymap.set("n", "<A-k>", '<cmd>call utils#SwitchLine(line("."), "up")<cr>', { desc = "move line up", })
|
keymap.set("n", "<A-k>", '<cmd>call utils#SwitchLine(line("."), "up")<cr>', { desc = "move line up" })
|
||||||
keymap.set("n", "<A-j>", '<cmd>call utils#SwitchLine(line("."), "down")<cr>', { desc = "move line down", })
|
keymap.set("n", "<A-j>", '<cmd>call utils#SwitchLine(line("."), "down")<cr>', { desc = "move line down" })
|
||||||
|
|
||||||
-- Move current visual-line selection up and down
|
-- Move current visual-line selection up and down
|
||||||
keymap.set("x", "<A-k>", '<cmd>call utils#MoveSelection("up")<cr>', { desc = "move selection up", })
|
keymap.set("x", "<A-k>", '<cmd>call utils#MoveSelection("up")<cr>', { desc = "move selection up" })
|
||||||
|
|
||||||
keymap.set("x", "<A-j>", '<cmd>call utils#MoveSelection("down")<cr>', { desc = "move selection down", })
|
keymap.set("x", "<A-j>", '<cmd>call utils#MoveSelection("down")<cr>', { desc = "move selection down" })
|
||||||
|
|
||||||
-- Replace visual selection with text in register, but not contaminate the register,
|
-- Replace visual selection with text in register, but not contaminate the register,
|
||||||
-- see also https://stackoverflow.com/q/10723700/6064933.
|
-- see also https://stackoverflow.com/q/10723700/6064933.
|
||||||
@@ -167,62 +167,79 @@ keymap.set("n", "<Up>", "<C-W>k")
|
|||||||
keymap.set("n", "<Down>", "<C-W>j")
|
keymap.set("n", "<Down>", "<C-W>j")
|
||||||
|
|
||||||
-- Text objects for URL
|
-- Text objects for URL
|
||||||
keymap.set({ "x", "o" }, "iu", "<cmd>call text_obj#URL()<cr>", { desc = "URL text object", })
|
keymap.set({ "x", "o" }, "iu", "<cmd>call text_obj#URL()<cr>", { desc = "URL text object" })
|
||||||
|
|
||||||
-- Text objects for entire buffer
|
-- Text objects for entire buffer
|
||||||
keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object", })
|
keymap.set({ "x", "o" }, "iB", "<cmd>call text_obj#Buffer()<cr>", { desc = "buffer text object" })
|
||||||
|
|
||||||
-- Do not move my cursor when joining lines.
|
-- Do not move my cursor when joining lines.
|
||||||
keymap.set("n", "J", "", {
|
keymap.set("n", "J", function()
|
||||||
desc = "join line",
|
vim.cmd([[
|
||||||
callback = function()
|
|
||||||
vim.cmd [[
|
|
||||||
normal! mzJ`z
|
normal! mzJ`z
|
||||||
delmarks z
|
delmarks z
|
||||||
]]
|
]])
|
||||||
end,
|
end, {
|
||||||
|
desc = "join line",
|
||||||
})
|
})
|
||||||
|
|
||||||
keymap.set("n", "gJ", "mzgJ`z", {
|
keymap.set("n", "gJ", function()
|
||||||
desc = "join visual lines",
|
-- we must use `normal!`, otherwise it will trigger recursive mapping
|
||||||
callback = function()
|
vim.cmd([[
|
||||||
-- we must use `normal!`, otherwise it will trigger recursive mapping
|
|
||||||
vim.cmd [[
|
|
||||||
normal! zmgJ`z
|
normal! zmgJ`z
|
||||||
delmarks z
|
delmarks z
|
||||||
]]
|
]])
|
||||||
end
|
end, {
|
||||||
|
desc = "join visual lines",
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Break inserted text into smaller undo units when we insert some punctuation chars.
|
-- Break inserted text into smaller undo units when we insert some punctuation chars.
|
||||||
local undo_ch = { ',', '.', '!', '?', ';', ':' }
|
local undo_ch = { ",", ".", "!", "?", ";", ":" }
|
||||||
for _, ch in ipairs(undo_ch) do
|
for _, ch in ipairs(undo_ch) do
|
||||||
keymap.set('i', ch, ch .. '<c-g>u')
|
keymap.set("i", ch, ch .. "<c-g>u")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- insert semicolon in the end
|
-- insert semicolon in the end
|
||||||
keymap.set('i', '<A-;>', '<Esc>miA;<Esc>`ii')
|
keymap.set("i", "<A-;>", "<Esc>miA;<Esc>`ii")
|
||||||
|
|
||||||
-- Keep cursor position after yanking
|
-- Keep cursor position after yanking
|
||||||
keymap.set('n', 'y', 'myy')
|
keymap.set("n", "y", "myy")
|
||||||
|
|
||||||
api.nvim_create_autocmd('TextYankPost', {
|
api.nvim_create_autocmd("TextYankPost", {
|
||||||
pattern = '*',
|
pattern = "*",
|
||||||
group = api.nvim_create_augroup("restore_after_yank", { clear = true }),
|
group = api.nvim_create_augroup("restore_after_yank", { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.cmd [[
|
vim.cmd([[
|
||||||
silent! normal! `y
|
silent! normal! `y
|
||||||
silent! delmarks y
|
silent! delmarks y
|
||||||
]]
|
]])
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Go to the beginning and end of current line in insert mode quickly
|
-- Go to the beginning and end of current line in insert mode quickly
|
||||||
keymap.set('i', '<C-A>', '<HOME>')
|
keymap.set("i", "<C-A>", "<HOME>")
|
||||||
keymap.set('i', '<C-E>', '<END>')
|
keymap.set("i", "<C-E>", "<END>")
|
||||||
|
|
||||||
-- Go to beginning of command in command-line mode
|
-- Go to beginning of command in command-line mode
|
||||||
keymap.set('c', '<C-A>', '<HOME>')
|
keymap.set("c", "<C-A>", "<HOME>")
|
||||||
|
|
||||||
-- Delete the character to the right of the cursor
|
-- Delete the character to the right of the cursor
|
||||||
keymap.set('i', '<C-D>', '<DEL>')
|
keymap.set("i", "<C-D>", "<DEL>")
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>cb", function()
|
||||||
|
local cnt = 0
|
||||||
|
local blink_times = 7
|
||||||
|
local timer = uv.new_timer()
|
||||||
|
|
||||||
|
timer:start(0, 100, vim.schedule_wrap(function()
|
||||||
|
vim.cmd[[
|
||||||
|
set cursorcolumn!
|
||||||
|
set cursorline!
|
||||||
|
]]
|
||||||
|
|
||||||
|
if cnt == blink_times then
|
||||||
|
timer:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
cnt = cnt + 1
|
||||||
|
end))
|
||||||
|
end)
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ scriptencoding utf-8
|
|||||||
" change fillchars for folding, vertical split, end of buffer, and message separator
|
" change fillchars for folding, vertical split, end of buffer, and message separator
|
||||||
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾
|
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾
|
||||||
|
|
||||||
" Paste mode toggle, it seems that Nvim's bracketed paste mode
|
|
||||||
" does not work very well for nvim-qt, so we use good-old paste mode
|
|
||||||
set pastetoggle=<F12>
|
|
||||||
|
|
||||||
" Split window below/right when creating horizontal/vertical windows
|
" Split window below/right when creating horizontal/vertical windows
|
||||||
set splitbelow splitright
|
set splitbelow splitright
|
||||||
|
|
||||||
@@ -44,9 +40,9 @@ set backup " create backup for files
|
|||||||
set backupcopy=yes " copy the original file to backupdir and overwrite it
|
set backupcopy=yes " copy the original file to backupdir and overwrite it
|
||||||
|
|
||||||
" General tab settings
|
" General tab settings
|
||||||
set tabstop=4 " number of visual spaces per TAB
|
set tabstop=2 " number of visual spaces per TAB
|
||||||
set softtabstop=4 " number of spaces in tab when editing
|
set softtabstop=2 " number of spaces in tab when editing
|
||||||
set shiftwidth=4 " number of spaces to use for autoindent
|
set shiftwidth=2 " number of spaces to use for autoindent
|
||||||
set expandtab " expand tab to spaces so that tabs are spaces
|
set expandtab " expand tab to spaces so that tabs are spaces
|
||||||
|
|
||||||
" Set matching pairs of characters and highlight matching brackets
|
" Set matching pairs of characters and highlight matching brackets
|
||||||
@@ -75,6 +71,7 @@ set scrolloff=3
|
|||||||
" Use mouse to select and resize windows, etc.
|
" Use mouse to select and resize windows, etc.
|
||||||
set mouse=nic " Enable mouse in several mode
|
set mouse=nic " Enable mouse in several mode
|
||||||
set mousemodel=popup " Set the behaviour of mouse
|
set mousemodel=popup " Set the behaviour of mouse
|
||||||
|
set mousescroll=ver:1,hor:6
|
||||||
|
|
||||||
" Disable showing current mode on command line since statusline plugins can show it.
|
" Disable showing current mode on command line since statusline plugins can show it.
|
||||||
set noshowmode
|
set noshowmode
|
||||||
@@ -144,7 +141,7 @@ set formatoptions+=mM
|
|||||||
" Tilde (~) is an operator, thus must be followed by motions like `e` or `w`.
|
" Tilde (~) is an operator, thus must be followed by motions like `e` or `w`.
|
||||||
set tildeop
|
set tildeop
|
||||||
|
|
||||||
set synmaxcol=200 " Text after this column number is not highlighted
|
set synmaxcol=250 " Text after this column number is not highlighted
|
||||||
set nostartofline
|
set nostartofline
|
||||||
|
|
||||||
" External program to use for grep command
|
" External program to use for grep command
|
||||||
@@ -162,7 +159,7 @@ set termguicolors
|
|||||||
" https://github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-color-in-the-terminal
|
" https://github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-color-in-the-terminal
|
||||||
set guicursor=n-v-c:block-Cursor/lCursor,i-ci-ve:ver25-Cursor2/lCursor2,r-cr:hor20,o:hor20
|
set guicursor=n-v-c:block-Cursor/lCursor,i-ci-ve:ver25-Cursor2/lCursor2,r-cr:hor20,o:hor20
|
||||||
|
|
||||||
set signcolumn=auto:2
|
set signcolumn=yes:1
|
||||||
|
|
||||||
" Remove certain character from file name pattern matching
|
" Remove certain character from file name pattern matching
|
||||||
set isfname-==
|
set isfname-==
|
||||||
@@ -175,5 +172,7 @@ set diffopt+=filler " show filler for deleted lines
|
|||||||
set diffopt+=closeoff " turn off diff when one file window is closed
|
set diffopt+=closeoff " turn off diff when one file window is closed
|
||||||
set diffopt+=context:3 " context for diff
|
set diffopt+=context:3 " context for diff
|
||||||
set diffopt+=internal,indent-heuristic,algorithm:histogram
|
set diffopt+=internal,indent-heuristic,algorithm:histogram
|
||||||
|
set diffopt+=linematch:60
|
||||||
|
|
||||||
set nowrap " do no wrap
|
set nowrap " do no wrap
|
||||||
|
set noruler
|
||||||
|
|||||||
@@ -137,31 +137,6 @@ let g:mundo_width = 80
|
|||||||
|
|
||||||
nnoremap <silent> <Space>u :MundoToggle<CR>
|
nnoremap <silent> <Space>u :MundoToggle<CR>
|
||||||
|
|
||||||
""""""""""""""""""""""""""""vim-yoink settings"""""""""""""""""""""""""
|
|
||||||
if g:is_win || g:is_mac
|
|
||||||
" ctrl-n and ctrl-p will not work if you add the TextChanged event to vim-auto-save events.
|
|
||||||
" nmap <c-n> <plug>(YoinkPostPasteSwapBack)
|
|
||||||
" nmap <c-p> <plug>(YoinkPostPasteSwapForward)
|
|
||||||
|
|
||||||
" The following p/P mappings are also needed for ctrl-n and ctrl-p to work
|
|
||||||
" nmap p <plug>(YoinkPaste_p)
|
|
||||||
" nmap P <plug>(YoinkPaste_P)
|
|
||||||
|
|
||||||
" Cycle the yank stack with the following mappings
|
|
||||||
nmap [y <plug>(YoinkRotateBack)
|
|
||||||
nmap ]y <plug>(YoinkRotateForward)
|
|
||||||
|
|
||||||
" Do not change the cursor position
|
|
||||||
nmap y <plug>(YoinkYankPreserveCursorPosition)
|
|
||||||
xmap y <plug>(YoinkYankPreserveCursorPosition)
|
|
||||||
|
|
||||||
" Move cursor to end of paste after multiline paste
|
|
||||||
let g:yoinkMoveCursorToEndOfPaste = 0
|
|
||||||
|
|
||||||
" Record yanks in system clipboard
|
|
||||||
let g:yoinkSyncSystemClipboardOnFocus = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
""""""""""""""""""""""""""""better-escape.vim settings"""""""""""""""""""""""""
|
""""""""""""""""""""""""""""better-escape.vim settings"""""""""""""""""""""""""
|
||||||
let g:better_escape_interval = 200
|
let g:better_escape_interval = 200
|
||||||
|
|
||||||
@@ -182,14 +157,7 @@ let g:neoformat_c_clangformat = {
|
|||||||
let g:neoformat_enabled_cpp = ['clangformat']
|
let g:neoformat_enabled_cpp = ['clangformat']
|
||||||
let g:neoformat_enabled_c = ['clangformat']
|
let g:neoformat_enabled_c = ['clangformat']
|
||||||
|
|
||||||
"""""""""""""""""""""""""vim-signify settings""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""vim-markdown settings"""""""""""""""""""
|
||||||
" The VCS to use
|
|
||||||
let g:signify_vcs_list = [ 'git' ]
|
|
||||||
|
|
||||||
" Change the sign for certain operations
|
|
||||||
let g:signify_sign_change = '~'
|
|
||||||
|
|
||||||
"""""""""""""""""""""""""plasticboy/vim-markdown settings"""""""""""""""""""
|
|
||||||
" Disable header folding
|
" Disable header folding
|
||||||
let g:vim_markdown_folding_disabled = 1
|
let g:vim_markdown_folding_disabled = 1
|
||||||
|
|
||||||
@@ -250,7 +218,7 @@ nmap s <Nop>
|
|||||||
omap s <Nop>
|
omap s <Nop>
|
||||||
|
|
||||||
""""""""""""""""""""""""""""vimtex settings"""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""vimtex settings"""""""""""""""""""""""""""""
|
||||||
if ( g:is_win || g:is_mac ) && executable('latex')
|
if executable('latex')
|
||||||
" Hacks for inverse search to work semi-automatically,
|
" Hacks for inverse search to work semi-automatically,
|
||||||
" see https://jdhao.github.io/2021/02/20/inverse_search_setup_neovim_vimtex/.
|
" see https://jdhao.github.io/2021/02/20/inverse_search_setup_neovim_vimtex/.
|
||||||
function! s:write_server_name() abort
|
function! s:write_server_name() abort
|
||||||
@@ -311,11 +279,6 @@ if ( g:is_win || g:is_mac ) && executable('latex')
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
""""""""""""""""""""""""""""vim-startify settings""""""""""""""""""""""""""""
|
|
||||||
" Do not change working directory when opening files.
|
|
||||||
let g:startify_change_to_dir = 0
|
|
||||||
let g:startify_fortune_use_unicode = 1
|
|
||||||
|
|
||||||
""""""""""""""""""""""""""""vim-matchup settings"""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""vim-matchup settings"""""""""""""""""""""""""""""
|
||||||
" Improve performance
|
" Improve performance
|
||||||
let g:matchup_matchparen_deferred = 1
|
let g:matchup_matchparen_deferred = 1
|
||||||
@@ -362,16 +325,20 @@ if exists('g:started_by_firenvim') && g:started_by_firenvim
|
|||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
function! s:setup_firenvim() abort
|
function s:setup_firenvim() abort
|
||||||
set noruler noshowcmd
|
set signcolumn=no
|
||||||
set laststatus=0 showtabline=0
|
set noruler
|
||||||
|
set noshowcmd
|
||||||
|
set laststatus=0
|
||||||
|
set showtabline=0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
augroup firenvim
|
augroup firenvim
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType text call s:setup_firenvim()
|
autocmd BufEnter * call s:setup_firenvim()
|
||||||
autocmd BufNewFile github.com_*.txt set filetype=markdown
|
autocmd BufEnter sqlzoo*.txt set filetype=sql
|
||||||
autocmd BufNewFile stackoverflow.com_*.txt set filetype=markdown
|
autocmd BufEnter github.com_*.txt set filetype=markdown
|
||||||
|
autocmd BufEnter stackoverflow.com_*.txt set filetype=markdown
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ fi
|
|||||||
|
|
||||||
# Install some Python packages used by Nvim plugins.
|
# Install some Python packages used by Nvim plugins.
|
||||||
echo "Installing Python packages"
|
echo "Installing Python packages"
|
||||||
declare -a py_packages=("pynvim" 'python-lsp-server[all]' "black" "vim-vint" "pyls-isort" "pylsp-mypy")
|
declare -a PY_PACKAGES=("pynvim" 'python-lsp-server[all]' "black" "vim-vint" "pyls-isort" "pylsp-mypy")
|
||||||
|
|
||||||
if [[ "$SYSTEM_PYTHON" = true ]]; then
|
if [[ "$SYSTEM_PYTHON" = true ]]; then
|
||||||
echo "Using system Python to install $(PY_PACKAGES)"
|
echo "Using system Python to install $(PY_PACKAGES)"
|
||||||
@@ -76,12 +76,12 @@ if [[ "$SYSTEM_PYTHON" = true ]]; then
|
|||||||
# If we use system Python, we need to install these Python packages under
|
# If we use system Python, we need to install these Python packages under
|
||||||
# user HOME, since we do not have permissions to install them under system
|
# user HOME, since we do not have permissions to install them under system
|
||||||
# directories.
|
# directories.
|
||||||
for p in "${py_packages[@]}"; do
|
for p in "${PY_PACKAGES[@]}"; do
|
||||||
pip install --user "$p"
|
pip install --user "$p"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo "Using custom Python to install $(PY_PACKAGES)"
|
echo "Using custom Python to install $(PY_PACKAGES)"
|
||||||
for p in "${py_packages[@]}"; do
|
for p in "${PY_PACKAGES[@]}"; do
|
||||||
"$CONDA_DIR/bin/pip" install "$p"
|
"$CONDA_DIR/bin/pip" install "$p"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@@ -124,27 +124,27 @@ fi
|
|||||||
#######################################################################
|
#######################################################################
|
||||||
# lua-language-server #
|
# lua-language-server #
|
||||||
#######################################################################
|
#######################################################################
|
||||||
SUMNEKO_LUA_DIR=$HOME/tools/lua-language-server
|
LUA_LS_DIR=$HOME/tools/lua-language-server
|
||||||
SUMNEKO_LUA_SRC_NAME=$HOME/packages/lua-language-server.tar.gz
|
LUA_LS_SRC=$HOME/packages/lua-language-server.tar.gz
|
||||||
SUMNEKO_LUA_LINK="https://github.com/sumneko/lua-language-server/releases/download/3.5.3/lua-language-server-3.5.3-linux-x64.tar.gz"
|
LUA_LS_LINK="https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-linux-x64.tar.gz"
|
||||||
|
|
||||||
if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$SUMNEKO_LUA_DIR/bin/lua-language-server" ]]; then
|
if [[ -z "$(command -v lua-language-server)" ]] && [[ ! -f "$LUA_LS_DIR/bin/lua-language-server" ]]; then
|
||||||
echo 'Install lua-language-server'
|
echo 'Install lua-language-server'
|
||||||
if [[ ! -f $SUMNEKO_LUA_SRC_NAME ]]; then
|
if [[ ! -f $LUA_LS_SRC ]]; then
|
||||||
echo "Downloading lua-language-server and renaming"
|
echo "Downloading lua-language-server and renaming"
|
||||||
wget $SUMNEKO_LUA_LINK -O "$SUMNEKO_LUA_SRC_NAME"
|
wget $LUA_LS_LINK -O "$LUA_LS_SRC"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d "$SUMNEKO_LUA_DIR" ]]; then
|
if [[ ! -d "$LUA_LS_DIR" ]]; then
|
||||||
echo "Creating lua-language-server directory under tools directory"
|
echo "Creating lua-language-server directory under tools directory"
|
||||||
mkdir -p "$SUMNEKO_LUA_DIR"
|
mkdir -p "$LUA_LS_DIR"
|
||||||
echo "Extracting to directory $SUMNEKO_LUA_DIR"
|
echo "Extracting to directory $LUA_LS_DIR"
|
||||||
|
|
||||||
tar zxvf "$SUMNEKO_LUA_SRC_NAME" -C "$SUMNEKO_LUA_DIR"
|
tar zxvf "$LUA_LS_SRC" -C "$LUA_LS_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then
|
if [[ "$ADD_TO_SYSTEM_PATH" = true ]] && [[ "$USE_BASH_SHELL" = true ]]; then
|
||||||
echo "export PATH=\"$SUMNEKO_LUA_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
|
echo "export PATH=\"$LUA_LS_DIR/bin:\$PATH\"" >> "$HOME/.bash_profile"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "lua-language-server is already installed. Skip installing it."
|
echo "lua-language-server is already installed. Skip installing it."
|
||||||
|
|||||||
@@ -36,19 +36,19 @@ scoop install vcredist2022
|
|||||||
scoop install 7zip
|
scoop install 7zip
|
||||||
|
|
||||||
# Install lua-language-server
|
# Install lua-language-server
|
||||||
$sumneko_lua_link = "https://github.com/sumneko/lua-language-server/releases/download/3.5.3/lua-language-server-3.5.3-win32-x64.zip"
|
$lua_ls_link = "https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-win32-x64.zip"
|
||||||
$sumneko_lua_install_dir = "D:\portable_tools"
|
$lua_ls_install_dir = "D:\portable_tools"
|
||||||
$sumneko_lua_src_dir = "$sumneko_lua_install_dir\lua-language-server.zip"
|
$lua_ls_src_path = "$lua_ls_install_dir\lua-language-server.zip"
|
||||||
$sumneko_lua_dir = "$sumneko_lua_install_dir\lua-language-server"
|
$lua_ls_dir = "$lua_ls_install_dir\lua-language-server"
|
||||||
|
|
||||||
# Download file, ref: https://stackoverflow.com/a/51225744/6064933
|
# Download file, ref: https://stackoverflow.com/a/51225744/6064933
|
||||||
Invoke-WebRequest $sumneko_lua_link -OutFile "$sumneko_lua_src_dir"
|
Invoke-WebRequest $lua_ls_link -OutFile "$lua_ls_src_path"
|
||||||
|
|
||||||
# Extract the zip file using 7zip, ref: https://stackoverflow.com/a/41933215/6064933
|
# Extract the zip file using 7zip, ref: https://stackoverflow.com/a/41933215/6064933
|
||||||
7z x "$sumneko_lua_src_dir" -o"$sumneko_lua_dir"
|
7z x "$lua_ls_src_path" -o"$lua_ls_dir"
|
||||||
|
|
||||||
# Setup PATH env variable, ref: https://stackoverflow.com/q/714877/6064933
|
# Setup PATH env variable, ref: https://stackoverflow.com/q/714877/6064933
|
||||||
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$sumneko_lua_dir\bin", "Machine")
|
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$lua_ls_dir\bin", "Machine")
|
||||||
|
|
||||||
# Install neovim nightly
|
# Install neovim nightly
|
||||||
scoop bucket add versions
|
scoop bucket add versions
|
||||||
|
|||||||
30
init.lua
30
init.lua
@@ -4,35 +4,39 @@
|
|||||||
-- I would not recommend cloning this repo and replace your own config. Good configurations are personal,
|
-- I would not recommend cloning this repo and replace your own config. Good configurations are personal,
|
||||||
-- built over time with a lot of polish.
|
-- built over time with a lot of polish.
|
||||||
--
|
--
|
||||||
-- Author: Jie-dong Hao
|
-- Author: Jiedong Hao
|
||||||
-- Email: jdhao@hotmail.com
|
-- Email: jdhao@hotmail.com
|
||||||
-- Blog: https://jdhao.github.io/
|
-- Blog: https://jdhao.github.io/
|
||||||
|
-- GitHub: https://github.com/jdhao
|
||||||
|
-- StackOverflow: https://stackoverflow.com/users/6064933/jdhao
|
||||||
|
|
||||||
local api = vim.api
|
local api = vim.api
|
||||||
local utils = require "utils"
|
local version = vim.version
|
||||||
|
|
||||||
-- check if we have the latest stable version of nvim
|
-- check if we have the latest stable version of nvim
|
||||||
local expected_ver = "0.7.2"
|
local expected_ver = "0.9.0"
|
||||||
local nvim_ver = utils.get_nvim_version()
|
local ev = version.parse(expected_ver)
|
||||||
|
local actual_ver = version()
|
||||||
|
|
||||||
if nvim_ver ~= expected_ver then
|
if version.cmp(ev, actual_ver) ~= 0 then
|
||||||
local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver)
|
local _ver = string.format("%s.%s.%s", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
||||||
|
local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, _ver)
|
||||||
api.nvim_err_writeln(msg)
|
api.nvim_err_writeln(msg)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local core_conf_files = {
|
local core_conf_files = {
|
||||||
"globals.vim", -- some global settings
|
"globals.lua", -- some global settings
|
||||||
"options.vim", -- setting options in nvim
|
"options.vim", -- setting options in nvim
|
||||||
"autocommands.vim", -- various autocommands
|
"autocommands.vim", -- various autocommands
|
||||||
"mappings.lua", -- all the user-defined mappings
|
"mappings.lua", -- all the user-defined mappings
|
||||||
"plugins.vim", -- all the plugins installed and their configurations
|
"plugins.vim", -- all the plugins installed and their configurations
|
||||||
"colorschemes.lua", -- colorscheme settings
|
"colorschemes.lua", -- colorscheme settings
|
||||||
}
|
}
|
||||||
|
|
||||||
-- source all the core config files
|
-- source all the core config files
|
||||||
for _, name in ipairs(core_conf_files) do
|
for _, name in ipairs(core_conf_files) do
|
||||||
local path = string.format("%s/core/%s", vim.fn.stdpath('config'), name)
|
local path = string.format("%s/core/%s", vim.fn.stdpath("config"), name)
|
||||||
local source_cmd = "source " .. path
|
local source_cmd = "source " .. path
|
||||||
vim.cmd(source_cmd)
|
vim.cmd(source_cmd)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require("bqf").setup({
|
require("bqf").setup {
|
||||||
auto_resize_height = false,
|
auto_resize_height = false,
|
||||||
preview = {
|
preview = {
|
||||||
auto_preview = false,
|
auto_preview = false,
|
||||||
}
|
},
|
||||||
})
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require("bufferline").setup({
|
require("bufferline").setup {
|
||||||
options = {
|
options = {
|
||||||
numbers = "buffer_id",
|
numbers = "buffer_id",
|
||||||
close_command = "bdelete! %d",
|
close_command = "bdelete! %d",
|
||||||
@@ -6,8 +6,8 @@ require("bufferline").setup({
|
|||||||
left_mouse_command = "buffer %d",
|
left_mouse_command = "buffer %d",
|
||||||
middle_mouse_command = nil,
|
middle_mouse_command = nil,
|
||||||
indicator = {
|
indicator = {
|
||||||
icon = '▎', -- this should be omitted if indicator style is not 'icon'
|
icon = "▎", -- this should be omitted if indicator style is not 'icon'
|
||||||
style = 'icon',
|
style = "icon",
|
||||||
},
|
},
|
||||||
buffer_close_icon = "",
|
buffer_close_icon = "",
|
||||||
modified_icon = "●",
|
modified_icon = "●",
|
||||||
@@ -43,4 +43,4 @@ require("bufferline").setup({
|
|||||||
always_show_bufferline = true,
|
always_show_bufferline = true,
|
||||||
sort_by = "id",
|
sort_by = "id",
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
local api = vim.api
|
||||||
|
local keymap = vim.keymap
|
||||||
local dashboard = require("dashboard")
|
local dashboard = require("dashboard")
|
||||||
|
|
||||||
dashboard.custom_header = {
|
dashboard.custom_header = {
|
||||||
@@ -52,14 +54,15 @@ dashboard.custom_center = {
|
|||||||
desc = "Quit Nvim ",
|
desc = "Quit Nvim ",
|
||||||
-- desc = "Quit Nvim ",
|
-- desc = "Quit Nvim ",
|
||||||
action = "qa",
|
action = "qa",
|
||||||
shortcut = "q "
|
shortcut = "q ",
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.cmd([[
|
api.nvim_create_autocmd("FileType", {
|
||||||
augroup dashboard_enter
|
pattern = "dashboard",
|
||||||
au!
|
group = api.nvim_create_augroup("dashboard_enter", { clear = true }),
|
||||||
autocmd FileType dashboard nnoremap <buffer> q :qa<CR>
|
callback = function ()
|
||||||
autocmd FileType dashboard nnoremap <buffer> e :enew<CR>
|
keymap.set("n", "q", ":qa<CR>", { buffer = true, silent = true })
|
||||||
augroup END
|
keymap.set("n", "e", ":enew<CR>", { buffer = true, silent = true })
|
||||||
]])
|
end
|
||||||
|
})
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
require"fidget".setup{}
|
require("fidget").setup {}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
|
|
||||||
keymap.set('n', '<leader>gs', '<cmd>Git<cr>', { desc = 'Git status' })
|
keymap.set("n", "<leader>gs", "<cmd>Git<cr>", { desc = "Git status" })
|
||||||
keymap.set('n', '<leader>gw', '<cmd>Gwrite<cr>', { desc = 'Git add' })
|
keymap.set("n", "<leader>gw", "<cmd>Gwrite<cr>", { desc = "Git add" })
|
||||||
keymap.set('n', '<leader>gc', '<cmd>Git commit<cr>', { desc = 'Git commit' })
|
keymap.set("n", "<leader>gc", "<cmd>Git commit<cr>", { desc = "Git commit" })
|
||||||
keymap.set('n', '<leader>gd', '<cmd>Gdiffsplit<cr>', { desc = 'Git diff' })
|
keymap.set("n", "<leader>gd", "<cmd>Gdiffsplit<cr>", { desc = "Git diff" })
|
||||||
keymap.set('n', '<leader>gpl', '<cmd>Git pull<cr>', { desc = 'Git pull' })
|
keymap.set("n", "<leader>gpl", "<cmd>Git pull<cr>", { desc = "Git pull" })
|
||||||
keymap.set('n', '<leader>gpu', '<cmd>15 split|term git push<cr>', { desc = 'Git push' })
|
keymap.set("n", "<leader>gpu", "<cmd>15 split|term git push<cr>", { desc = "Git push" })
|
||||||
|
|
||||||
|
-- convert git to Git in command line mode
|
||||||
|
vim.fn['utils#Cabbrev']('git', 'Git')
|
||||||
|
|||||||
@@ -1,15 +1,25 @@
|
|||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local gitlinker = require('gitlinker')
|
local gitlinker = require("gitlinker")
|
||||||
|
|
||||||
gitlinker.setup({
|
gitlinker.setup {
|
||||||
mappings = nil,
|
mappings = nil,
|
||||||
})
|
}
|
||||||
|
|
||||||
keymap.set({ 'n', 'v' }, '<leader>gl', '', {
|
keymap.set({ "n", "v" }, "<leader>gl", "", {
|
||||||
silent = true,
|
silent = true,
|
||||||
desc = "get git permlink",
|
desc = "get git permlink",
|
||||||
callback = function()
|
callback = function()
|
||||||
local mode = string.lower(vim.fn.mode())
|
local mode = string.lower(vim.fn.mode())
|
||||||
gitlinker.get_buf_range_url(mode)
|
gitlinker.get_buf_range_url(mode)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
keymap.set("n", "<leader>gb", "", {
|
||||||
|
silent = true,
|
||||||
|
desc = "browse repo in browser",
|
||||||
|
callback = function()
|
||||||
|
gitlinker.get_repo_url({
|
||||||
|
action_callback = gitlinker.actions.open_in_browser
|
||||||
|
})
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local gs = require "gitsigns"
|
local gs = require("gitsigns")
|
||||||
|
|
||||||
gs.setup {
|
gs.setup {
|
||||||
signs = {
|
signs = {
|
||||||
@@ -8,7 +8,7 @@ gs.setup {
|
|||||||
topdelete = { hl = "GitSignsDelete", text = "‾", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
topdelete = { hl = "GitSignsDelete", text = "‾", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
|
||||||
changedelete = { hl = "GitSignsChange", text = "│", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
|
changedelete = { hl = "GitSignsChange", text = "│", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
|
||||||
},
|
},
|
||||||
word_diff = true, -- Toggle with `:Gitsigns toggle_word_diff`
|
word_diff = true,
|
||||||
on_attach = function(bufnr)
|
on_attach = function(bufnr)
|
||||||
local function map(mode, l, r, opts)
|
local function map(mode, l, r, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
@@ -25,7 +25,7 @@ gs.setup {
|
|||||||
gs.next_hunk()
|
gs.next_hunk()
|
||||||
end)
|
end)
|
||||||
return "<Ignore>"
|
return "<Ignore>"
|
||||||
end, { expr = true, desc = 'next hunk' })
|
end, { expr = true, desc = "next hunk" })
|
||||||
|
|
||||||
map("n", "[c", function()
|
map("n", "[c", function()
|
||||||
if vim.wo.diff then
|
if vim.wo.diff then
|
||||||
@@ -35,10 +35,23 @@ gs.setup {
|
|||||||
gs.prev_hunk()
|
gs.prev_hunk()
|
||||||
end)
|
end)
|
||||||
return "<Ignore>"
|
return "<Ignore>"
|
||||||
end, { expr = true, desc = 'previous hunk' })
|
end, { expr = true, desc = "previous hunk" })
|
||||||
|
|
||||||
-- Actions
|
-- Actions
|
||||||
map("n", "<leader>hp", gs.preview_hunk)
|
map("n", "<leader>hp", gs.preview_hunk)
|
||||||
map("n", "<leader>hb", function() gs.blame_line { full = true } end)
|
map("n", "<leader>hb", function()
|
||||||
|
gs.blame_line { full = true }
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('ColorScheme', {
|
||||||
|
pattern = "*",
|
||||||
|
callback = function()
|
||||||
|
vim.cmd [[
|
||||||
|
hi GitSignsChangeInline gui=reverse
|
||||||
|
hi GitSignsAddInline gui=reverse
|
||||||
|
hi GitSignsDeleteInline gui=reverse
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
local api = vim.api
|
local api = vim.api
|
||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
|
|
||||||
local hlslens = require('hlslens')
|
local hlslens = require("hlslens")
|
||||||
|
|
||||||
hlslens.setup({
|
hlslens.setup {
|
||||||
calm_down = true,
|
calm_down = true,
|
||||||
nearest_only = true,
|
nearest_only = true,
|
||||||
})
|
}
|
||||||
|
|
||||||
local activate_hlslens = function(direction)
|
local activate_hlslens = function(direction)
|
||||||
local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction)
|
local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction)
|
||||||
@@ -22,13 +22,27 @@ local activate_hlslens = function(direction)
|
|||||||
hlslens.start()
|
hlslens.start()
|
||||||
end
|
end
|
||||||
|
|
||||||
keymap.set('n', 'n', '', {
|
keymap.set("n", "n", "", {
|
||||||
callback = function() activate_hlslens('n') end
|
callback = function()
|
||||||
|
activate_hlslens("n")
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
keymap.set('n', 'N', '', {
|
keymap.set("n", "N", "", {
|
||||||
callback = function() activate_hlslens('N') end
|
callback = function()
|
||||||
|
activate_hlslens("N")
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
keymap.set('n', '*', "<Plug>(asterisk-z*)<Cmd>lua require('hlslens').start()<CR>")
|
keymap.set("n", "*", "", {
|
||||||
keymap.set('n', '#', "<Plug>(asterisk-z#)<Cmd>lua require('hlslens').start()<CR>")
|
callback = function()
|
||||||
|
vim.fn.execute("normal! *N")
|
||||||
|
hlslens.start()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
keymap.set("n", "#", "", {
|
||||||
|
callback = function()
|
||||||
|
vim.fn.execute("normal! #N")
|
||||||
|
hlslens.start()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local api = vim.api
|
local api = vim.api
|
||||||
|
|
||||||
local exclude_ft = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" }
|
local exclude_ft = { "help", "git", "markdown", "snippets", "text", "gitconfig", "alpha" }
|
||||||
require("indent_blankline").setup({
|
require("indent_blankline").setup {
|
||||||
-- U+2502 may also be a good choice, it will be on the middle of cursor.
|
-- U+2502 may also be a good choice, it will be on the middle of cursor.
|
||||||
-- U+250A is also a good choice
|
-- U+250A is also a good choice
|
||||||
char = "▏",
|
char = "▏",
|
||||||
@@ -9,13 +9,13 @@ require("indent_blankline").setup({
|
|||||||
disable_with_nolist = true,
|
disable_with_nolist = true,
|
||||||
buftype_exclude = { "terminal" },
|
buftype_exclude = { "terminal" },
|
||||||
filetype_exclude = exclude_ft,
|
filetype_exclude = exclude_ft,
|
||||||
})
|
}
|
||||||
|
|
||||||
local gid = api.nvim_create_augroup("indent_blankline", { clear = true })
|
local gid = api.nvim_create_augroup("indent_blankline", { clear = true })
|
||||||
api.nvim_create_autocmd("InsertEnter", {
|
api.nvim_create_autocmd("InsertEnter", {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
group = gid,
|
group = gid,
|
||||||
command = "IndentBlanklineDisable"
|
command = "IndentBlanklineDisable",
|
||||||
})
|
})
|
||||||
|
|
||||||
api.nvim_create_autocmd("InsertLeave", {
|
api.nvim_create_autocmd("InsertLeave", {
|
||||||
@@ -23,7 +23,7 @@ api.nvim_create_autocmd("InsertLeave", {
|
|||||||
group = gid,
|
group = gid,
|
||||||
callback = function()
|
callback = function()
|
||||||
if not vim.tbl_contains(exclude_ft, vim.bo.filetype) then
|
if not vim.tbl_contains(exclude_ft, vim.bo.filetype) then
|
||||||
vim.cmd [[IndentBlanklineEnable]]
|
vim.cmd([[IndentBlanklineEnable]])
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local iron = require("iron")
|
local iron = require("iron")
|
||||||
iron.core.set_config({
|
iron.core.set_config {
|
||||||
preferred = {
|
preferred = {
|
||||||
python = "ipython",
|
python = "ipython",
|
||||||
},
|
},
|
||||||
repl_open_cmd = "vertical 120 split",
|
repl_open_cmd = "vertical 120 split",
|
||||||
})
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local fn = vim.fn
|
|||||||
local api = vim.api
|
local api = vim.api
|
||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local lsp = vim.lsp
|
local lsp = vim.lsp
|
||||||
|
local diagnostic = vim.diagnostic
|
||||||
|
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
|
|
||||||
@@ -14,37 +15,36 @@ local custom_attach = function(client, bufnr)
|
|||||||
keymap.set(mode, l, r, opts)
|
keymap.set(mode, l, r, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
map("n", "gd", vim.lsp.buf.definition, {desc = 'go to definition'})
|
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
|
||||||
map("n", "<C-]>", vim.lsp.buf.definition)
|
map("n", "<C-]>", vim.lsp.buf.definition)
|
||||||
map("n", "K", vim.lsp.buf.hover)
|
map("n", "K", vim.lsp.buf.hover)
|
||||||
map("n", "<C-k>", vim.lsp.buf.signature_help)
|
map("n", "<C-k>", vim.lsp.buf.signature_help)
|
||||||
map("n", "<space>rn", vim.lsp.buf.rename, { desc = 'varialbe rename' })
|
map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
|
||||||
map("n", "gr", vim.lsp.buf.references, { desc = 'show references' })
|
map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
|
||||||
map("n", "[d", vim.diagnostic.goto_prev, { desc = 'previous diagnostic' })
|
map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" })
|
||||||
map("n", "]d", vim.diagnostic.goto_next, { desc = 'next diagnostic' })
|
map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" })
|
||||||
map("n", "<space>q", function() vim.diagnostic.setqflist({open = true}) end, { desc = 'put diagnostic to qf' })
|
map("n", "<space>q", diagnostic.setqflist, { desc = "put diagnostic to qf" })
|
||||||
map("n", "<space>ca", vim.lsp.buf.code_action, { desc = 'LSP code action' })
|
map("n", "<space>ca", vim.lsp.buf.code_action, { desc = "LSP code action" })
|
||||||
map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = 'add workspace folder' } )
|
map("n", "<space>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
|
||||||
map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = 'remove workspace folder' })
|
map("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
|
||||||
map("n", "<space>wl", function() inspect(vim.lsp.buf.list_workspace_folders()) end, { desc = 'list workspace folder' })
|
map("n", "<space>wl", function()
|
||||||
|
inspect(vim.lsp.buf.list_workspace_folders())
|
||||||
|
end, { desc = "list workspace folder" })
|
||||||
|
|
||||||
-- Set some key bindings conditional on server capabilities
|
-- Set some key bindings conditional on server capabilities
|
||||||
if client.resolved_capabilities.document_formatting then
|
if client.server_capabilities.documentFormattingProvider then
|
||||||
map("n", "<space>f", vim.lsp.buf.formatting_sync, { desc = 'format code' })
|
map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" })
|
||||||
end
|
|
||||||
if client.resolved_capabilities.document_range_formatting then
|
|
||||||
map("x", "<space>f", vim.lsp.buf.range_formatting, { desc = 'range format' })
|
|
||||||
end
|
end
|
||||||
|
|
||||||
api.nvim_create_autocmd("CursorHold", {
|
api.nvim_create_autocmd("CursorHold", {
|
||||||
buffer=bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
local float_opts = {
|
local float_opts = {
|
||||||
focusable = false,
|
focusable = false,
|
||||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||||
border = 'rounded',
|
border = "rounded",
|
||||||
source = 'always', -- show source in diagnostic popup window
|
source = "always", -- show source in diagnostic popup window
|
||||||
prefix = ' '
|
prefix = " ",
|
||||||
}
|
}
|
||||||
|
|
||||||
if not vim.b.diagnostics_pos then
|
if not vim.b.diagnostics_pos then
|
||||||
@@ -52,44 +52,54 @@ local custom_attach = function(client, bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local cursor_pos = api.nvim_win_get_cursor(0)
|
local cursor_pos = api.nvim_win_get_cursor(0)
|
||||||
if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2]) and
|
if (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
|
||||||
#vim.diagnostic.get() > 0
|
and #diagnostic.get() > 0
|
||||||
then
|
then
|
||||||
vim.diagnostic.open_float(nil, float_opts)
|
diagnostic.open_float(nil, float_opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.b.diagnostics_pos = cursor_pos
|
vim.b.diagnostics_pos = cursor_pos
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- The blow command will highlight the current variable and its usages in the buffer.
|
-- The blow command will highlight the current variable and its usages in the buffer.
|
||||||
if client.resolved_capabilities.document_highlight then
|
if client.server_capabilities.documentHighlightProvider then
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
hi! link LspReferenceRead Visual
|
hi! link LspReferenceRead Visual
|
||||||
hi! link LspReferenceText Visual
|
hi! link LspReferenceText Visual
|
||||||
hi! link LspReferenceWrite Visual
|
hi! link LspReferenceWrite Visual
|
||||||
augroup lsp_document_highlight
|
|
||||||
autocmd! * <buffer>
|
|
||||||
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
|
||||||
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
|
||||||
augroup END
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||||
|
api.nvim_create_autocmd("CursorHold" , {
|
||||||
|
group = gid,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function ()
|
||||||
|
lsp.buf.document_highlight()
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("CursorMoved" , {
|
||||||
|
group = gid,
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = function ()
|
||||||
|
lsp.buf.clear_references()
|
||||||
|
end
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.g.logging_level == 'debug' then
|
if vim.g.logging_level == "debug" then
|
||||||
local msg = string.format("Language server %s started!", client.name)
|
local msg = string.format("Language server %s started!", client.name)
|
||||||
vim.notify(msg, vim.log.levels.DEBUG, {title = 'Nvim-config'})
|
vim.notify(msg, vim.log.levels.DEBUG, { title = "Nvim-config" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local capabilities = lsp.protocol.make_client_capabilities()
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
if utils.executable('pylsp') then
|
if utils.executable("pylsp") then
|
||||||
lspconfig.pylsp.setup({
|
lspconfig.pylsp.setup {
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
settings = {
|
settings = {
|
||||||
pylsp = {
|
pylsp = {
|
||||||
@@ -107,9 +117,9 @@ if utils.executable('pylsp') then
|
|||||||
debounce_text_changes = 200,
|
debounce_text_changes = 200,
|
||||||
},
|
},
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
})
|
}
|
||||||
else
|
else
|
||||||
vim.notify("pylsp not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
|
vim.notify("pylsp not found!", vim.log.levels.WARN, { title = "Nvim-config" })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if utils.executable('pyright') then
|
-- if utils.executable('pyright') then
|
||||||
@@ -121,43 +131,55 @@ end
|
|||||||
-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
|
-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
if utils.executable('clangd') then
|
if utils.executable("ltex-ls") then
|
||||||
lspconfig.clangd.setup({
|
lspconfig.ltex.setup {
|
||||||
|
on_attach = custom_attach,
|
||||||
|
cmd = { "ltex-ls" },
|
||||||
|
filetypes = { "text", "plaintex", "tex", "markdown" },
|
||||||
|
settings = {
|
||||||
|
ltex = {
|
||||||
|
language = "en"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
flags = { debounce_text_changes = 300 },
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
if utils.executable("clangd") then
|
||||||
|
lspconfig.clangd.setup {
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
filetypes = { "c", "cpp", "cc" },
|
filetypes = { "c", "cpp", "cc" },
|
||||||
flags = {
|
flags = {
|
||||||
debounce_text_changes = 500,
|
debounce_text_changes = 500,
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
else
|
|
||||||
vim.notify("clangd not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set up vim-language-server
|
-- set up vim-language-server
|
||||||
if utils.executable('vim-language-server') then
|
if utils.executable("vim-language-server") then
|
||||||
lspconfig.vimls.setup({
|
lspconfig.vimls.setup {
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
flags = {
|
flags = {
|
||||||
debounce_text_changes = 500,
|
debounce_text_changes = 500,
|
||||||
},
|
},
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
})
|
}
|
||||||
else
|
else
|
||||||
vim.notify("vim-language-server not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
|
vim.notify("vim-language-server not found!", vim.log.levels.WARN, { title = "Nvim-config" })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set up bash-language-server
|
-- set up bash-language-server
|
||||||
if utils.executable('bash-language-server') then
|
if utils.executable("bash-language-server") then
|
||||||
lspconfig.bashls.setup({
|
lspconfig.bashls.setup {
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
})
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if utils.executable("lua-language-server") then
|
if utils.executable("lua-language-server") then
|
||||||
-- settings for lua-language-server can be found on https://github.com/sumneko/lua-language-server/wiki/Settings .
|
-- settings for lua-language-server can be found on https://github.com/LuaLS/lua-language-server/wiki/Settings .
|
||||||
lspconfig.sumneko_lua.setup({
|
lspconfig.lua_ls.setup {
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
@@ -171,11 +193,11 @@ if utils.executable("lua-language-server") then
|
|||||||
},
|
},
|
||||||
workspace = {
|
workspace = {
|
||||||
-- Make the server aware of Neovim runtime files,
|
-- Make the server aware of Neovim runtime files,
|
||||||
-- see also https://github.com/sumneko/lua-language-server/wiki/Libraries#link-to-workspace .
|
-- see also https://github.com/LuaLS/lua-language-server/wiki/Libraries#link-to-workspace .
|
||||||
-- Lua-dev.nvim also has similar settings for sumneko lua, https://github.com/folke/lua-dev.nvim/blob/main/lua/lua-dev/sumneko.lua .
|
-- Lua-dev.nvim also has similar settings for lua ls, https://github.com/folke/neodev.nvim/blob/main/lua/neodev/luals.lua .
|
||||||
library = {
|
library = {
|
||||||
fn.stdpath('data') .. "/site/pack/packer/opt/emmylua-nvim",
|
fn.stdpath("data") .. "/site/pack/packer/opt/emmylua-nvim",
|
||||||
fn.stdpath('config'),
|
fn.stdpath("config"),
|
||||||
},
|
},
|
||||||
maxPreload = 2000,
|
maxPreload = 2000,
|
||||||
preloadFileSize = 50000,
|
preloadFileSize = 50000,
|
||||||
@@ -183,7 +205,7 @@ if utils.executable("lua-language-server") then
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
})
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Change diagnostic signs.
|
-- Change diagnostic signs.
|
||||||
@@ -193,12 +215,12 @@ fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "Diagnostic
|
|||||||
fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
|
||||||
|
|
||||||
-- global config for diagnostic
|
-- global config for diagnostic
|
||||||
vim.diagnostic.config({
|
diagnostic.config {
|
||||||
underline = false,
|
underline = false,
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
signs = true,
|
signs = true,
|
||||||
severity_sort = true,
|
severity_sort = true,
|
||||||
})
|
}
|
||||||
|
|
||||||
-- lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(lsp.diagnostic.on_publish_diagnostics, {
|
-- lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(lsp.diagnostic.on_publish_diagnostics, {
|
||||||
-- underline = false,
|
-- underline = false,
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
require("neoscroll").setup({
|
|
||||||
easing_function = "quadratic",
|
|
||||||
})
|
|
||||||
|
|
||||||
local t = {}
|
|
||||||
-- Syntax: t[keys] = {function, {function arguments}}
|
|
||||||
-- Use the "sine" easing function
|
|
||||||
t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "20", [['cubic']] } }
|
|
||||||
t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "20", [['cubic']] } }
|
|
||||||
-- Use the "circular" easing function
|
|
||||||
t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } }
|
|
||||||
t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } }
|
|
||||||
-- Pass "nil" to disable the easing animation (constant scrolling speed)
|
|
||||||
t["<C-y>"] = { "scroll", { "-0.10", "false", "100", nil } }
|
|
||||||
t["<C-e>"] = { "scroll", { "0.10", "false", "100", nil } }
|
|
||||||
-- When no easing function is provided the default easing function (in this case "quadratic") will be used
|
|
||||||
t["zt"] = { "zt", { "10" } }
|
|
||||||
t["zz"] = { "zz", { "10" } }
|
|
||||||
t["zb"] = { "zb", { "10" } }
|
|
||||||
|
|
||||||
require("neoscroll.config").set_mappings(t)
|
|
||||||
@@ -1,54 +1,53 @@
|
|||||||
-- Setup nvim-cmp.
|
-- Setup nvim-cmp.
|
||||||
local cmp = require'cmp'
|
local cmp = require("cmp")
|
||||||
local lspkind = require'lspkind'
|
local lspkind = require("lspkind")
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup {
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
-- For `ultisnips` user.
|
-- For `ultisnips` user.
|
||||||
vim.fn["UltiSnips#Anon"](args.body)
|
vim.fn["UltiSnips#Anon"](args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert {
|
||||||
['<Tab>'] = function(fallback)
|
["<Tab>"] = function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
['<S-Tab>'] = function(fallback)
|
["<S-Tab>"] = function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||||
['<C-e>'] = cmp.mapping.abort(),
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
['<Esc>'] = cmp.mapping.close(),
|
["<Esc>"] = cmp.mapping.close(),
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
}),
|
},
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' }, -- For nvim-lsp
|
{ name = "nvim_lsp" }, -- For nvim-lsp
|
||||||
{ name = 'ultisnips' }, -- For ultisnips user.
|
{ name = "ultisnips" }, -- For ultisnips user.
|
||||||
{ name = 'path' }, -- for path completion
|
{ name = "path" }, -- for path completion
|
||||||
{ name = 'buffer', keyword_length = 2 }, -- for buffer word completion
|
{ name = "buffer", keyword_length = 2 }, -- for buffer word completion
|
||||||
{ name = 'omni' },
|
{ name = "emoji", insert = true }, -- emoji completion
|
||||||
{ name = 'emoji', insert = true, } -- emoji completion
|
|
||||||
},
|
},
|
||||||
completion = {
|
completion = {
|
||||||
keyword_length = 1,
|
keyword_length = 1,
|
||||||
completeopt = "menu,noselect"
|
completeopt = "menu,noselect",
|
||||||
},
|
},
|
||||||
view = {
|
view = {
|
||||||
entries = 'custom',
|
entries = "custom",
|
||||||
},
|
},
|
||||||
formatting = {
|
formatting = {
|
||||||
format = lspkind.cmp_format({
|
format = lspkind.cmp_format {
|
||||||
mode = "symbol_text",
|
mode = "symbol_text",
|
||||||
menu = ({
|
menu = {
|
||||||
nvim_lsp = "[LSP]",
|
nvim_lsp = "[LSP]",
|
||||||
ultisnips = "[US]",
|
ultisnips = "[US]",
|
||||||
nvim_lua = "[Lua]",
|
nvim_lua = "[Lua]",
|
||||||
@@ -56,13 +55,22 @@ cmp.setup({
|
|||||||
buffer = "[Buffer]",
|
buffer = "[Buffer]",
|
||||||
emoji = "[Emoji]",
|
emoji = "[Emoji]",
|
||||||
omni = "[Omni]",
|
omni = "[Omni]",
|
||||||
}),
|
},
|
||||||
}),
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cmp.setup.filetype("tex", {
|
||||||
|
sources = {
|
||||||
|
{ name = "omni" },
|
||||||
|
{ name = "ultisnips" }, -- For ultisnips user.
|
||||||
|
{ name = "buffer", keyword_length = 2 }, -- for buffer word completion
|
||||||
|
{ name = "path" }, -- for path completion
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
|
-- see https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-dark-theme-colors-to-the-menu
|
||||||
vim.cmd[[
|
vim.cmd([[
|
||||||
highlight! link CmpItemMenu Comment
|
highlight! link CmpItemMenu Comment
|
||||||
" gray
|
" gray
|
||||||
highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080
|
highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080
|
||||||
@@ -80,4 +88,4 @@ vim.cmd[[
|
|||||||
highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4
|
highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4
|
||||||
highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4
|
highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4
|
||||||
highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4
|
highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4
|
||||||
]]
|
]])
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
local nvim_notify = require("notify")
|
local nvim_notify = require("notify")
|
||||||
nvim_notify.setup({
|
nvim_notify.setup {
|
||||||
-- Animation style
|
-- Animation style
|
||||||
stages = "fade_in_slide_out",
|
stages = "fade_in_slide_out",
|
||||||
-- Default timeout for notifications
|
-- Default timeout for notifications
|
||||||
timeout = 1500,
|
timeout = 1500,
|
||||||
background_colour = "#2E3440",
|
background_colour = "#2E3440",
|
||||||
})
|
}
|
||||||
|
|
||||||
vim.notify = nvim_notify
|
vim.notify = nvim_notify
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local nvim_tree = require("nvim-tree")
|
local nvim_tree = require("nvim-tree")
|
||||||
|
|
||||||
nvim_tree.setup({
|
nvim_tree.setup {
|
||||||
auto_reload_on_write = true,
|
auto_reload_on_write = true,
|
||||||
disable_netrw = false,
|
disable_netrw = false,
|
||||||
hijack_cursor = false,
|
hijack_cursor = false,
|
||||||
hijack_netrw = true,
|
hijack_netrw = true,
|
||||||
hijack_unnamed_buffer_when_opening = false,
|
hijack_unnamed_buffer_when_opening = false,
|
||||||
ignore_buffer_on_setup = false,
|
|
||||||
open_on_setup = false,
|
|
||||||
open_on_setup_file = false,
|
|
||||||
open_on_tab = false,
|
open_on_tab = false,
|
||||||
sort_by = "name",
|
sort_by = "name",
|
||||||
update_cwd = false,
|
update_cwd = false,
|
||||||
view = {
|
view = {
|
||||||
width = 30,
|
width = 30,
|
||||||
height = 30,
|
|
||||||
hide_root_folder = false,
|
hide_root_folder = false,
|
||||||
side = "left",
|
side = "left",
|
||||||
preserve_window_proportions = false,
|
preserve_window_proportions = false,
|
||||||
@@ -51,7 +47,6 @@ nvim_tree.setup({
|
|||||||
update_cwd = false,
|
update_cwd = false,
|
||||||
ignore_list = {},
|
ignore_list = {},
|
||||||
},
|
},
|
||||||
ignore_ft_on_setup = {},
|
|
||||||
system_open = {
|
system_open = {
|
||||||
cmd = "",
|
cmd = "",
|
||||||
args = {},
|
args = {},
|
||||||
@@ -112,9 +107,9 @@ nvim_tree.setup({
|
|||||||
profile = false,
|
profile = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
keymap.set('n', '<space>s', function()
|
keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
|
||||||
return require('nvim-tree').toggle(false, true)
|
silent = true,
|
||||||
end,
|
desc = "toggle nvim-tree",
|
||||||
{ silent = true, desc = "toggle nvim-tree" })
|
})
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
vim.cmd [[hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff]]
|
vim.cmd([[hi HopNextKey cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff]])
|
||||||
vim.cmd [[hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff]]
|
vim.cmd([[hi HopNextKey1 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff]])
|
||||||
vim.cmd [[hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff]]
|
vim.cmd([[hi HopNextKey2 cterm=bold ctermfg=176 gui=bold guibg=#ff00ff guifg=#ffffff]])
|
||||||
|
|
||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local hop = require "hop"
|
local hop = require("hop")
|
||||||
hop.setup({
|
hop.setup {
|
||||||
case_insensitive = true,
|
case_insensitive = true,
|
||||||
char2_fallback_key = "<CR>",
|
char2_fallback_key = "<CR>",
|
||||||
quit_key = "<Esc>",
|
quit_key = "<Esc>",
|
||||||
})
|
}
|
||||||
|
|
||||||
keymap.set({ "n", "v", "o" }, "f", "", {
|
keymap.set({ "n", "v", "o" }, "f", "", {
|
||||||
silent = true,
|
silent = true,
|
||||||
|
|||||||
@@ -8,12 +8,18 @@ local function spell()
|
|||||||
return ""
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- show indicator for Chinese IME
|
||||||
local function ime_state()
|
local function ime_state()
|
||||||
if vim.g.is_mac then
|
if vim.g.is_mac then
|
||||||
-- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
|
-- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11
|
||||||
local layout = fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '')
|
local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "")
|
||||||
if layout == '0' then
|
|
||||||
return '[CN]'
|
-- We can use `xkbswitch -g` on the command line to get current mode.
|
||||||
|
-- mode for macOS builtin pinyin IME: com.apple.inputmethod.SCIM.ITABC
|
||||||
|
-- mode for Rime: im.rime.inputmethod.Squirrel.Rime
|
||||||
|
local res = fn.match(layout, [[\v(Squirrel\.Rime|SCIM.ITABC)]])
|
||||||
|
if res ~= -1 then
|
||||||
|
return "[CN]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -27,7 +33,7 @@ local function trailing_space()
|
|||||||
|
|
||||||
local line_num = nil
|
local line_num = nil
|
||||||
|
|
||||||
for i=1, fn.line('$') do
|
for i = 1, fn.line("$") do
|
||||||
local linetext = fn.getline(i)
|
local linetext = fn.getline(i)
|
||||||
-- To prevent invalid escape error, we wrap the regex string with `[[]]`.
|
-- To prevent invalid escape error, we wrap the regex string with `[[]]`.
|
||||||
local idx = fn.match(linetext, [[\v\s+$]])
|
local idx = fn.match(linetext, [[\v\s+$]])
|
||||||
@@ -53,28 +59,45 @@ local function mixed_indent()
|
|||||||
|
|
||||||
local space_pat = [[\v^ +]]
|
local space_pat = [[\v^ +]]
|
||||||
local tab_pat = [[\v^\t+]]
|
local tab_pat = [[\v^\t+]]
|
||||||
local space_indent = fn.search(space_pat, 'nwc')
|
local space_indent = fn.search(space_pat, "nwc")
|
||||||
local tab_indent = fn.search(tab_pat, 'nwc')
|
local tab_indent = fn.search(tab_pat, "nwc")
|
||||||
local mixed = (space_indent > 0 and tab_indent > 0)
|
local mixed = (space_indent > 0 and tab_indent > 0)
|
||||||
local mixed_same_line
|
local mixed_same_line
|
||||||
if not mixed then
|
if not mixed then
|
||||||
mixed_same_line = fn.search([[\v^(\t+ | +\t)]], 'nwc')
|
mixed_same_line = fn.search([[\v^(\t+ | +\t)]], "nwc")
|
||||||
mixed = mixed_same_line > 0
|
mixed = mixed_same_line > 0
|
||||||
end
|
end
|
||||||
if not mixed then return '' end
|
if not mixed then
|
||||||
if mixed_same_line ~= nil and mixed_same_line > 0 then
|
return ""
|
||||||
return 'MI:'..mixed_same_line
|
|
||||||
end
|
end
|
||||||
local space_indent_cnt = fn.searchcount({pattern=space_pat, max_count=1e3}).total
|
if mixed_same_line ~= nil and mixed_same_line > 0 then
|
||||||
local tab_indent_cnt = fn.searchcount({pattern=tab_pat, max_count=1e3}).total
|
return "MI:" .. mixed_same_line
|
||||||
|
end
|
||||||
|
local space_indent_cnt = fn.searchcount({ pattern = space_pat, max_count = 1e3 }).total
|
||||||
|
local tab_indent_cnt = fn.searchcount({ pattern = tab_pat, max_count = 1e3 }).total
|
||||||
if space_indent_cnt > tab_indent_cnt then
|
if space_indent_cnt > tab_indent_cnt then
|
||||||
return 'MI:'..tab_indent
|
return "MI:" .. tab_indent
|
||||||
else
|
else
|
||||||
return 'MI:'..space_indent
|
return "MI:" .. space_indent
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
require("lualine").setup({
|
local diff = function()
|
||||||
|
local git_status = vim.b.gitsigns_status_dict
|
||||||
|
if git_status == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local modify_num = git_status.changed
|
||||||
|
local remove_num = git_status.removed
|
||||||
|
local add_num = git_status.added
|
||||||
|
|
||||||
|
local info = { added = add_num, modified = modify_num, removed = remove_num }
|
||||||
|
-- vim.print(info)
|
||||||
|
return info
|
||||||
|
end
|
||||||
|
|
||||||
|
require("lualine").setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = "auto",
|
theme = "auto",
|
||||||
@@ -87,16 +110,22 @@ require("lualine").setup({
|
|||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = { "mode" },
|
lualine_a = { "mode" },
|
||||||
lualine_b = { "branch", "diff" },
|
lualine_b = {
|
||||||
|
"branch",
|
||||||
|
{
|
||||||
|
"diff",
|
||||||
|
source = diff,
|
||||||
|
},
|
||||||
|
},
|
||||||
lualine_c = {
|
lualine_c = {
|
||||||
"filename",
|
"filename",
|
||||||
{
|
{
|
||||||
ime_state,
|
ime_state,
|
||||||
color = {fg = 'black', bg = '#f46868'}
|
color = { fg = "black", bg = "#f46868" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
spell,
|
spell,
|
||||||
color = {fg = 'black', bg = '#a7c080'}
|
color = { fg = "black", bg = "#a7c080" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
lualine_x = {
|
lualine_x = {
|
||||||
@@ -116,15 +145,15 @@ require("lualine").setup({
|
|||||||
"location",
|
"location",
|
||||||
{
|
{
|
||||||
"diagnostics",
|
"diagnostics",
|
||||||
sources = { "nvim_diagnostic" }
|
sources = { "nvim_diagnostic" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
trailing_space,
|
trailing_space,
|
||||||
color = "WarningMsg"
|
color = "WarningMsg",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
mixed_indent,
|
mixed_indent,
|
||||||
color = "WarningMsg"
|
color = "WarningMsg",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -137,6 +166,5 @@ require("lualine").setup({
|
|||||||
lualine_z = {},
|
lualine_z = {},
|
||||||
},
|
},
|
||||||
tabline = {},
|
tabline = {},
|
||||||
extensions = {'quickfix', 'fugitive', 'nvim-tree'},
|
extensions = { "quickfix", "fugitive", "nvim-tree" },
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
require("nvim-treesitter.configs").setup({
|
require("nvim-treesitter.configs").setup {
|
||||||
ensure_installed = {"python", "cpp", "lua", "vim"},
|
ensure_installed = { "python", "cpp", "lua", "vim" },
|
||||||
ignore_install = {}, -- List of parsers to ignore installing
|
ignore_install = {}, -- List of parsers to ignore installing
|
||||||
highlight = {
|
highlight = {
|
||||||
enable = true, -- false will disable the whole extension
|
enable = true, -- false will disable the whole extension
|
||||||
disable = {}, -- list of language that will be disabled
|
disable = { 'help' }, -- list of language that will be disabled
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
require("which-key").setup({
|
require("which-key").setup {
|
||||||
plugins = {
|
plugins = {
|
||||||
marks = true, -- shows a list of your marks on ' and `
|
marks = true, -- shows a list of your marks on ' and `
|
||||||
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
|
registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode
|
||||||
@@ -46,7 +46,7 @@ require("which-key").setup({
|
|||||||
align = "center", -- align columns left, center or right
|
align = "center", -- align columns left, center or right
|
||||||
},
|
},
|
||||||
ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label
|
ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label
|
||||||
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ "}, -- hide mapping boilerplate
|
hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate
|
||||||
show_help = true, -- show help message on the command line when the popup is visible
|
show_help = true, -- show help message on the command line when the popup is visible
|
||||||
triggers = "auto", -- automatically setup triggers
|
triggers = "auto", -- automatically setup triggers
|
||||||
-- triggers = {"<leader>"} -- or specify a list manually
|
-- triggers = {"<leader>"} -- or specify a list manually
|
||||||
@@ -57,4 +57,4 @@ require("which-key").setup({
|
|||||||
-- most people should not need to change this
|
-- most people should not need to change this
|
||||||
n = { "o", "O" },
|
n = { "o", "O" },
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|||||||
13
lua/config/yanky.lua
Normal file
13
lua/config/yanky.lua
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
require("yanky").setup({
|
||||||
|
ring = {
|
||||||
|
history_length = 50,
|
||||||
|
storage = "memory",
|
||||||
|
},
|
||||||
|
preserve_cursor_position = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- cycle through the yank history, only work after paste
|
||||||
|
vim.keymap.set("n", "[y", "<Plug>(YankyCycleForward)")
|
||||||
|
vim.keymap.set("n", "]y", "<Plug>(YankyCycleBackward)")
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
require("zen-mode").setup({
|
require("zen-mode").setup {
|
||||||
window = {
|
window = {
|
||||||
backdrop = 0.8, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
|
backdrop = 0.8, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
|
||||||
width = 120,
|
width = 120,
|
||||||
@@ -12,4 +12,4 @@ require("zen-mode").setup({
|
|||||||
list = false, -- disable whitespace characters
|
list = false, -- disable whitespace characters
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ local api = vim.api
|
|||||||
|
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
|
|
||||||
|
|
||||||
-- Display a message when the current file is not in utf-8 format.
|
-- Display a message when the current file is not in utf-8 format.
|
||||||
-- Note that we need to use `unsilent` command here because of this issue:
|
-- Note that we need to use `unsilent` command here because of this issue:
|
||||||
-- https://github.com/vim/vim/issues/4379
|
-- https://github.com/vim/vim/issues/4379
|
||||||
@@ -11,10 +10,10 @@ api.nvim_create_autocmd({ "BufRead" }, {
|
|||||||
pattern = "*",
|
pattern = "*",
|
||||||
group = api.nvim_create_augroup("non_utf8_file", { clear = true }),
|
group = api.nvim_create_augroup("non_utf8_file", { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.bo.fileencoding ~= 'utf-8' then
|
if vim.bo.fileencoding ~= "utf-8" then
|
||||||
vim.notify("File not in UTF-8 format!", vim.log.levels.WARN, { title = "nvim-config" })
|
vim.notify("File not in UTF-8 format!", vim.log.levels.WARN, { title = "nvim-config" })
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- highlight yanked region, see `:h lua-highlight`
|
-- highlight yanked region, see `:h lua-highlight`
|
||||||
@@ -23,18 +22,7 @@ api.nvim_create_autocmd({ "TextYankPost" }, {
|
|||||||
group = api.nvim_create_augroup("highlight_yank", { clear = true }),
|
group = api.nvim_create_augroup("highlight_yank", { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank { higroup = "YankColor", timeout = 300 }
|
vim.highlight.on_yank { higroup = "YankColor", timeout = 300 }
|
||||||
end
|
end,
|
||||||
})
|
|
||||||
|
|
||||||
-- Auto-generate packer_compiled.lua file
|
|
||||||
api.nvim_create_autocmd({ "BufWritePost" }, {
|
|
||||||
pattern = "*/nvim/lua/plugins.lua",
|
|
||||||
group = api.nvim_create_augroup("packer_auto_compile", { clear = true }),
|
|
||||||
callback = function(ctx)
|
|
||||||
local cmd = "source " .. ctx.file
|
|
||||||
vim.cmd(cmd)
|
|
||||||
vim.cmd("PackerCompile")
|
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Auto-create dir when saving a file, in case some intermediate directory does not exist
|
-- Auto-create dir when saving a file, in case some intermediate directory does not exist
|
||||||
@@ -44,7 +32,7 @@ api.nvim_create_autocmd({ "BufWritePre" }, {
|
|||||||
callback = function(ctx)
|
callback = function(ctx)
|
||||||
local dir = fn.fnamemodify(ctx.file, ":p:h")
|
local dir = fn.fnamemodify(ctx.file, ":p:h")
|
||||||
utils.may_create_dir(dir)
|
utils.may_create_dir(dir)
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Automatically reload the file if it is changed outside of Nvim, see https://unix.stackexchange.com/a/383044/221410.
|
-- Automatically reload the file if it is changed outside of Nvim, see https://unix.stackexchange.com/a/383044/221410.
|
||||||
@@ -57,17 +45,17 @@ api.nvim_create_autocmd({ "FileChangedShellPost" }, {
|
|||||||
group = "auto_read",
|
group = "auto_read",
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.notify("File changed on disk. Buffer reloaded!", vim.log.levels.WARN, { title = "nvim-config" })
|
vim.notify("File changed on disk. Buffer reloaded!", vim.log.levels.WARN, { title = "nvim-config" })
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
api.nvim_create_autocmd({ "FocusGained", "CursorHold" }, {
|
api.nvim_create_autocmd({ "FocusGained", "CursorHold" }, {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
group = "auto_read",
|
group = "auto_read",
|
||||||
callback = function()
|
callback = function()
|
||||||
if fn.getcmdwintype() == '' then
|
if fn.getcmdwintype() == "" then
|
||||||
vim.cmd("checktime")
|
vim.cmd("checktime")
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Resize all windows when we resize the terminal
|
-- Resize all windows when we resize the terminal
|
||||||
|
|||||||
324
lua/plugins.lua
324
lua/plugins.lua
@@ -1,41 +1,54 @@
|
|||||||
local utils = require("utils")
|
local api = vim.api
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
|
|
||||||
|
local utils = require("utils")
|
||||||
|
|
||||||
-- The root dir to install all plugins. Plugins are under opt/ or start/ sub-directory.
|
-- The root dir to install all plugins. Plugins are under opt/ or start/ sub-directory.
|
||||||
vim.g.plugin_home = fn.stdpath("data") .. "/site/pack/packer"
|
vim.g.plugin_home = fn.stdpath("data") .. "/site/pack/packer"
|
||||||
|
|
||||||
-- Where to install packer.nvim -- the package manager (we make it opt)
|
--- Install packer if it has not been installed.
|
||||||
local packer_dir = vim.g.plugin_home .. "/opt/packer.nvim"
|
--- Return:
|
||||||
|
--- true: if this is a fresh install of packer
|
||||||
|
--- false: if packer has been installed
|
||||||
|
local function packer_ensure_install()
|
||||||
|
-- Where to install packer.nvim -- the package manager (we make it opt)
|
||||||
|
local packer_dir = vim.g.plugin_home .. "/opt/packer.nvim"
|
||||||
|
|
||||||
-- Whether this is a fresh install, i.e., packer itself and plugins have not been installed.
|
if fn.glob(packer_dir) ~= "" then
|
||||||
local fresh_install = false
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Auto-install packer in case it hasn't been installed.
|
-- Auto-install packer in case it hasn't been installed.
|
||||||
if fn.glob(packer_dir) == "" then
|
vim.api.nvim_echo({ { "Installing packer.nvim", "Type" } }, true, {})
|
||||||
fresh_install = true
|
|
||||||
|
|
||||||
-- Now we need to install packer.nvim first.
|
|
||||||
local packer_repo = "https://github.com/wbthomason/packer.nvim"
|
local packer_repo = "https://github.com/wbthomason/packer.nvim"
|
||||||
local install_cmd = string.format("!git clone --depth=1 %s %s", packer_repo, packer_dir)
|
local install_cmd = string.format("!git clone --depth=1 %s %s", packer_repo, packer_dir)
|
||||||
|
|
||||||
vim.api.nvim_echo({ { "Installing packer.nvim", "Type" } }, true, {})
|
|
||||||
vim.cmd(install_cmd)
|
vim.cmd(install_cmd)
|
||||||
|
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local fresh_install = packer_ensure_install()
|
||||||
|
|
||||||
-- Load packer.nvim
|
-- Load packer.nvim
|
||||||
vim.cmd("packadd packer.nvim")
|
vim.cmd("packadd packer.nvim")
|
||||||
|
|
||||||
local packer = require("packer")
|
local packer = require("packer")
|
||||||
local packer_util = require('packer.util')
|
local packer_util = require("packer.util")
|
||||||
|
|
||||||
packer.startup({
|
-- check if firenvim is active
|
||||||
|
local firenvim_not_active = function()
|
||||||
|
return not vim.g.started_by_firenvim
|
||||||
|
end
|
||||||
|
|
||||||
|
packer.startup {
|
||||||
function(use)
|
function(use)
|
||||||
-- it is recommended to put impatient.nvim before any other plugins
|
-- it is recommended to put impatient.nvim before any other plugins
|
||||||
use { 'lewis6991/impatient.nvim', config = [[require('impatient')]] }
|
use { "lewis6991/impatient.nvim", config = [[require('impatient')]] }
|
||||||
|
|
||||||
use({ "wbthomason/packer.nvim", opt = true })
|
use { "wbthomason/packer.nvim", opt = true }
|
||||||
|
|
||||||
use({ "onsails/lspkind-nvim", event = "VimEnter" })
|
use { "onsails/lspkind-nvim", event = "VimEnter" }
|
||||||
-- auto-completion engine
|
-- auto-completion engine
|
||||||
use { "hrsh7th/nvim-cmp", after = "lspkind-nvim", config = [[require('config.nvim-cmp')]] }
|
use { "hrsh7th/nvim-cmp", after = "lspkind-nvim", config = [[require('config.nvim-cmp')]] }
|
||||||
|
|
||||||
@@ -44,312 +57,321 @@ packer.startup({
|
|||||||
use { "hrsh7th/cmp-path", after = "nvim-cmp" }
|
use { "hrsh7th/cmp-path", after = "nvim-cmp" }
|
||||||
use { "hrsh7th/cmp-buffer", after = "nvim-cmp" }
|
use { "hrsh7th/cmp-buffer", after = "nvim-cmp" }
|
||||||
use { "hrsh7th/cmp-omni", after = "nvim-cmp" }
|
use { "hrsh7th/cmp-omni", after = "nvim-cmp" }
|
||||||
use { "quangnguyen30192/cmp-nvim-ultisnips", after = { 'nvim-cmp', 'ultisnips' } }
|
use { "quangnguyen30192/cmp-nvim-ultisnips", after = { "nvim-cmp", "ultisnips" } }
|
||||||
if vim.g.is_mac then
|
if vim.g.is_mac then
|
||||||
use { "hrsh7th/cmp-emoji", after = 'nvim-cmp' }
|
use { "hrsh7th/cmp-emoji", after = "nvim-cmp" }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp).
|
-- nvim-lsp configuration (it relies on cmp-nvim-lsp, so it should be loaded after cmp-nvim-lsp).
|
||||||
use({ "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] })
|
use { "neovim/nvim-lspconfig", after = "cmp-nvim-lsp", config = [[require('config.lsp')]] }
|
||||||
|
|
||||||
if vim.g.is_mac then
|
if vim.g.is_mac then
|
||||||
use({ "nvim-treesitter/nvim-treesitter", event = 'BufEnter', run = ":TSUpdate",
|
use {
|
||||||
config = [[require('config.treesitter')]] })
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
event = "BufEnter",
|
||||||
|
run = ":TSUpdate",
|
||||||
|
config = [[require('config.treesitter')]],
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Python indent (follows the PEP8 style)
|
-- Python indent (follows the PEP8 style)
|
||||||
use({ "Vimjas/vim-python-pep8-indent", ft = { "python" } })
|
use { "Vimjas/vim-python-pep8-indent", ft = { "python" } }
|
||||||
|
|
||||||
-- Python-related text object
|
-- Python-related text object
|
||||||
use({ "jeetsukumaran/vim-pythonsense", ft = { "python" } })
|
use { "jeetsukumaran/vim-pythonsense", ft = { "python" } }
|
||||||
|
|
||||||
use({ "machakann/vim-swap", event = "VimEnter" })
|
use { "machakann/vim-swap", event = "VimEnter" }
|
||||||
|
|
||||||
-- IDE for Lisp
|
-- IDE for Lisp
|
||||||
if utils.executable("sbcl") then
|
if utils.executable("sbcl") then
|
||||||
-- use 'kovisoft/slimv'
|
-- use 'kovisoft/slimv'
|
||||||
use({ "vlime/vlime", rtp = "vim/", ft = { "lisp" } })
|
use { "vlime/vlime", rtp = "vim/", ft = { "lisp" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Super fast buffer jump
|
-- Super fast buffer jump
|
||||||
use {
|
use {
|
||||||
'phaazon/hop.nvim',
|
"phaazon/hop.nvim",
|
||||||
event = "VimEnter",
|
event = "VimEnter",
|
||||||
config = function()
|
config = function()
|
||||||
vim.defer_fn(function() require('config.nvim_hop') end, 2000)
|
vim.defer_fn(function()
|
||||||
end
|
require("config.nvim_hop")
|
||||||
|
end, 2000)
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Show match number and index for searching
|
-- Show match number and index for searching
|
||||||
use {
|
use {
|
||||||
'kevinhwang91/nvim-hlslens',
|
"kevinhwang91/nvim-hlslens",
|
||||||
branch = 'main',
|
branch = "main",
|
||||||
keys = { { 'n', '*' }, { 'n', '#' }, { 'n', 'n' }, { 'n', 'N' } },
|
keys = { { "n", "*" }, { "n", "#" }, { "n", "n" }, { "n", "N" } },
|
||||||
config = [[require('config.hlslens')]]
|
config = [[require('config.hlslens')]],
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Stay after pressing * and search selected text
|
|
||||||
use({ "haya14busa/vim-asterisk", event = 'VimEnter' })
|
|
||||||
|
|
||||||
-- File search, tag search and more
|
-- File search, tag search and more
|
||||||
if vim.g.is_win then
|
if vim.g.is_win then
|
||||||
use({ "Yggdroot/LeaderF", cmd = "Leaderf" })
|
use { "Yggdroot/LeaderF", cmd = "Leaderf" }
|
||||||
else
|
else
|
||||||
use({ "Yggdroot/LeaderF", cmd = "Leaderf", run = ":LeaderfInstallCExtension" })
|
use { "Yggdroot/LeaderF", cmd = "Leaderf", run = ":LeaderfInstallCExtension" }
|
||||||
end
|
end
|
||||||
|
|
||||||
use {
|
use {
|
||||||
'nvim-telescope/telescope.nvim', cmd = 'Telescope',
|
"nvim-telescope/telescope.nvim",
|
||||||
requires = { { 'nvim-lua/plenary.nvim' } }
|
cmd = "Telescope",
|
||||||
|
requires = { { "nvim-lua/plenary.nvim" } },
|
||||||
}
|
}
|
||||||
-- search emoji and other symbols
|
-- search emoji and other symbols
|
||||||
use { 'nvim-telescope/telescope-symbols.nvim', after = 'telescope.nvim' }
|
use { "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" }
|
||||||
|
|
||||||
-- A list of colorscheme plugin you may want to try. Find what suits you.
|
-- A list of colorscheme plugin you may want to try. Find what suits you.
|
||||||
use({ "lifepillar/vim-gruvbox8", opt = true })
|
use { "navarasu/onedark.nvim", opt = true }
|
||||||
use({ "navarasu/onedark.nvim", opt = true })
|
use { "sainnhe/edge", opt = true }
|
||||||
use({ "sainnhe/edge", opt = true })
|
use { "sainnhe/sonokai", opt = true }
|
||||||
use({ "sainnhe/sonokai", opt = true })
|
use { "sainnhe/gruvbox-material", opt = true }
|
||||||
use({ "sainnhe/gruvbox-material", opt = true })
|
use { "shaunsingh/nord.nvim", opt = true }
|
||||||
use({ "shaunsingh/nord.nvim", opt = true })
|
use { "sainnhe/everforest", opt = true }
|
||||||
use({ "NTBBloodbath/doom-one.nvim", opt = true })
|
use { "EdenEast/nightfox.nvim", opt = true }
|
||||||
use({ "sainnhe/everforest", opt = true })
|
use { "rebelot/kanagawa.nvim", opt = true }
|
||||||
use({ "EdenEast/nightfox.nvim", opt = true })
|
use { "catppuccin/nvim", as = "catppuccin", opt = true }
|
||||||
use({ "rebelot/kanagawa.nvim", opt = true })
|
use({ "rose-pine/neovim", as = 'rose-pine', opt = true })
|
||||||
use({ "catppuccin/nvim", as = "catppuccin", opt = true })
|
use { "olimorris/onedarkpro.nvim", opt = true }
|
||||||
|
use { "tanvirtin/monokai.nvim", opt = true }
|
||||||
|
use { "marko-cerovac/material.nvim", opt = true }
|
||||||
|
|
||||||
use { 'kyazdani42/nvim-web-devicons', event = 'VimEnter' }
|
use { "nvim-tree/nvim-web-devicons", event = "VimEnter" }
|
||||||
|
|
||||||
use {
|
use {
|
||||||
'nvim-lualine/lualine.nvim',
|
"nvim-lualine/lualine.nvim",
|
||||||
event = 'VimEnter',
|
event = "VimEnter",
|
||||||
config = [[require('config.statusline')]]
|
cond = firenvim_not_active,
|
||||||
|
config = [[require('config.statusline')]],
|
||||||
}
|
}
|
||||||
|
|
||||||
use({ "akinsho/bufferline.nvim", event = "VimEnter", config = [[require('config.bufferline')]] })
|
use { "akinsho/bufferline.nvim", event = "VimEnter",
|
||||||
|
cond = firenvim_not_active,
|
||||||
|
config = [[require('config.bufferline')]] }
|
||||||
|
|
||||||
-- fancy start screen
|
-- fancy start screen
|
||||||
use { 'glepnir/dashboard-nvim', event = "VimEnter", config = [[require('config.dashboard-nvim')]] }
|
use { "glepnir/dashboard-nvim", event = "VimEnter",
|
||||||
|
cond = firenvim_not_active,
|
||||||
|
config = [[require('config.dashboard-nvim')]]
|
||||||
|
}
|
||||||
|
|
||||||
use({
|
use {
|
||||||
"lukas-reineke/indent-blankline.nvim",
|
"lukas-reineke/indent-blankline.nvim",
|
||||||
event = 'VimEnter',
|
event = "VimEnter",
|
||||||
config = [[require('config.indent-blankline')]]
|
config = [[require('config.indent-blankline')]],
|
||||||
})
|
}
|
||||||
|
|
||||||
-- Highlight URLs inside vim
|
-- Highlight URLs inside vim
|
||||||
use({ "itchyny/vim-highlighturl", event = "VimEnter" })
|
use { "itchyny/vim-highlighturl", event = "VimEnter" }
|
||||||
|
|
||||||
-- notification plugin
|
-- notification plugin
|
||||||
use({
|
use {
|
||||||
"rcarriga/nvim-notify",
|
"rcarriga/nvim-notify",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
config = function()
|
config = function()
|
||||||
vim.defer_fn(function() require('config.nvim-notify') end, 2000)
|
vim.defer_fn(function()
|
||||||
end
|
require("config.nvim-notify")
|
||||||
})
|
end, 2000)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may
|
-- For Windows and Mac, we can open an URL in the browser. For Linux, it may
|
||||||
-- not be possible since we maybe in a server which disables GUI.
|
-- not be possible since we maybe in a server which disables GUI.
|
||||||
if vim.g.is_win or vim.g.is_mac then
|
if vim.g.is_win or vim.g.is_mac then
|
||||||
-- open URL in browser
|
-- open URL in browser
|
||||||
use({ "tyru/open-browser.vim", event = "VimEnter" })
|
use { "tyru/open-browser.vim", event = "VimEnter" }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Only install these plugins if ctags are installed on the system
|
-- Only install these plugins if ctags are installed on the system
|
||||||
if utils.executable("ctags") then
|
if utils.executable("ctags") then
|
||||||
-- show file tags in vim window
|
-- show file tags in vim window
|
||||||
use({ "liuchengxu/vista.vim", cmd = "Vista" })
|
use { "liuchengxu/vista.vim", cmd = "Vista" }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Snippet engine and snippet template
|
-- Snippet engine and snippet template
|
||||||
use({ "SirVer/ultisnips", event = 'InsertEnter' })
|
use { "SirVer/ultisnips", event = "InsertEnter" }
|
||||||
use({ "honza/vim-snippets", after = 'ultisnips' })
|
use { "honza/vim-snippets", after = "ultisnips" }
|
||||||
|
|
||||||
-- Automatic insertion and deletion of a pair of characters
|
-- Automatic insertion and deletion of a pair of characters
|
||||||
use({ "Raimondi/delimitMate", event = "InsertEnter" })
|
use { "Raimondi/delimitMate", event = "InsertEnter" }
|
||||||
|
|
||||||
-- Comment plugin
|
-- Comment plugin
|
||||||
use({ "tpope/vim-commentary", event = "VimEnter" })
|
use { "tpope/vim-commentary", event = "VimEnter" }
|
||||||
|
|
||||||
-- Multiple cursor plugin like Sublime Text?
|
-- Multiple cursor plugin like Sublime Text?
|
||||||
-- use 'mg979/vim-visual-multi'
|
-- use 'mg979/vim-visual-multi'
|
||||||
|
|
||||||
-- Autosave files on certain events
|
-- Autosave files on certain events
|
||||||
use({ "907th/vim-auto-save", event = "InsertEnter" })
|
use { "907th/vim-auto-save", event = "InsertEnter" }
|
||||||
|
|
||||||
-- Show undo history visually
|
-- Show undo history visually
|
||||||
use({ "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } })
|
use { "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } }
|
||||||
|
|
||||||
|
-- better UI for some nvim actions
|
||||||
|
use {'stevearc/dressing.nvim'}
|
||||||
|
|
||||||
-- Manage your yank history
|
-- Manage your yank history
|
||||||
if vim.g.is_win or vim.g.is_mac then
|
use({
|
||||||
use({ "svermeulen/vim-yoink", event = "VimEnter" })
|
"gbprod/yanky.nvim",
|
||||||
end
|
config = [[require('config.yanky')]]
|
||||||
|
})
|
||||||
|
|
||||||
-- Handy unix command inside Vim (Rename, Move etc.)
|
-- Handy unix command inside Vim (Rename, Move etc.)
|
||||||
use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } })
|
use { "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }
|
||||||
|
|
||||||
-- Repeat vim motions
|
-- Repeat vim motions
|
||||||
use({ "tpope/vim-repeat", event = "VimEnter" })
|
use { "tpope/vim-repeat", event = "VimEnter" }
|
||||||
|
|
||||||
use({ "nvim-zh/better-escape.vim", event = { "InsertEnter" } })
|
use { "nvim-zh/better-escape.vim", event = { "InsertEnter" } }
|
||||||
|
|
||||||
if vim.g.is_mac then
|
if vim.g.is_mac then
|
||||||
use({ "lyokha/vim-xkbswitch", event = { "InsertEnter" } })
|
use { "lyokha/vim-xkbswitch", event = { "InsertEnter" } }
|
||||||
elseif vim.g.is_win then
|
elseif vim.g.is_win then
|
||||||
use({ "Neur1n/neuims", event = { "InsertEnter" } })
|
use { "Neur1n/neuims", event = { "InsertEnter" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Auto format tools
|
-- Auto format tools
|
||||||
use({ "sbdchd/neoformat", cmd = { "Neoformat" } })
|
use { "sbdchd/neoformat", cmd = { "Neoformat" } }
|
||||||
|
|
||||||
-- Git command inside vim
|
-- Git command inside vim
|
||||||
use({ "tpope/vim-fugitive", event = "User InGitRepo", config = [[require('config.fugitive')]] })
|
use { "tpope/vim-fugitive", event = "User InGitRepo", config = [[require('config.fugitive')]] }
|
||||||
|
|
||||||
-- Better git log display
|
-- Better git log display
|
||||||
use({ "rbong/vim-flog", requires = "tpope/vim-fugitive", cmd = { "Flog" } })
|
use { "rbong/vim-flog", requires = "tpope/vim-fugitive", cmd = { "Flog" } }
|
||||||
|
|
||||||
use({ "christoomey/vim-conflicted", requires = "tpope/vim-fugitive", cmd = { "Conflicted" } })
|
use { "christoomey/vim-conflicted", requires = "tpope/vim-fugitive", cmd = { "Conflicted" } }
|
||||||
|
|
||||||
use {
|
use {
|
||||||
'ruifm/gitlinker.nvim',
|
"ruifm/gitlinker.nvim",
|
||||||
requires = 'nvim-lua/plenary.nvim',
|
requires = "nvim-lua/plenary.nvim",
|
||||||
event = "User InGitRepo",
|
event = "User InGitRepo",
|
||||||
config = [[require('config.git-linker')]]
|
config = [[require('config.git-linker')]],
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Show git change (change, delete, add) signs in vim sign column
|
-- Show git change (change, delete, add) signs in vim sign column
|
||||||
use({ 'lewis6991/gitsigns.nvim', config = [[require('config.gitsigns')]] })
|
use { "lewis6991/gitsigns.nvim", config = [[require('config.gitsigns')]] }
|
||||||
|
|
||||||
-- Better git commit experience
|
-- Better git commit experience
|
||||||
use({ "rhysd/committia.vim", opt = true, setup = [[vim.cmd('packadd committia.vim')]] })
|
use { "rhysd/committia.vim", opt = true, setup = [[vim.cmd('packadd committia.vim')]] }
|
||||||
|
|
||||||
use({ "kevinhwang91/nvim-bqf", ft = "qf", config = [[require('config.bqf')]] })
|
use { "kevinhwang91/nvim-bqf", ft = "qf", config = [[require('config.bqf')]] }
|
||||||
|
|
||||||
-- Another markdown plugin
|
-- Another markdown plugin
|
||||||
use({ "plasticboy/vim-markdown", ft = { "markdown" } })
|
use { "preservim/vim-markdown", ft = { "markdown" } }
|
||||||
|
|
||||||
-- Faster footnote generation
|
-- Faster footnote generation
|
||||||
use({ "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } })
|
use { "vim-pandoc/vim-markdownfootnotes", ft = { "markdown" } }
|
||||||
|
|
||||||
-- Vim tabular plugin for manipulate tabular, required by markdown plugins
|
-- Vim tabular plugin for manipulate tabular, required by markdown plugins
|
||||||
use({ "godlygeek/tabular", cmd = { "Tabularize" } })
|
use { "godlygeek/tabular", cmd = { "Tabularize" } }
|
||||||
|
|
||||||
-- Markdown JSON header highlight plugin
|
|
||||||
use({ "elzr/vim-json", ft = { "json", "markdown" } })
|
|
||||||
|
|
||||||
-- Markdown previewing (only for Mac and Windows)
|
-- Markdown previewing (only for Mac and Windows)
|
||||||
if vim.g.is_win or vim.g.is_mac then
|
if vim.g.is_win or vim.g.is_mac then
|
||||||
use({
|
use {
|
||||||
"iamcco/markdown-preview.nvim",
|
"iamcco/markdown-preview.nvim",
|
||||||
run = function()
|
run = "cd app && npm install",
|
||||||
fn["mkdp#util#install"]()
|
|
||||||
end,
|
|
||||||
ft = { "markdown" },
|
ft = { "markdown" },
|
||||||
})
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
use({ 'folke/zen-mode.nvim', cmd = 'ZenMode', config = [[require('config.zen-mode')]] })
|
use { "folke/zen-mode.nvim", cmd = "ZenMode", config = [[require('config.zen-mode')]] }
|
||||||
|
|
||||||
if vim.g.is_mac then
|
if vim.g.is_mac then
|
||||||
use({ "rhysd/vim-grammarous", ft = { "markdown" } })
|
use { "rhysd/vim-grammarous", ft = { "markdown" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
use({ "chrisbra/unicode.vim", event = "VimEnter" })
|
use { "chrisbra/unicode.vim", event = "VimEnter" }
|
||||||
|
|
||||||
-- Additional powerful text object for vim, this plugin should be studied
|
-- Additional powerful text object for vim, this plugin should be studied
|
||||||
-- carefully to use its full power
|
-- carefully to use its full power
|
||||||
use({ "wellle/targets.vim", event = "VimEnter" })
|
use { "wellle/targets.vim", event = "VimEnter" }
|
||||||
|
|
||||||
-- Plugin to manipulate character pairs quickly
|
-- Plugin to manipulate character pairs quickly
|
||||||
use({ "machakann/vim-sandwich", event = "VimEnter" })
|
use { "machakann/vim-sandwich", event = "VimEnter" }
|
||||||
|
|
||||||
-- Add indent object for vim (useful for languages like Python)
|
-- Add indent object for vim (useful for languages like Python)
|
||||||
use({ "michaeljsmith/vim-indent-object", event = "VimEnter" })
|
use { "michaeljsmith/vim-indent-object", event = "VimEnter" }
|
||||||
|
|
||||||
-- Only use these plugin on Windows and Mac and when LaTeX is installed
|
-- Only use these plugin on Windows and Mac and when LaTeX is installed
|
||||||
if vim.g.is_win or vim.g.is_mac and utils.executable("latex") then
|
if utils.executable("latex") then
|
||||||
use({ "lervag/vimtex", ft = { "tex" } })
|
use { "lervag/vimtex", ft = { "tex" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Since tmux is only available on Linux and Mac, we only enable these plugins
|
-- Since tmux is only available on Linux and Mac, we only enable these plugins
|
||||||
-- for Linux and Mac
|
-- for Linux and Mac
|
||||||
if utils.executable("tmux") then
|
if utils.executable("tmux") then
|
||||||
-- .tmux.conf syntax highlighting and setting check
|
-- .tmux.conf syntax highlighting and setting check
|
||||||
use({ "tmux-plugins/vim-tmux", ft = { "tmux" } })
|
use { "tmux-plugins/vim-tmux", ft = { "tmux" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Modern matchit implementation
|
-- Modern matchit implementation
|
||||||
use({ "andymass/vim-matchup", event = "VimEnter" })
|
use { "andymass/vim-matchup", event = "VimEnter" }
|
||||||
|
|
||||||
-- Smoothie motions
|
use { "tpope/vim-scriptease", cmd = { "Scriptnames", "Message", "Verbose" } }
|
||||||
use({
|
|
||||||
"karb94/neoscroll.nvim",
|
|
||||||
event = "VimEnter",
|
|
||||||
config = function()
|
|
||||||
vim.defer_fn(function() require('config.neoscroll') end, 2000)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
use({ "tpope/vim-scriptease", cmd = { "Scriptnames", "Message", "Verbose" } })
|
|
||||||
|
|
||||||
-- Asynchronous command execution
|
-- Asynchronous command execution
|
||||||
use({ "skywind3000/asyncrun.vim", opt = true, cmd = { "AsyncRun" } })
|
use { "skywind3000/asyncrun.vim", opt = true, cmd = { "AsyncRun" } }
|
||||||
|
|
||||||
use({ "cespare/vim-toml", ft = { "toml" }, branch = "main" })
|
use { "cespare/vim-toml", ft = { "toml" }, branch = "main" }
|
||||||
|
|
||||||
-- Edit text area in browser using nvim
|
-- Edit text area in browser using nvim
|
||||||
if vim.g.is_win or vim.g.is_mac then
|
if vim.g.is_win or vim.g.is_mac then
|
||||||
use({
|
use {
|
||||||
"glacambre/firenvim",
|
"glacambre/firenvim",
|
||||||
run = function() fn["firenvim#install"](0) end,
|
run = function()
|
||||||
|
fn["firenvim#install"](0)
|
||||||
|
end,
|
||||||
opt = true,
|
opt = true,
|
||||||
setup = [[vim.cmd('packadd firenvim')]],
|
setup = [[vim.cmd('packadd firenvim')]],
|
||||||
})
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debugger plugin
|
-- Debugger plugin
|
||||||
if vim.g.is_win or vim.g.is_linux then
|
if vim.g.is_win or vim.g.is_linux then
|
||||||
use({ "sakhnik/nvim-gdb", run = { "bash install.sh" }, opt = true, setup = [[vim.cmd('packadd nvim-gdb')]] })
|
use { "sakhnik/nvim-gdb", run = { "bash install.sh" }, opt = true, setup = [[vim.cmd('packadd nvim-gdb')]] }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Session management plugin
|
-- Session management plugin
|
||||||
use({ "tpope/vim-obsession", cmd = 'Obsession' })
|
use { "tpope/vim-obsession", cmd = "Obsession" }
|
||||||
|
|
||||||
if vim.g.is_linux then
|
if vim.g.is_linux then
|
||||||
use({ "ojroques/vim-oscyank", cmd = { 'OSCYank', 'OSCYankReg' } })
|
use { "ojroques/vim-oscyank", cmd = { "OSCYank", "OSCYankReg" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The missing auto-completion for cmdline!
|
-- The missing auto-completion for cmdline!
|
||||||
use({ "gelguy/wilder.nvim", opt = true, setup = [[vim.cmd('packadd wilder.nvim')]] })
|
use { "gelguy/wilder.nvim", opt = true, setup = [[vim.cmd('packadd wilder.nvim')]] }
|
||||||
|
|
||||||
-- showing keybindings
|
-- showing keybindings
|
||||||
use { "folke/which-key.nvim",
|
use {
|
||||||
|
"folke/which-key.nvim",
|
||||||
event = "VimEnter",
|
event = "VimEnter",
|
||||||
config = function()
|
config = function()
|
||||||
vim.defer_fn(function() require('config.which-key') end, 2000)
|
vim.defer_fn(function()
|
||||||
end
|
require("config.which-key")
|
||||||
|
end, 2000)
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- show and trim trailing whitespaces
|
-- show and trim trailing whitespaces
|
||||||
use { 'jdhao/whitespace.nvim', event = 'VimEnter' }
|
use { "jdhao/whitespace.nvim", event = "VimEnter" }
|
||||||
|
|
||||||
-- file explorer
|
-- file explorer
|
||||||
use {
|
use {
|
||||||
'kyazdani42/nvim-tree.lua',
|
"nvim-tree/nvim-tree.lua",
|
||||||
requires = { 'kyazdani42/nvim-web-devicons' },
|
requires = { "nvim-tree/nvim-web-devicons" },
|
||||||
config = [[require('config.nvim-tree')]]
|
config = [[require('config.nvim-tree')]],
|
||||||
}
|
}
|
||||||
|
|
||||||
use { 'ii14/emmylua-nvim', ft = 'lua' }
|
use { "ii14/emmylua-nvim", ft = "lua" }
|
||||||
|
|
||||||
use { 'j-hui/fidget.nvim', after = 'nvim-lspconfig', config = [[require('config.fidget-nvim')]] }
|
use { "j-hui/fidget.nvim", after = "nvim-lspconfig", config = [[require('config.fidget-nvim')]] }
|
||||||
end,
|
end,
|
||||||
config = {
|
config = {
|
||||||
max_jobs = 16,
|
max_jobs = 16,
|
||||||
compile_path = packer_util.join_paths(fn.stdpath('data'), 'site', 'lua', 'packer_compiled.lua'),
|
compile_path = packer_util.join_paths(fn.stdpath("data"), "site", "lua", "packer_compiled.lua"),
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
-- For fresh install, we need to install plugins. Otherwise, we just need to require `packer_compiled.lua`.
|
-- For fresh install, we need to install plugins. Otherwise, we just need to require `packer_compiled.lua`.
|
||||||
if fresh_install then
|
if fresh_install then
|
||||||
@@ -357,9 +379,21 @@ if fresh_install then
|
|||||||
-- So plugin installation should be done after the startup process.
|
-- So plugin installation should be done after the startup process.
|
||||||
packer.sync()
|
packer.sync()
|
||||||
else
|
else
|
||||||
local status, _ = pcall(require, 'packer_compiled')
|
local status, _ = pcall(require, "packer_compiled")
|
||||||
if not status then
|
if not status then
|
||||||
local msg = "File packer_compiled.lua not found: run PackerSync to fix!"
|
local msg = "File packer_compiled.lua not found: run PackerSync to fix!"
|
||||||
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
vim.notify(msg, vim.log.levels.ERROR, { title = "nvim-config" })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Auto-generate packer_compiled.lua file
|
||||||
|
api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
|
pattern = "*/nvim/lua/plugins.lua",
|
||||||
|
group = api.nvim_create_augroup("packer_auto_compile", { clear = true }),
|
||||||
|
callback = function(ctx)
|
||||||
|
local cmd = "source " .. ctx.file
|
||||||
|
vim.cmd(cmd)
|
||||||
|
vim.cmd("PackerCompile")
|
||||||
|
vim.notify("PackerCompile done!", vim.log.levels.INFO, { title = "Nvim-config" })
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
|
|
||||||
-- inspect something
|
|
||||||
function _G.inspect(item)
|
|
||||||
vim.pretty_print(item)
|
|
||||||
end
|
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.executable(name)
|
function M.executable(name)
|
||||||
@@ -15,23 +10,27 @@ function M.executable(name)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- check whether a feature exists in Nvim
|
||||||
|
--- @feat: string
|
||||||
|
--- the feature name, like `nvim-0.7` or `unix`.
|
||||||
|
--- return: bool
|
||||||
|
M.has = function(feat)
|
||||||
|
if fn.has(feat) == 1 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
--- Create a dir if it does not exist
|
--- Create a dir if it does not exist
|
||||||
function M.may_create_dir(dir)
|
function M.may_create_dir(dir)
|
||||||
local res = fn.isdirectory(dir)
|
local res = fn.isdirectory(dir)
|
||||||
|
|
||||||
if res == 0 then
|
if res == 0 then
|
||||||
fn.mkdir(dir, 'p')
|
fn.mkdir(dir, "p")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_nvim_version()
|
|
||||||
local actual_ver = vim.version()
|
|
||||||
|
|
||||||
local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
|
|
||||||
return nvim_ver_str
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
--- Generate random integers in the range [Low, High], inclusive,
|
--- Generate random integers in the range [Low, High], inclusive,
|
||||||
--- adapted from https://stackoverflow.com/a/12739441/6064933
|
--- adapted from https://stackoverflow.com/a/12739441/6064933
|
||||||
--- @low: the lower value for this range
|
--- @low: the lower value for this range
|
||||||
|
|||||||
3
plugin/abbrev.vim
Normal file
3
plugin/abbrev.vim
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
" some abbreviations
|
||||||
|
iabbrev reqire require
|
||||||
|
iabbrev serveral several
|
||||||
@@ -194,7 +194,6 @@ wiki
|
|||||||
backticks
|
backticks
|
||||||
Reddit
|
Reddit
|
||||||
LeaderF
|
LeaderF
|
||||||
gruvbox8
|
|
||||||
tabpage
|
tabpage
|
||||||
ccls
|
ccls
|
||||||
cmake
|
cmake
|
||||||
@@ -203,6 +202,8 @@ llvm
|
|||||||
subsampling
|
subsampling
|
||||||
refactor
|
refactor
|
||||||
colorschemes
|
colorschemes
|
||||||
|
gruvbox8
|
||||||
|
gruvbox
|
||||||
Gruvbox
|
Gruvbox
|
||||||
monokai
|
monokai
|
||||||
NeoSolarized
|
NeoSolarized
|
||||||
@@ -436,3 +437,24 @@ PostgreSQL
|
|||||||
CNY
|
CNY
|
||||||
wechat
|
wechat
|
||||||
ziroom
|
ziroom
|
||||||
|
Postgres
|
||||||
|
plpgsql
|
||||||
|
postgres
|
||||||
|
PySpark
|
||||||
|
winbar
|
||||||
|
cmdline
|
||||||
|
shada
|
||||||
|
async
|
||||||
|
localhost
|
||||||
|
JetBrains
|
||||||
|
localhost
|
||||||
|
MariaDB
|
||||||
|
SQLite
|
||||||
|
Pgadmin
|
||||||
|
Datagrip
|
||||||
|
mysql
|
||||||
|
cwd
|
||||||
|
pyright
|
||||||
|
stubgen
|
||||||
|
pylance
|
||||||
|
variadic
|
||||||
|
|||||||
Reference in New Issue
Block a user