Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: support Neovim v0.9 #697

Merged
merged 52 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
cec7c7b
chore(README): bump supported version
Jint-lzxy Apr 9, 2023
4fa58dc
feat(options): support new options shipped with v0.9
Jint-lzxy Apr 8, 2023
d1798df
feat(scripts): support v0.9
Jint-lzxy Apr 8, 2023
7155d96
feat!: add initial support for lsp semantic tokens (#633)
Jint-lzxy Apr 10, 2023
32febc1
feat(utils): use neovim builtin to get highlights (#632)
Jint-lzxy Apr 10, 2023
8592b7e
Merge branch 'main' into 0.9
Jint-lzxy Apr 10, 2023
bcc4b87
Merge pull request #630 from ayamir/feat/0.9-scripts
ayamir Apr 10, 2023
98a789f
Merge pull request #631 from ayamir/feat/0.9-options
ayamir Apr 10, 2023
7e4bfa2
fix: remove deprecated options for nvim-tree.
ayamir Apr 11, 2023
55dc993
fix(cmp): support dynamic `kind_text` from cmp source: `treesitter`, …
CharlesChiuGit Apr 11, 2023
cd9776e
Merge pull request #645 from ayamir/fix/nvim-tree
ayamir Apr 11, 2023
d090c47
Merge branch 'main' into 0.9
Jint-lzxy Apr 11, 2023
7dd7f0f
fix&feat: introduce suda.vim to write file with sudo
ayamir Apr 10, 2023
80573d6
chore(kind_text): cleanup (#648)
Jint-lzxy Apr 11, 2023
0f101a1
feat(alpha): add custom highlight groups (#650)
Jint-lzxy Apr 11, 2023
a9752b7
fix: install `psutils` by default for Windows users
Jint-lzxy Apr 11, 2023
70dedba
revert: bind `SudaWrite` to `<A-s>`
Jint-lzxy Apr 11, 2023
b02c8bc
Merge pull request #641 from ayamir/fix/sudo
ayamir Apr 11, 2023
00c063d
fix(cmp): nil `vim_item`
CharlesChiuGit Apr 12, 2023
30310e2
perf(core-mapping): add some useful mapping
CharlesChiuGit Apr 12, 2023
aa04de3
fix(nvim-tree): `hide_root_folder` is deprecated
Jint-lzxy Apr 12, 2023
68fefe7
perf: load fidget.nvim after `LspAttach`
Jint-lzxy Apr 12, 2023
bab92a1
Merge pull request #652 from ayamir/minor-patch
ayamir Apr 12, 2023
177cda4
minor fix
CharlesChiuGit Apr 12, 2023
47e6f04
perf: align style
CharlesChiuGit Apr 12, 2023
12572d1
perf(0.9): `stabilize.nvim` had been upstream to `0.9`
CharlesChiuGit Apr 13, 2023
f9668ae
chore(project.nvim): update legacy code
CharlesChiuGit Apr 13, 2023
775795a
Merge pull request #655 from ayamir/perf/0.9patch
ayamir Apr 13, 2023
bda4aac
chore(README): update branch info
Jint-lzxy Apr 13, 2023
fccf351
chore(mapping): cleanup (#657)
Jint-lzxy Apr 13, 2023
e533b2a
fix(icon): update invalid cmp icon (#665)
CharlesChiuGit Apr 18, 2023
f0fa437
chore/lspsaga_move (#667)
CharlesChiuGit Apr 19, 2023
62417b1
fix: paint word boundary in python (#669)
fecet Apr 19, 2023
ecaba00
fix(bufferline): `show_buffer_default_icon` is now deprecate
CharlesChiuGit Apr 21, 2023
9189c59
Merge pull request #673 from ayamir/chore/bufferline-4.0.0
ayamir Apr 21, 2023
6c6912b
feat(formatting): notify users for files under disabled dirs
Jint-lzxy Apr 22, 2023
75f4dc8
chore(formatting): rephrase messages
Jint-lzxy Apr 22, 2023
be8150f
Merge pull request #678 from ayamir/feat/more-notifications
ayamir Apr 22, 2023
e2cfef9
fix(font-encoding): fix invalid characters on windows, fix #639 (#659)
CharlesChiuGit Apr 23, 2023
f2f3c2c
pref: unify code style for PowerShell commands
Jint-lzxy Apr 23, 2023
4e56030
perf: better guidance to `Discussions` and `Wiki` (#680)
CharlesChiuGit Apr 25, 2023
e679eae
pref(ISSUE_TEMPLATE): fix typos and format with prettier
Jint-lzxy Apr 25, 2023
b00c182
Merge branch 'main' into 0.9
Jint-lzxy Apr 25, 2023
24c9bef
fixup! pref(ISSUE_TEMPLATE): fix typos and format with prettier
Jint-lzxy Apr 25, 2023
a5c8d33
feat(scripts): abort for nvim v0.7 and its antecedent
Jint-lzxy Apr 25, 2023
7b11447
feat(settings): allow customization of `transparent_background` (#687)
AngelontheRoad Apr 25, 2023
6d55f06
fix(bufferline): use defaults for `get_element_icon` (#685)
Jint-lzxy Apr 26, 2023
f3520c9
Merge pull request #686 from ayamir/feat/deprecate-0.7
ayamir Apr 26, 2023
e15ac1c
feat(auto-session): remember opened buffers (#688)
Saafo Apr 26, 2023
f9ca549
revert(keymap): remove redundant mappings.
ayamir Apr 27, 2023
d94d6d2
Merge branch 'main' into 0.9
Jint-lzxy Apr 30, 2023
eccd1d8
fix(catppuccin): properly detect `g:colors_name` (#695)
Jint-lzxy Apr 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
blank_issues_enabled: false
blank_issues_enabled: true
contact_links:
- name: GitHub Discussions
url: https://github.com/ayamir/nvimdots/discussions/new/choose
about: Any issue that does not fall into the above categories shall go here.
about: Any issue that does not fall into the above categories shall go here
- name: GitHub Wiki
url: https://github.com/ayamir/nvimdots/wiki
about: Make sure you have checked our documentation first. To be explicit, the "Issues" section.
about: Make sure you have checked our documentation first. To be explicit, the "Issues" section
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<a href="https://github.com/neovim/neovim/releases/tag/stable">
<img
alt="NeoVim Version Capability"
src="https://img.shields.io/badge/Supports%20Nvim-v0.8-A6D895?style=for-the-badge&colorA=363A4F&logo=neovim&logoColor=D9E0EE">
src="https://img.shields.io/badge/Supports%20Nvim-v0.9-A6D895?style=for-the-badge&colorA=363A4F&logo=neovim&logoColor=D9E0EE">
</a>
<a href="https://github.com/ayamir/nvimdots/releases">
<img
Expand Down Expand Up @@ -38,14 +38,15 @@

This repo hosts my [NeoVim](https://neovim.io/) configuration for Linux, macOS, and Windows. `init.lua` is the config entry point.

It contains two branches:
Branch info:

<div align="center">

| Branch | Completion Solution |
| :----: | :------------------------: |
| main | config for nvim 0.8 stable |
| 0.7 | config for nvim 0.7 stable |
| Branch | Supported neovim version |
| :----: | :----------------------: |
| main | nvim 0.9 stable |
| 0.8 | nvim 0.8 |
| 0.7 | nvim 0.7 |

</div>

Expand Down
32 changes: 32 additions & 0 deletions lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ local disable_distribution_plugins = function()
-- Disable sql omni completion.
vim.g.loaded_sql_completion = 1

-- Disable EditorConfig support
vim.g.editorconfig = 1

-- Disable remote plugins
-- NOTE: Disabling rplugin.vim will show error for `wilder.nvim` in :checkhealth,
-- NOTE: but since it's config doesn't require python rtp, it's fine to ignore.
Expand Down Expand Up @@ -112,13 +115,42 @@ local clipboard_config = function()
end
end

local shell_config = function()
if global.is_windows then
if not (vim.fn.executable("pwsh") or vim.fn.executable("powershell")) then
vim.notify(
[[
Failed to setup terminal config

PowerShell is either not installed, missing from PATH, or not executable;
cmd.exe will be used instead for `:!` (shell bang) and toggleterm.nvim.

You're recommended to install PowerShell for better experience.]],
vim.log.levels.WARN,
{ title = "[core] Runtime error" }
)
return
end

local basecmd = "-NoLogo -MTA -ExecutionPolicy RemoteSigned"
local ctrlcmd = "-Command [console]::InputEncoding = [console]::OutputEncoding = [System.Text.Encoding]::UTF8"
vim.api.nvim_set_option_value("shell", vim.fn.executable("pwsh") and "pwsh" or "powershell", {})
vim.api.nvim_set_option_value("shellcmdflag", string.format("%s %s;", basecmd, ctrlcmd), {})
vim.api.nvim_set_option_value("shellredir", "-RedirectStandardOutput %s -NoNewWindow -Wait", {})
vim.api.nvim_set_option_value("shellpipe", "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode", {})
vim.api.nvim_set_option_value("shellquote", nil, {})
vim.api.nvim_set_option_value("shellxquote", nil, {})
end
end

local load_core = function()
createdir()
disable_distribution_plugins()
leader_map()

neovide_config()
clipboard_config()
shell_config()

require("core.options")
require("core.mapping")
Expand Down
61 changes: 31 additions & 30 deletions lua/core/mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ local map_cmd = bind.map_cmd

local core_map = {
-- Suckless
["n|<S-Tab>"] = map_cr("normal za"):with_noremap():with_silent():with_desc("editn: Toggle code fold"),
["n|<C-s>"] = map_cu("write"):with_noremap():with_silent():with_desc("editn: Save file"),
["n|<C-S-s>"] = map_cmd("execute 'silent! write !sudo tee % >/dev/null' <bar> edit!")
:with_silent()
:with_noremap()
:with_desc("editn: Save file using sudo"),
["n|Y"] = map_cmd("y$"):with_desc("editn: Yank text to EOL"),
["n|D"] = map_cmd("d$"):with_desc("editn: Delete text to EOL"),
["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("editn: Next search result"),
["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("editn: Prev search result"),
["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("editn: Join next line"),
["n|<S-Tab>"] = map_cr("normal za"):with_noremap():with_silent():with_desc("edit: Toggle code fold"),
["n|<C-s>"] = map_cu("write"):with_noremap():with_silent():with_desc("edit: Save file"),
["n|Y"] = map_cmd("y$"):with_desc("edit: Yank text to EOL"),
["n|D"] = map_cmd("d$"):with_desc("edit: Delete text to EOL"),
["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("edit: Next search result"),
["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("edit: Prev search result"),
["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("edit: Join next line"),
["n|<Esc>"] = map_cr("noh"):with_noremap():with_silent():with_desc("edit: Clear search highlight"),
["n|<C-h>"] = map_cmd("<C-w>h"):with_noremap():with_desc("window: Focus left"),
["n|<C-l>"] = map_cmd("<C-w>l"):with_noremap():with_desc("window: Focus right"),
["n|<C-j>"] = map_cmd("<C-w>j"):with_noremap():with_desc("window: Focus down"),
Expand All @@ -28,30 +25,34 @@ local core_map = {
["n|<A-]>"] = map_cr("vertical resize +5"):with_silent():with_desc("window: Resize +5 vertically"),
["n|<A-;>"] = map_cr("resize -2"):with_silent():with_desc("window: Resize -2 horizontally"),
["n|<A-'>"] = map_cr("resize +2"):with_silent():with_desc("window: Resize +2 horizontally"),
["n|<C-q>"] = map_cmd(":wq<CR>"):with_desc("editn: Save file and quit"),
["n|<A-S-q>"] = map_cmd(":q!<CR>"):with_desc("editn: Force quit"),
["n|<leader>o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("editn: Toggle spell check"),
["n|<C-q>"] = map_cr("wq"):with_desc("edit: Save file and quit"),
["n|<A-S-q>"] = map_cr("q!"):with_desc("edit: Force quit"),
["n|<leader>o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"),
["n|tn"] = map_cr("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"),
["n|tk"] = map_cr("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"),
["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"),
["n|to"] = map_cr("tabonly"):with_noremap():with_silent():with_desc("tab: Only keep current tab"),
-- Insert mode
["i|<C-u>"] = map_cmd("<C-G>u<C-U>"):with_noremap():with_desc("editi: Delete previous block"),
["i|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("editi: Move cursor to left"),
["i|<C-a>"] = map_cmd("<ESC>^i"):with_noremap():with_desc("editi: Move cursor to line start"),
["i|<C-s>"] = map_cmd("<Esc>:w<CR>"):with_desc("editi: Save file"),
["i|<C-q>"] = map_cmd("<Esc>:wq<CR>"):with_desc("editi: Save file and quit"),
["i|<C-u>"] = map_cmd("<C-G>u<C-U>"):with_noremap():with_desc("edit: Delete previous block"),
["i|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Move cursor to left"),
["i|<C-a>"] = map_cmd("<ESC>^i"):with_noremap():with_desc("edit: Move cursor to line start"),
["i|<C-s>"] = map_cmd("<Esc>:w<CR>"):with_desc("edit: Save file"),
["i|<C-q>"] = map_cmd("<Esc>:wq<CR>"):with_desc("edit: Save file and quit"),
-- Command mode
["c|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("editc: Left"),
["c|<C-f>"] = map_cmd("<Right>"):with_noremap():with_desc("editc: Right"),
["c|<C-a>"] = map_cmd("<Home>"):with_noremap():with_desc("editc: Home"),
["c|<C-e>"] = map_cmd("<End>"):with_noremap():with_desc("editc: End"),
["c|<C-d>"] = map_cmd("<Del>"):with_noremap():with_desc("editc: Delete"),
["c|<C-h>"] = map_cmd("<BS>"):with_noremap():with_desc("editc: Backspace"),
["c|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Left"),
["c|<C-f>"] = map_cmd("<Right>"):with_noremap():with_desc("edit: Right"),
["c|<C-a>"] = map_cmd("<Home>"):with_noremap():with_desc("edit: Home"),
["c|<C-e>"] = map_cmd("<End>"):with_noremap():with_desc("edit: End"),
["c|<C-d>"] = map_cmd("<Del>"):with_noremap():with_desc("edit: Delete"),
["c|<C-h>"] = map_cmd("<BS>"):with_noremap():with_desc("edit: Backspace"),
["c|<C-t>"] = map_cmd([[<C-R>=expand("%:p:h") . "/" <CR>]])
:with_noremap()
:with_desc("editc: Complete path of current file"),
:with_desc("edit: Complete path of current file"),
-- Visual mode
["v|J"] = map_cmd(":m '>+1<CR>gv=gv"):with_desc("editv: Move this line down"),
["v|K"] = map_cmd(":m '<-2<CR>gv=gv"):with_desc("editv: Move this line up"),
["v|<"] = map_cmd("<gv"):with_desc("editv: Decrease indent"),
["v|>"] = map_cmd(">gv"):with_desc("editv: Increase indent"),
["v|J"] = map_cmd(":m '>+1<CR>gv=gv"):with_desc("edit: Move this line down"),
["v|K"] = map_cmd(":m '<-2<CR>gv=gv"):with_desc("edit: Move this line up"),
["v|<"] = map_cmd("<gv"):with_desc("edit: Decrease indent"),
["v|>"] = map_cmd(">gv"):with_desc("edit: Increase indent"),
}

bind.nvim_load_mapping(core_map)
7 changes: 4 additions & 3 deletions lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local function load_options()
conceallevel = 0,
cursorcolumn = true,
cursorline = true,
diffopt = "filler,iwhite,internal,algorithm:patience",
diffopt = "filler,iwhite,internal,linematch:60,algorithm:patience",
display = "lastline",
encoding = "utf-8",
equalalways = false,
Expand Down Expand Up @@ -58,7 +58,7 @@ local function load_options()
relativenumber = true,
ruler = true,
scrolloff = 2,
sessionoptions = "curdir,help,tabpages,winsize",
sessionoptions = "buffers,curdir,help,tabpages,winsize",
shada = "!,'300,<50,@100,s10,h",
shiftround = true,
shiftwidth = 4,
Expand All @@ -73,6 +73,7 @@ local function load_options()
smarttab = true,
softtabstop = 4,
splitbelow = true,
splitkeep = "cursor",
splitright = true,
startofline = false,
swapfile = false,
Expand Down Expand Up @@ -124,7 +125,7 @@ local function load_options()
-- Fix sqlite3 missing-lib issue on Windows
if global.is_windows then
-- Download the DLLs form https://www.sqlite.org/download.html
vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400100/sqlite3.dll"
vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400200/sqlite3.dll"
end
end

Expand Down
5 changes: 4 additions & 1 deletion lua/core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ settings["palette_overwrite"] = {}
---@type string
settings["colorscheme"] = "catppuccin"

-- Set it to true if your terminal has transparent background.
---@type boolean
settings["transparent_background"] = false

-- Set background color to use here.
-- Useful if you would like to use a colorscheme that has a light and dark variant like `edge`.
-- Valid values are: `dark`, `light`.
Expand Down Expand Up @@ -79,7 +83,6 @@ settings["lsp_deps"] = {
settings["null_ls_deps"] = {
"black",
"clang_format",
"editorconfig_checker",
"prettier",
"rustfmt",
"shfmt",
Expand Down
3 changes: 3 additions & 0 deletions lua/keymap/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ local plug_map = {
-- Plugin: tabout
["i|<A-l>"] = map_cmd("<Plug>(TaboutMulti)"):with_silent():with_noremap():with_desc("edit: Goto end of pair"),
["i|<A-h>"] = map_cmd("<Plug>(TaboutBackMulti)"):with_silent():with_noremap():with_desc("edit: Goto begin of pair"),

-- Plugin suda.vim
["n|<A-s>"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"),
}

bind.nvim_load_mapping(plug_map)
53 changes: 44 additions & 9 deletions lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,35 @@ return function()
return (diff < 0)
end

local lspkind = require("lspkind")
local function cmp_format(opts)
opts = opts or {}

return function(entry, vim_item)
if opts.before then
vim_item = opts.before(entry, vim_item)
end

local kind_symbol = opts.symbol_map[vim_item.kind] or icons.kind.Undefined
local source_symbol = opts.symbol_map[entry.source.name] or icons.cmp.undefined

vim_item.menu = " " .. source_symbol .. " |"
vim_item.kind = string.format(" 〔 %s %s 〕", kind_symbol, vim_item.kind)

if opts.maxwidth ~= nil then
if opts.ellipsis_char == nil then
vim_item.abbr = string.sub(vim_item.abbr, 1, opts.maxwidth)
else
local label = vim_item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, opts.maxwidth)
if truncated_label ~= label then
vim_item.abbr = truncated_label .. opts.ellipsis_char
end
end
end
return vim_item
end
end

local cmp = require("cmp")

cmp.setup({
Expand Down Expand Up @@ -72,16 +100,13 @@ return function()
},
},
formatting = {
fields = { "kind", "abbr", "menu" },
fields = { "menu", "abbr", "kind" },
format = function(entry, vim_item)
local kind = lspkind.cmp_format({
mode = "symbol_text",
local kind_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp)
local kind = cmp_format({
maxwidth = 50,
symbol_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp),
symbol_map = kind_map,
})(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. strings[1] .. " "
kind.menu = " (" .. strings[2] .. ")"
return kind
end,
},
Expand Down Expand Up @@ -123,7 +148,17 @@ return function()
{ name = "nvim_lua" },
{ name = "luasnip" },
{ name = "path" },
{ name = "treesitter" },
{
name = "treesitter",
entry_filter = function(entry)
local ignore_list = {
"Error",
"Comment",
}
local kind = entry:get_completion_item().cmp.kind_text
return not vim.tbl_contains(ignore_list, kind)
end,
},
{ name = "spell" },
{ name = "tmux" },
{ name = "orgmode" },
Expand Down
Loading