Skip to content

Commit

Permalink
feat!: support Neovim v0.9 (#697)
Browse files Browse the repository at this point in the history
* chore(README): bump supported version

* feat(options): support new options shipped with v0.9

* feat(scripts): support v0.9

* feat!: add initial support for lsp semantic tokens (#633)

* feat(utils): use neovim builtin to get highlights (#632)

* fix: remove deprecated options for nvim-tree.

* fix(cmp): support dynamic `kind_text` from cmp source: `treesitter`, fix #624 #634 (#637)

* fix&feat: introduce suda.vim to write file with sudo

* chore(kind_text): cleanup (#648)

* feat(alpha): add custom highlight groups (#650)

* fix: install `psutils` by default for Windows users

* revert: bind `SudaWrite` to `<A-s>`

ref: #641 (comment)

* fix(cmp): nil `vim_item`

* perf(core-mapping): add some useful mapping

* fix(nvim-tree): `hide_root_folder` is deprecated

* perf: load fidget.nvim after `LspAttach`

* minor fix

1. remove `<nop>` at "n|Q"
2. use visual mode instead of visual-line mode for "n|<C-a>"

* perf: align style

* perf(0.9): `stabilize.nvim` had been upstream to `0.9`

* chore(project.nvim): update legacy code

* chore(README): update branch info

* chore(mapping): cleanup (#657)

* fix(icon): update invalid cmp icon (#665)

* chore/lspsaga_move (#667)

* fix: paint word boundary in python (#669)

* fix(bufferline): `show_buffer_default_icon` is now deprecate

* feat(formatting): notify users for files under disabled dirs

* chore(formatting): rephrase messages

* fix(font-encoding): fix invalid characters on windows, fix #639 (#659)

Co-authored-by: 冷酔閑吟 <[email protected]>

* pref: unify code style for PowerShell commands

* perf: better guidance to `Discussions` and `Wiki` (#680)

* pref(ISSUE_TEMPLATE): fix typos and format with prettier

* fixup! pref(ISSUE_TEMPLATE): fix typos and format with prettier

* feat(scripts): abort for nvim v0.7 and its antecedent

* feat(settings): allow customization of `transparent_background` (#687)

* fix(bufferline): use defaults for `get_element_icon` (#685)

* feat(auto-session): remember opened buffers (#688)

* revert(keymap): remove redundant mappings.

* fix(catppuccin): properly detect `g:colors_name` (#695)

Ref: upstream breaking change [catppuccin/nvim@7a7a664]

---------

Co-authored-by: ayamir <[email protected]>
Co-authored-by: Charles Chiu <[email protected]>
Co-authored-by: CharlesChiuGit <[email protected]>
Co-authored-by: Xie Zejian <[email protected]>
Co-authored-by: AngelontheRoad <[email protected]>
Co-authored-by: Saafo <[email protected]>
  • Loading branch information
7 people authored Apr 30, 2023
1 parent 226031b commit 08c4561
Show file tree
Hide file tree
Showing 25 changed files with 279 additions and 161 deletions.
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

0 comments on commit 08c4561

Please sign in to comment.