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

22 Commits

Author SHA1 Message Date
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
21 changed files with 116 additions and 105 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

@@ -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

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

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

@@ -137,31 +137,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

@@ -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

@@ -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

View File

@@ -2,7 +2,8 @@ local api = vim.api
local keymap = vim.keymap
local dashboard = require("dashboard")
dashboard.custom_header = {
conf = {}
conf.header = {
" ",
" ",
" ",
@@ -18,46 +19,52 @@ dashboard.custom_header = {
" ",
}
dashboard.custom_center = {
conf.center = {
{
icon = "",
desc = "Find File ",
action = "Leaderf file --popup",
shortcut = "<Leader> f f",
key = "<Leader> f f",
},
{
icon = "",
desc = "Recently opened files ",
action = "Leaderf mru --popup",
shortcut = "<Leader> f r",
key = "<Leader> f r",
},
{
icon = "",
desc = "Project grep ",
action = "Leaderf rg --popup",
shortcut = "<Leader> f g",
key = "<Leader> f g",
},
{
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 = "",
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

@@ -131,6 +131,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 +154,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 +178,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 +193,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"),

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

View File

@@ -1,5 +1,5 @@
require("nvim-treesitter.configs").setup {
ensure_installed = { "python", "cpp", "lua", "vim" },
ensure_installed = { "python", "cpp", "lua", "vim", "json" },
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

@@ -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