Skip to content

Commit

Permalink
Merge pull request #14 from TonyWu20/ayamir-main
Browse files Browse the repository at this point in the history
ayamir main
  • Loading branch information
TonyWu20 authored Apr 26, 2023
2 parents 3ad28f7 + 6cbec4c commit b011b1e
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ body:
options:
- main (Default/Latest)
- 0.8 (Legacy)
- 0.7 (Bug fixes only)
- 0.7 (Deprecated)
validations:
required: true
- type: dropdown
Expand Down
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
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
- 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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/lsp_issue_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ body:
options:
- main (Default/Latest)
- 0.8 (Legacy)
- 0.7 (Bug fixes only)
- 0.7 (Deprecated)
validations:
required: true
- type: dropdown
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
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
29 changes: 29 additions & 0 deletions lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,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
23 changes: 8 additions & 15 deletions lua/core/mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local core_map = {
["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_cmd("<Cmd>noh<CR>"):with_noremap():with_silent():with_desc("edit: Clear search highlight"),
["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 @@ -25,17 +25,17 @@ 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("edit: Save file and quit"),
["n|<A-S-q>"] = map_cmd(":q!<CR>"):with_desc("edit: Force quit"),
["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|+"] = map_cmd("<C-a>"):with_noremap():with_silent():with_desc("edit: Increment"),
["n|-"] = map_cmd("<C-x>"):with_noremap():with_silent():with_desc("edit: Decrement"),
["n|<C-a>"] = map_cmd("gg0vG$"):with_noremap():with_silent():with_desc("edit: Select all"),
["n|tn"] = map_cmd("<Cmd>tabnew<CR>"):with_noremap():with_silent():with_desc("tab: Create a new tab"),
["n|tk"] = map_cmd("<Cmd>tabnext<CR>"):with_noremap():with_silent():with_desc("tab: Move to next tab"),
["n|tj"] = map_cmd("<Cmd>tabprevious<CR>"):with_noremap():with_silent():with_desc("tab: Move to previous tab"),
["n|to"] = map_cmd("<Cmd>tabonly<CR>"):with_noremap():with_silent():with_desc("tab: Only keep current tab"),
["n|<leader><leader>x"] = map_cmd("<Cmd>!chmod +x %<CR>"):with_silent():with_desc("file: chmod +x current file"),
["x|<C-a>"] = map_cmd("<Esc>gg0vG$"):with_noremap():with_silent():with_desc("edit: Select all"),
["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("edit: Delete previous block"),
["i|<C-b>"] = map_cmd("<Left>"):with_noremap():with_desc("edit: Move cursor to left"),
Expand All @@ -60,10 +60,3 @@ local core_map = {
}

bind.nvim_load_mapping(core_map)

vim.api.nvim_set_keymap(
"n",
"<leader><leader>s",
"<Cmd>%s/\\<<C-r><C-w>\\>/<C-r><C-w>/gI<Left><Left><Left>",
{ noremap = true, silent = true, nowait = true, desc = "edit: Start replacment mode of current word" }
)
2 changes: 1 addition & 1 deletion lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,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
4 changes: 4 additions & 0 deletions 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
2 changes: 1 addition & 1 deletion lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ return function()
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)
vim_item.kind = string.format(" %s %s ", kind_symbol, vim_item.kind)

if opts.maxwidth ~= nil then
if opts.ellipsis_char == nil then
Expand Down
30 changes: 21 additions & 9 deletions lua/modules/configs/completion/formatting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ vim.api.nvim_create_user_command("FormatterToggleFt", function(opts)
vim.notify(
string.format("[LSP] Formatter for [%s] has been recorded in list and disabled.", opts.args),
vim.log.levels.WARN,
{ title = "LSP Formatter Warning!" }
{ title = "LSP Formatter Warning" }
)
block_list[opts.args] = true
else
Expand All @@ -39,22 +39,29 @@ function M.enable_format_on_save(is_configured)
group = "format_on_save",
pattern = opts.pattern,
callback = function()
require("completion.formatting").format({ timeout_ms = opts.timeout, filter = M.format_filter })
require("completion.formatting").format({
timeout_ms = opts.timeout,
filter = M.format_filter,
})
end,
})
if not is_configured then
vim.notify(
"Successfully enabled format-on-save",
vim.log.levels.INFO,
{ title = "Settings modification success!" }
{ title = "Settings modification success" }
)
end
end

function M.disable_format_on_save()
pcall(vim.api.nvim_del_augroup_by_name, "format_on_save")
if format_on_save then
vim.notify("Disabled format-on-save", vim.log.levels.INFO, { title = "Settings modification success!" })
vim.notify(
"Successfully disabled format-on-save",
vim.log.levels.INFO,
{ title = "Settings modification success" }
)
end
end

Expand Down Expand Up @@ -95,6 +102,11 @@ function M.format(opts)
local cwd = vim.fn.getcwd()
for i = 1, #disabled_workspaces do
if cwd.find(cwd, disabled_workspaces[i]) ~= nil then
vim.notify(
string.format("[LSP] Formatting support for all files under [%s] is disabled.", disabled_workspaces[i]),
vim.log.levels.WARN,
{ title = "LSP Formatter Warning" }
)
return
end
end
Expand Down Expand Up @@ -122,7 +134,7 @@ function M.format(opts)
vim.notify(
"[LSP] Format request failed, no matching language servers.",
vim.log.levels.WARN,
{ title = "Formatting Failed!" }
{ title = "Formatting Failed" }
)
end

Expand All @@ -136,7 +148,7 @@ function M.format(opts)
vim.bo.filetype
),
vim.log.levels.WARN,
{ title = "LSP Formatter Warning!" }
{ title = "LSP Formatter Warning" }
)
return
end
Expand All @@ -145,15 +157,15 @@ function M.format(opts)
if result and result.result then
vim.lsp.util.apply_text_edits(result.result, bufnr, client.offset_encoding)
vim.notify(
string.format("[LSP] Format successfully with [%s]!", client.name),
string.format("[LSP] Format successfully with %s!", client.name),
vim.log.levels.INFO,
{ title = "LSP Format Success!", timeout = 2000 }
{ title = "LSP Format Success" }
)
elseif err then
vim.notify(
string.format("[LSP][%s] %s", client.name, err),
vim.log.levels.ERROR,
{ title = "LSP Format Error!" }
{ title = "LSP Format Error" }
)
end
end
Expand Down
1 change: 1 addition & 0 deletions lua/modules/configs/lang/vim-pencil.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return function() end
2 changes: 1 addition & 1 deletion lua/modules/configs/tool/project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ return function()
manual_mode = false,
detection_methods = { "lsp", "pattern" },
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" },
ignore_lsp = { "efm", "copilot" },
ignore_lsp = { "null-ls", "copilot" },
exclude_dirs = {},
show_hidden = false,
silent_chdir = true,
Expand Down
1 change: 0 additions & 1 deletion lua/modules/configs/ui/bufferline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ return function()
color_icons = true,
show_buffer_icons = true,
show_buffer_close_icons = true,
show_buffer_default_icon = true,
show_close_icon = true,
show_tab_indicators = true,
enforce_regular_tabs = true,
Expand Down
4 changes: 1 addition & 3 deletions lua/modules/configs/ui/catppuccin.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
return function()
local transparent_background = false -- Set background transparency here!

