1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

36 Commits

Author SHA1 Message Date
jdhao
4a6379ca5d update git-linker conf
1. Add configuration for azure devops
2. change the mappings slightly
2023-08-09 19:52:58 +02:00
jdhao
855a88b532 fix: user lua conf reloading fails
The cache should be invalidated. This fix does not work 100%, because, e.g.,
there are other configs hiding deeper under lua/config/ directory.
A restart is the best way to reload the config.
2023-07-29 14:34:42 +02:00
jdhao
892cd49f06 doc: update doc and install guide for pylsp 2023-07-29 13:09:37 +02:00
jdhao
e53ee104ec feat: move lua conf under lua directory 2023-07-28 22:28:36 +02:00
jdhao
671c78df9b feat: more ignore files for LeaderF (#209) 2023-07-29 04:09:50 +08:00
jdhao
1608a36dd3 fix: conf is not local 2023-07-25 23:00:25 +02:00
jdhao
450f058da5 feat: support venv in Mypy
Specify the correct python executable path for mypy to work well.
2023-07-25 22:59:06 +02:00
jdhao
e2f348cb37 fix: missing nerdfonts
Since wezterm upgrade its support for Nerd Fonts 3.0, we should update
the codepoints used for some of the Unicode Icons. Their code points are
changed due to breaking changes in Nerd Fonts.
2023-07-25 22:53:20 +02:00
jdhao
fc8175d32d feat: update diagnostic mappings
Use separate key mappings to show diagnostics for the current buffer and
all opened files.
2023-07-22 15:01:41 +02:00
jdhao
4034b6b673 feat: update pylsp conf
1. support using black as formatter
2. replace obsolete pyls-isort with maintained ones
2023-07-22 14:51:27 +02:00
jdhao
67a4b6e6d0 feat: add treesitter toml 2023-07-22 14:46:10 +02:00
jdhao
bb27d93433 fix: move location indication to the right of statusline 2023-07-20 23:00:06 +02:00
jdhao
9d9c3ef32f feat: update diagnostic position in statusline
Do not show it in far right, move it to the left side for easier
visibility.
2023-07-20 22:52:55 +02:00
jdhao
00e8c77b23 Fix LeaderF bug
It will add files to buffer list even if we have not confirmed the
selection. This behavior is really annoying.
See also 27bd938a42.
2023-06-27 20:39:26 +02:00
jdhao
7bb3ccc275 use legacy version of fidget for now 2023-06-17 00:08:02 +02:00
jdhao
ee38046ebc Add folding support for JSON files 2023-06-13 22:25:25 +02:00
jdhao
6c873a32da update to nvim 0.9.1 2023-06-03 21:37:14 +02:00
jdhao
9ca65fd942 update conf for nvim-dashboard 2023-05-22 20:50:15 +02:00
jdhao
cc3a7d6ebd remove impatient.nvim
It is not needed since nvim 0.9.0
2023-05-07 20:10:52 +02:00
jdhao
f3a359a2fa conf for nvim 0.9.0 2023-04-20 22:36:48 +02:00
jdhao
9a4d71db88 update nvim-tree conf 2023-04-17 22:05:36 +02:00
jdhao
dc597004df Merge pull request #187 from mr-cal/nvim-tree-update
nvim-tree: fix shortcut and repo
2023-04-17 21:59:43 +02:00
jdhao
644993a89e bump to nvim version 0.9.0 (#188) 2023-04-08 04:42:24 +08:00
Callahan Kovacs
164d6129f8 nvim-tree: update other references
Signed-off-by: Callahan Kovacs <callahankovacs@gmail.com>
2023-04-05 08:37:16 -05:00
Callahan Kovacs
cde21f6f67 nvim-tree: use api and new repository url
Signed-off-by: Callahan Kovacs <callahankovacs@gmail.com>
2023-03-30 08:41:15 -05:00
jdhao
8746c7eb11 fix: omit the clangd missing message, close #180 (#186)
It is not necessary to install clangd if the user does not use neovim with CPP/C.
2023-03-13 19:55:00 +08:00
jdhao
7c44997289 refactor: lua language server rename (#185)
The lua language server from sumneko had changed its repo and created a
new organizational repo. See also https://github.com/neovim/nvim-lspconfig/pull/2439.
2023-02-16 17:39:23 +08:00
jdhao
bfdb3f5a26 bump supported nvim version (#184) 2023-02-11 11:42:57 +08:00
jdhao
76ced0e265 update contact info 2023-01-18 13:27:55 +08:00
jdhao
e84d18a204 update license year (#175) 2023-01-04 01:01:59 +08:00
jdhao
6429e8364c update nvim to version 0.8.2 (#173) 2022-12-31 10:13:39 +08:00
jdhao
f2c6900a8d update setting for onedarkpro (#172) 2022-12-28 22:29:49 +08:00
jdhao
116aaa0675 update spell 2022-12-14 12:55:41 +08:00
jdhao
12f3ca9d1f more abbr (#169) 2022-12-14 12:54:54 +08:00
jdhao
7e7944a30c use yanky.nvim to replace vim-yoink (#168) 2022-12-14 12:52:40 +08:00
bldur
53c17aea96 Add ltex-ls support to lsp. (#166)
* Add ltex-ls support to lsp.

Co-authored-by: bldur (https://github.com/bldur)
2022-11-28 17:35:43 +08:00
25 changed files with 227 additions and 143 deletions

View File

@@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal

View File

@@ -13,7 +13,7 @@
<img alt="Latest release" src="https://img.shields.io/github/v/release/jdhao/nvim-config" />
</a>
<a href="https://github.com/neovim/neovim/releases/tag/stable">
<img src="https://img.shields.io/badge/Neovim-0.8.1-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
<img src="https://img.shields.io/badge/Neovim-0.9.1-blueviolet.svg?style=flat-square&logo=Neovim&logoColor=green" alt="Neovim minimum version"/>
</a>
<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"/>
@@ -21,8 +21,8 @@
<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 href="https://github.com/jdhao/nvim-config/releases/tag/v0.9.1">
<img src="https://img.shields.io/github/commits-since/jdhao/nvim-config/v0.9.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" />
@@ -69,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).
+ Powerful snippet insertion via [Ultisnips](https://github.com/SirVer/ultisnips).
+ 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).
+ 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).

6
after/ftplugin/json.vim Normal file
View File

@@ -0,0 +1,6 @@
" let the initial folding state be that all folds are closed.
set foldlevel=0
" Use nvim-treesitter for folding
set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()

View File

@@ -3,10 +3,6 @@ scriptencoding utf-8
" change fillchars for folding, vertical split, end of buffer, and message separator
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
set splitbelow splitright
@@ -176,6 +172,7 @@ set diffopt+=filler " show filler for deleted lines
set diffopt+=closeoff " turn off diff when one file window is closed
set diffopt+=context:3 " context for diff
set diffopt+=internal,indent-heuristic,algorithm:histogram
set diffopt+=linematch:60
set nowrap " do no wrap
set noruler

View File

@@ -42,7 +42,7 @@ let g:Lf_UseMemoryCache = 0
" Ignore certain files and directories when searching files
let g:Lf_WildIgnore = {
\ 'dir': ['.git', '__pycache__', '.DS_Store'],
\ 'dir': ['.git', '__pycache__', '.DS_Store', '*_cache'],
\ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
\ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz',
\ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp',
@@ -109,6 +109,20 @@ let g:Lf_PopupColorscheme = 'gruvbox_material'
" items.
let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}
" do not preview results, it will add the file to buffer list
let g:Lf_PreviewResult = {
\ 'File': 0,
\ 'Buffer': 0,
\ 'Mru': 0,
\ 'Tag': 0,
\ 'BufTag': 1,
\ 'Function': 1,
\ 'Line': 0,
\ 'Colorscheme': 0,
\ 'Rg': 0,
\ 'Gtags': 0
\}
""""""""""""""""""""""""""""open-browser.vim settings"""""""""""""""""""
if g:is_win || g:is_mac
" Disable netrw's gx mapping.
@@ -137,31 +151,6 @@ let g:mundo_width = 80
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"""""""""""""""""""""""""
let g:better_escape_interval = 200

View File

@@ -65,7 +65,7 @@ pip install -U pynvim
[python-lsp-server (pylsp)](https://github.com/python-lsp/python-lsp-server) is a Python [Language Server](https://microsoft.github.io/language-server-protocol/) for completion, linting, go to definition, etc.
```
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort
pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort python-lsp-black
```
Note the executable for pylsp is also named `pylsp`. You need to set its PATH correctly.

View File

@@ -68,7 +68,7 @@ fi
# Install some Python packages used by Nvim plugins.
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]' "vim-vint" "python-lsp-isort" "pylsp-mypy" "python-lsp-black")
if [[ "$SYSTEM_PYTHON" = true ]]; then
echo "Using system Python to install $(PY_PACKAGES)"
@@ -124,27 +124,27 @@ fi
#######################################################################
# lua-language-server #
#######################################################################
SUMNEKO_LUA_DIR=$HOME/tools/lua-language-server
SUMNEKO_LUA_SRC_NAME=$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_DIR=$HOME/tools/lua-language-server
LUA_LS_SRC=$HOME/packages/lua-language-server.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'
if [[ ! -f $SUMNEKO_LUA_SRC_NAME ]]; then
if [[ ! -f $LUA_LS_SRC ]]; then
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
if [[ ! -d "$SUMNEKO_LUA_DIR" ]]; then
if [[ ! -d "$LUA_LS_DIR" ]]; then
echo "Creating lua-language-server directory under tools directory"
mkdir -p "$SUMNEKO_LUA_DIR"
echo "Extracting to directory $SUMNEKO_LUA_DIR"
mkdir -p "$LUA_LS_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
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
else
echo "lua-language-server is already installed. Skip installing it."

View File

@@ -27,7 +27,7 @@ scoop install miniconda3
pip install -U pynvim
# Install python-language-server
pip install 'python-lsp-server[all]' pylsp-mypy pyls-isort
pip install 'python-lsp-server[all]' pylsp-mypy python-lsp-isort
# Install visual c++ redistribution
scoop install vcredist2022
@@ -36,19 +36,19 @@ scoop install vcredist2022
scoop install 7zip
# 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"
$sumneko_lua_install_dir = "D:\portable_tools"
$sumneko_lua_src_dir = "$sumneko_lua_install_dir\lua-language-server.zip"
$sumneko_lua_dir = "$sumneko_lua_install_dir\lua-language-server"
$lua_ls_link = "https://github.com/LuaLS/lua-language-server/releases/download/3.6.11/lua-language-server-3.6.11-win32-x64.zip"
$lua_ls_install_dir = "D:\portable_tools"
$lua_ls_src_path = "$lua_ls_install_dir\lua-language-server.zip"
$lua_ls_dir = "$lua_ls_install_dir\lua-language-server"
# 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
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
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$sumneko_lua_dir\bin", "Machine")
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$lua_ls_dir\bin", "Machine")
# Install neovim nightly
scoop bucket add versions

View File

@@ -4,19 +4,24 @@
-- I would not recommend cloning this repo and replace your own config. Good configurations are personal,
-- built over time with a lot of polish.
--
-- Author: Jie-dong Hao
-- Author: Jiedong Hao
-- Email: jdhao@hotmail.com
-- Blog: https://jdhao.github.io/
-- GitHub: https://github.com/jdhao
-- StackOverflow: https://stackoverflow.com/users/6064933/jdhao
vim.loader.enable()
local api = vim.api
local utils = require("utils")
local version = vim.version
-- check if we have the latest stable version of nvim
local expected_ver = "0.8.1"
local nvim_ver = utils.get_nvim_version()
local expected_ver = "0.9.1"
local ev = version.parse(expected_ver)
local actual_ver = version()
if nvim_ver ~= expected_ver then
local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver)
if version.cmp(ev, actual_ver) ~= 0 then
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)
return
end
@@ -31,8 +36,14 @@ local core_conf_files = {
}
-- source all the core config files
for _, name in ipairs(core_conf_files) do
local path = string.format("%s/core/%s", vim.fn.stdpath("config"), name)
for _, file_name in ipairs(core_conf_files) do
if vim.endswith(file_name, 'vim') then
local path = string.format("%s/core/%s", vim.fn.stdpath("config"), file_name)
local source_cmd = "source " .. path
vim.cmd(source_cmd)
else
local module_name, _ = string.gsub(file_name, "%.lua", "")
package.loaded[module_name] = nil
require(module_name)
end
end

View File

@@ -105,12 +105,8 @@ M.rose_pine = function()
end
M.onedarkpro = function()
require("onedarkpro").setup({
dark_theme = "onedark", -- The default dark theme
})
-- set colorscheme after options
vim.cmd('colorscheme onedarkpro')
vim.cmd('colorscheme onedark_vivid')
end
M.monokai = function()

View File

@@ -9,7 +9,7 @@ require("bufferline").setup {
icon = "", -- this should be omitted if indicator style is not 'icon'
style = "icon",
},
buffer_close_icon = "",
buffer_close_icon = "",
modified_icon = "",
close_icon = "",
left_trunc_marker = "",

View File

@@ -2,7 +2,8 @@ local api = vim.api
local keymap = vim.keymap
local dashboard = require("dashboard")
dashboard.custom_header = {
local conf = {}
conf.header = {
" ",
" ",
" ",
@@ -18,46 +19,52 @@ dashboard.custom_header = {
" ",
}
dashboard.custom_center = {
conf.center = {
{
icon = " ",
icon = "󰈞 ",
desc = "Find File ",
action = "Leaderf file --popup",
shortcut = "<Leader> f f",
key = "<Leader> f f",
},
{
icon = " ",
icon = "󰈢 ",
desc = "Recently opened files ",
action = "Leaderf mru --popup",
shortcut = "<Leader> f r",
key = "<Leader> f r",
},
{
icon = " ",
icon = "󰈬 ",
desc = "Project grep ",
action = "Leaderf rg --popup",
shortcut = "<Leader> f g",
key = "<Leader> f g",
},
{
icon = " ",
icon = " ",
desc = "Open Nvim config ",
action = "tabnew $MYVIMRC | tcd %:p:h",
shortcut = "<Leader> e v",
key = "<Leader> e v",
},
{
icon = "",
desc = "New file ",
action = "enew",
shortcut = "e ",
key = "e",
},
{
icon = " ",
icon = "󰗼 ",
desc = "Quit Nvim ",
-- desc = "Quit Nvim ",
action = "qa",
shortcut = "q ",
key = "q",
},
}
dashboard.setup({
theme = 'doom',
shortcut_type = 'number',
config = conf
})
api.nvim_create_autocmd("FileType", {
pattern = "dashboard",
group = api.nvim_create_augroup("dashboard_enter", { clear = true }),

View File

@@ -2,24 +2,36 @@ local keymap = vim.keymap
local gitlinker = require("gitlinker")
gitlinker.setup {
callbacks = {
["dev.azure.com"] = function(url_data)
vim.print(url_data)
local url = require"gitlinker.hosts".get_base_https_url(url_data)
if url_data.lstart then
if url_data.lend == nil then
url_data.lend = url_data.lstart
end
url = url .. "?path=/" .. url_data.file .. "&version=GC" .. url_data.rev .. "&line=" .. url_data.lstart .. "&lineEnd=" .. url_data.lend .. "&lineStartColumn=1" .. "&lineEndColumn=120"
end
return url
end
},
mappings = nil,
}
keymap.set({ "n", "v" }, "<leader>gl", "", {
silent = true,
desc = "get git permlink",
callback = function()
keymap.set({ "n", "v" }, "<leader>gl", function()
local mode = string.lower(vim.fn.mode())
gitlinker.get_buf_range_url(mode)
end,
end, {
silent = true,
desc = "get git permlink",
})
keymap.set("n", "<leader>gb", "", {
silent = true,
desc = "browse repo in browser",
callback = function()
keymap.set("n", "<leader>gb", function()
gitlinker.get_repo_url({
action_callback = gitlinker.actions.open_in_browser
})
end
end, {
silent = true,
desc = "browse repo in browser",
})

View File

@@ -6,6 +6,18 @@ local diagnostic = vim.diagnostic
local utils = require("utils")
-- set quickfix list from diagnostics in a certain buffer, not the whole workspace
local set_qflist = function(buf_num, severity)
local diagnostics = nil
diagnostics = diagnostic.get(buf_num, { severity = severity })
local qf_items = diagnostic.toqflist(diagnostics)
vim.fn.setqflist({}, ' ', { title = 'Diagnostics', items = qf_items })
-- open quickfix by default
vim.cmd[[copen]]
end
local custom_attach = function(client, bufnr)
-- Mappings.
local map = function(mode, l, r, opts)
@@ -23,7 +35,10 @@ local custom_attach = function(client, bufnr)
map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" })
map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" })
map("n", "<space>q", diagnostic.setqflist, { desc = "put diagnostic to qf" })
-- this puts diagnostics from opened files to quickfix
map("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
-- this puts diagnostics from current buffer to quickfix
map("n", "<space>qb", function() set_qflist(bufnr) end, { desc = "put buffer diagnostics to qf" })
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>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
@@ -99,17 +114,40 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require("lspconfig")
if utils.executable("pylsp") then
local venv_path = os.getenv('VIRTUAL_ENV')
local py_path = nil
-- decide which python executable to use for mypy
if venv_path ~= nil then
py_path = venv_path .. "/bin/python3"
else
py_path = vim.g.python3_host_prog
end
lspconfig.pylsp.setup {
on_attach = custom_attach,
settings = {
pylsp = {
plugins = {
-- formatter options
black = { enabled = true },
autopep8 = { enabled = false },
yapf = { enabled = false },
-- linter options
pylint = { enabled = true, executable = "pylint" },
ruff = { enabled = false },
pyflakes = { enabled = false },
pycodestyle = { enabled = false },
-- type checker
pylsp_mypy = {
enabled = true,
overrides = { "--python-executable", py_path, true },
report_progress = true,
live_mode = false
},
-- auto-completion options
jedi_completion = { fuzzy = true },
pyls_isort = { enabled = true },
pylsp_mypy = { enabled = true },
-- import sorting
isort = { enabled = true },
},
},
},
@@ -131,6 +169,20 @@ end
-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Nvim-config'})
-- end
if utils.executable("ltex-ls") then
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,
@@ -140,8 +192,6 @@ if utils.executable("clangd") then
debounce_text_changes = 500,
},
}
else
vim.notify("clangd not found!", vim.log.levels.WARN, { title = "Nvim-config" })
end
-- set up vim-language-server
@@ -166,8 +216,8 @@ if utils.executable("bash-language-server") then
end
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 .
lspconfig.sumneko_lua.setup {
-- settings for lua-language-server can be found on https://github.com/LuaLS/lua-language-server/wiki/Settings .
lspconfig.lua_ls.setup {
on_attach = custom_attach,
settings = {
Lua = {
@@ -181,8 +231,8 @@ if utils.executable("lua-language-server") then
},
workspace = {
-- Make the server aware of Neovim runtime files,
-- see also https://github.com/sumneko/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 .
-- see also https://github.com/LuaLS/lua-language-server/wiki/Libraries#link-to-workspace .
-- Lua-dev.nvim also has similar settings for lua ls, https://github.com/folke/neodev.nvim/blob/main/lua/neodev/luals.lua .
library = {
fn.stdpath("data") .. "/site/pack/packer/opt/emmylua-nvim",
fn.stdpath("config"),
@@ -197,10 +247,10 @@ if utils.executable("lua-language-server") then
end
-- Change diagnostic signs.
fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" })
fn.sign_define("DiagnosticSignWarn", { text = "!", texthl = "DiagnosticSignWarn" })
fn.sign_define("DiagnosticSignInformation", { text = "", texthl = "DiagnosticSignInfo" })
fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" })
fn.sign_define("DiagnosticSignError", { text = '🆇', texthl = "DiagnosticSignError" })
fn.sign_define("DiagnosticSignWarn", { text = '⚠️', texthl = "DiagnosticSignWarn" })
fn.sign_define("DiagnosticSignInfo", { text = '', texthl = "DiagnosticSignInfo" })
fn.sign_define("DiagnosticSignHint", { text = '', texthl = "DiagnosticSignHint" })
-- global config for diagnostic
diagnostic.config {

View File

@@ -7,9 +7,6 @@ nvim_tree.setup {
hijack_cursor = false,
hijack_netrw = true,
hijack_unnamed_buffer_when_opening = false,
ignore_buffer_on_setup = false,
open_on_setup = false,
open_on_setup_file = false,
open_on_tab = false,
sort_by = "name",
update_cwd = false,
@@ -50,7 +47,6 @@ nvim_tree.setup {
update_cwd = false,
ignore_list = {},
},
ignore_ft_on_setup = {},
system_open = {
cmd = "",
args = {},
@@ -113,6 +109,7 @@ nvim_tree.setup {
},
}
keymap.set("n", "<space>s", function()
return require("nvim-tree").toggle(false, true)
end, { silent = true, desc = "toggle nvim-tree" })
keymap.set("n", "<space>s", require("nvim-tree.api").tree.toggle, {
silent = true,
desc = "toggle nvim-tree",
})

View File

@@ -93,7 +93,7 @@ local diff = function()
local add_num = git_status.added
local info = { added = add_num, modified = modify_num, removed = remove_num }
-- vim.pretty_print(info)
-- vim.print(info)
return info
end
@@ -127,6 +127,11 @@ require("lualine").setup {
spell,
color = { fg = "black", bg = "#a7c080" },
},
{
"diagnostics",
sources = { "nvim_diagnostic" },
symbols = {error = '🆇 ', warn = '⚠️ ', info = ' ', hint = ''},
},
},
lualine_x = {
"encoding",
@@ -140,13 +145,11 @@ require("lualine").setup {
},
"filetype",
},
lualine_y = { "progress" },
lualine_z = {
lualine_y = {
"location",
{
"diagnostics",
sources = { "nvim_diagnostic" },
"progress",
},
lualine_z = {
{
trailing_space,
color = "WarningMsg",

View File

@@ -1,5 +1,5 @@
require("nvim-treesitter.configs").setup {
ensure_installed = { "python", "cpp", "lua", "vim" },
ensure_installed = { "python", "cpp", "lua", "vim", "json", "toml" },
ignore_install = {}, -- List of parsers to ignore installing
highlight = {
enable = true, -- false will disable the whole extension

13
lua/config/yanky.lua Normal file
View 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)")

View File

@@ -5,7 +5,7 @@ local utils = require('utils')
-- Inspect something
function _G.inspect(item)
vim.pretty_print(item)
vim.print(item)
end
------------------------------------------------------------------------

View File

@@ -43,9 +43,6 @@ end
packer.startup {
function(use)
-- it is recommended to put impatient.nvim before any other plugins
use { "lewis6991/impatient.nvim", config = [[require('impatient')]] }
use { "wbthomason/packer.nvim", opt = true }
use { "onsails/lspkind-nvim", event = "VimEnter" }
@@ -137,7 +134,7 @@ packer.startup {
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 {
"nvim-lualine/lualine.nvim",
@@ -151,7 +148,7 @@ packer.startup {
config = [[require('config.bufferline')]] }
-- fancy start screen
use { "glepnir/dashboard-nvim", event = "VimEnter",
use { "nvimdev/dashboard-nvim", event = "VimEnter",
cond = firenvim_not_active,
config = [[require('config.dashboard-nvim')]]
}
@@ -208,10 +205,14 @@ packer.startup {
-- Show undo history visually
use { "simnalamburt/vim-mundo", cmd = { "MundoToggle", "MundoShow" } }
-- better UI for some nvim actions
use {'stevearc/dressing.nvim'}
-- Manage your yank history
if vim.g.is_win or vim.g.is_mac then
use { "svermeulen/vim-yoink", event = "VimEnter" }
end
use({
"gbprod/yanky.nvim",
config = [[require('config.yanky')]]
})
-- Handy unix command inside Vim (Rename, Move etc.)
use { "tpope/vim-eunuch", cmd = { "Rename", "Delete" } }
@@ -354,14 +355,14 @@ packer.startup {
-- file explorer
use {
"kyazdani42/nvim-tree.lua",
requires = { "kyazdani42/nvim-web-devicons" },
"nvim-tree/nvim-tree.lua",
requires = { "nvim-tree/nvim-web-devicons" },
config = [[require('config.nvim-tree')]],
}
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", tag = "legacy", config = [[require('config.fidget-nvim')]] }
end,
config = {
max_jobs = 16,

View File

@@ -31,13 +31,6 @@ function M.may_create_dir(dir)
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,
--- adapted from https://stackoverflow.com/a/12739441/6064933
--- @low: the lower value for this range

View File

@@ -1,2 +1,3 @@
" some abbreviations
iabbrev reqire require
iabbrev serveral several

View File

@@ -45,3 +45,6 @@ function! s:md_to_pdf() abort
echoerr "Error running command"
endif
endfunction
" json format
command! -range JSONFormat <line1>,<line2>!python -m json.tool

View File

@@ -453,3 +453,8 @@ SQLite
Pgadmin
Datagrip
mysql
cwd
pyright
stubgen
pylance
variadic