require("catppuccin").setup({
flavour = "mocha", -- Can be one of: latte, frappe, macchiato, mocha
background = { light = "latte", dark = "mocha" },
Expand All @@ -11,7 +9,7 @@ return function()
shade = "dark",
percentage = 0.15,
},
transparent_background = transparent_background,
transparent_background = require("core.settings").transparent_background,
show_end_of_buffer = false, -- show the '~' characters after the end of buffers
term_colors = true,
compile_path = vim.fn.stdpath("cache") .. "/catppuccin",
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/configs/ui/edge.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ return function()
vim.g.edge_disable_italic_comment = 1
vim.g.edge_show_eob = 1
vim.g.edge_better_performance = 1
vim.g.edge_transparent_background = 1
vim.g.edge_transparent_background = require("core.settings").transparent_background and 2 or 0
end
2 changes: 1 addition & 1 deletion lua/modules/configs/ui/nord.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ return function()
vim.g.nord_contrast = true
vim.g.nord_borders = false
vim.g.nord_cursorline_transparent = true
vim.g.nord_disable_background = false
vim.g.nord_disable_background = require("core.settings").transparent_background
vim.g.nord_enable_sidebar_background = true
vim.g.nord_italic = true
end
2 changes: 1 addition & 1 deletion lua/modules/configs/ui/paint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ return function()
},
{
filter = { filetype = "python" },
pattern = "%s*(%w+:)",
pattern = "%s*([_%w]+:)",
hl = "Constant",
},
},
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ completion["neovim/nvim-lspconfig"] = {
{ "williamboman/mason.nvim" },
{ "williamboman/mason-lspconfig.nvim" },
{
"glepnir/lspsaga.nvim",
"nvimdev/lspsaga.nvim",
config = require("completion.lspsaga"),
},
},
Expand Down
4 changes: 0 additions & 4 deletions lua/modules/plugins/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ editor["RRethy/vim-illuminate"] = {
event = { "CursorHold", "CursorHoldI" },
config = require("editor.vim-illuminate"),
}
editor["luukvbaal/stabilize.nvim"] = {
lazy = true,
event = "BufReadPost",
}
editor["romainl/vim-cool"] = {
lazy = true,
event = { "CursorMoved", "InsertEnter" },
Expand Down
8 changes: 4 additions & 4 deletions lua/modules/utils/icons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ local data = {
cmp = {
Codeium = "",
TabNine = "",
Copilot = "",
Copilot_alt = "",
Copilot = "",
-- Add source-specific icons here
buffer = "",
cmp_tabnine = "",
codeium = "",
cmp_tabnine = "",
codeium = "",
copilot = "",
copilot_alt = "",
latex_symbols = "",
luasnip = "",
nvim_lsp = "",
Expand Down
Loading

0 comments on commit b011b1e

Please sign in to comment.