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

ayamir main #18

Merged
merged 35 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8e46555
feat: add setting option for inline_diagnostic_virtual_text.
ayamir May 4, 2023
925613d
Merge pull request #706 from ayamir/feat/inline-diagnostic
ayamir May 4, 2023
fa5fb5c
feat(nvim-treesitter): add nvim-treesitter-context
Saafo May 4, 2023
f9cb8fe
Merge pull request #707 from Saafo/feat/ts-context
ayamir May 4, 2023
e09dabc
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 5, 2023
0108ed6
chore(settings): replace `pright` with `jedi_language_server`.
ayamir May 6, 2023
1d901b7
Merge pull request #713 from ayamir/chore/pyright-to-jedi
ayamir May 6, 2023
9d3e22d
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 7, 2023
56538b7
fix(icons)!: update icon codepoints (#447)
Jint-lzxy May 7, 2023
3a150ef
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 8, 2023
9c5f0b5
fix(lsp): set default python lsp to `pylsp`, avoid high CPU load caus…
ayamir May 8, 2023
54fb7aa
Merge pull request #724 from ayamir/fix/jedi-to-pylsp
ayamir May 8, 2023
463ac8f
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 9, 2023
6e2c7a9
fix(auto-session): fix command names (#728)
Jint-lzxy May 10, 2023
c6b4163
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 11, 2023
971b0c7
feat(cmp): enable `experimental.ghost_text` (#733)
Jint-lzxy May 14, 2023
a429539
chore(keymap): lsp keymap should effective at `LspAttach` event (#735)
Groveer May 14, 2023
2104162
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 15, 2023
a4b8f5c
fix(catppuccin): use transparent background for `TroubleNormal` (#737)
Groveer May 15, 2023
0d740d8
fix: typos in notifications
Jint-lzxy May 15, 2023
4796cd1
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 16, 2023
770810b
feat(neodim): support v2 (#739)
Jint-lzxy May 16, 2023
b607f5a
chore(wsl): use Windows native way to yank and paste. (#736)
ayamir May 16, 2023
42e816b
fix(wsl): paste selected clipboard content correctly.
ayamir May 16, 2023
1b53c90
feat!: use executables on `$PATH` (#738)
Groveer May 16, 2023
a860c4b
feat(cmp): reimplement comparators for completion entries (#746)
ayamir May 16, 2023
351549c
feat: load `SessionLens` manually via user command (#745)
ayamir May 16, 2023
ad5eff7
fix(vim_fn): check return values of `vim.fn` against 1 (#747)
Jint-lzxy May 16, 2023
986be6e
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 17, 2023
fff57e1
chore(keymap): move gitsigns's keymap to keymap/ui.lua (#748)
Groveer May 17, 2023
0f79d01
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 18, 2023
41262de
feat: add `FormatToggle` keymap (#750) (#751)
Groveer May 18, 2023
32cc577
chore(lockfile): auto update lazy-lock.json
github-actions[bot] May 19, 2023
7caf127
Pull ayamir/nvimdots branch main
TonyWu20 May 22, 2023
ae4c37e
Pull ayamir/nvimdots branch main
TonyWu20 May 22, 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
4 changes: 2 additions & 2 deletions dots.tutor
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ Back to the left window, the status line is showed at the bottom of the window.
You will see different content under different conditions. It will looks like
this if you switch to the right window and move cursor to the second line.
-------------------------------------------------------------------------------
|Normal|main| autocmd |~/.config/nvim|utf-8|LF|1%|2:1|
|Normal|main| 󰅩 autocmd |~/.config/nvim|utf-8|LF|1%|2:1|
-------------------------------------------------------------------------------
" autocmd" indicates this line has a variable named "autocmd". So this part of
"󰅩 autocmd" indicates this line has a variable named "autocmd". So this part of
status line will show you the context of your cursor position. This feature
is based on lsp, so it is disabled if corresponding lsp is not attach to current
buffer.
Expand Down
17 changes: 16 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
if not vim.g.vscode then
require("core")
print(vim.fn.expand("%"))
-- Release note
vim.schedule(function()
vim.notify_once(
[[
We've released version v3.0.0!
Visit https://github.com/ayamir/nvimdots/releases to see the release notes.
If you have icons that can't be rendered correctly (e.g., 𑨩 and � ) or icons with incorrect size, be sure to read this!

To silence this message, remove it from `init.lua` at the config's root directory.

To check the glyphs size, make sure the following icons are very close to the crosses but there is no overlap:
XXXXXXXXX
]],
vim.log.levels.WARN
)
end)
end
2 changes: 1 addition & 1 deletion lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@
"vim-pencil": { "branch": "master", "commit": "6d70438a8886eaf933c38a7a43a61adb0a7815ed" },
"which-key.nvim": { "branch": "main", "commit": "5a6c954a5a46023c19acc03a8b6d7c3e57964fc5" },
"wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }
}
}
8 changes: 8 additions & 0 deletions lua/core/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ function autocmd.nvim_create_augroups(definitions)
end
end

local mapping = require("keymap.completion")
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(event)
mapping.lsp(event.buf)
end,
})

-- auto close NvimTree
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("NvimTreeClose", { clear = true }),
Expand Down
16 changes: 8 additions & 8 deletions lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ local clipboard_config = function()
}
elseif global.is_wsl then
vim.g.clipboard = {
name = "win32yank-wsl",
name = "psyank-wsl",
copy = {
["+"] = "win32yank.exe -i --crlf",
["*"] = "win32yank.exe -i --crlf",
["+"] = "clip.exe",
["*"] = "clip.exe",
},
paste = {
["+"] = "win32yank.exe -o --lf",
["*"] = "win32yank.exe -o --lf",
["+"] = [[powershell.exe -NoProfile -NoLogo -NonInteractive -Command [console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))]],
["*"] = [[powershell.exe -NoProfile -NoLogo -NonInteractive -Command [console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))]],
},
cache_enabled = 0,
}
Expand All @@ -182,7 +182,7 @@ end

local shell_config = function()
if global.is_windows then
if not (vim.fn.executable("pwsh") or vim.fn.executable("powershell")) then
if not (vim.fn.executable("pwsh") == 1 or vim.fn.executable("powershell") == 1) then
vim.notify(
[[
Failed to setup terminal config
Expand All @@ -192,14 +192,14 @@ 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" }
{ title = "[core] Runtime Warning" }
)
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("shell", vim.fn.executable("pwsh") == 1 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", {})
Expand Down
7 changes: 2 additions & 5 deletions lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,9 @@ local function load_options()
if not isempty(conda_prefix) then
vim.g.python_host_prog = conda_prefix .. "/bin/python"
vim.g.python3_host_prog = conda_prefix .. "/bin/python"
elseif global.is_mac then
vim.g.python_host_prog = "/usr/bin/python"
vim.g.python3_host_prog = "/usr/local/bin/python3"
else
vim.g.python_host_prog = "/usr/bin/python"
vim.g.python3_host_prog = "/usr/bin/python3"
vim.g.python_host_prog = "python"
vim.g.python3_host_prog = "python3"
end

for name, value in pairs(global_local) do
Expand Down
7 changes: 6 additions & 1 deletion lua/core/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ settings["use_ssh"] = true
---@type boolean
settings["format_on_save"] = true

-- Set it to false if diagnostics virtual text is annoying for you
---@type boolean
settings["diagnostics_virtual_text"] = true

-- Set the format disabled directories here, files under these dirs won't be formatted on save.
---@type string[]
settings["format_disabled_dirs"] = {
Expand Down Expand Up @@ -59,6 +63,7 @@ settings["server_formatting_block_list"] = {
lua_ls = true,
tsserver = true,
clangd = true,
pylsp = true,
}

-- Set the language servers that will be installed during bootstrap here
Expand All @@ -71,7 +76,7 @@ settings["lsp_deps"] = {
"html",
"jsonls",
"lua_ls",
"pyright",
"pylsp",
-- "gopls",
}

Expand Down
67 changes: 31 additions & 36 deletions lua/keymap/completion.lua
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
local bind = require("keymap.bind")
local map_cr = bind.map_cr
local map_cu = bind.map_cu
-- local map_cmd = bind.map_cmd
local map_cmd = bind.map_cmd
local map_callback = bind.map_callback

local plug_map = {
-- LSP-related keymaps, work only when event = { "InsertEnter", "LspStart" }
["n|<leader>li"] = map_cr("LspInfo"):with_noremap():with_silent():with_nowait():with_desc("lsp: Info"),
["n|<leader>lr"] = map_cr("LspRestart"):with_noremap():with_silent():with_nowait():with_desc("lsp: Restart"),
["n|go"] = map_cr("Lspsaga outline"):with_noremap():with_silent():with_desc("lsp: Toggle outline"),
["n|g["] = map_cr("Lspsaga diagnostic_jump_prev"):with_noremap():with_silent():with_desc("lsp: Prev diagnostic"),
["n|g]"] = map_cr("Lspsaga diagnostic_jump_next"):with_noremap():with_silent():with_desc("lsp: Next diagnostic"),
["n|<leader>ld"] = map_cr("Lspsaga show_line_diagnostics")
:with_noremap()
:with_silent()
:with_desc("lsp: Line diagnostic"),
["n|gs"] = map_callback(function()
vim.lsp.buf.signature_help()
end)
:with_noremap()
:with_silent()
:with_desc("lsp: Signature help"),
["n|gr"] = map_cr("Lspsaga rename"):with_noremap():with_silent():with_desc("lsp: Rename in file range"),
["n|gR"] = map_cr("Lspsaga rename ++project")
:with_noremap()
:with_silent()
:with_desc("lsp: Rename in project range"),
["n|K"] = map_cr("Lspsaga hover_doc"):with_noremap():with_silent():with_desc("lsp: Show doc"),
["nv|ga"] = map_cr("Lspsaga code_action"):with_noremap():with_silent():with_desc("lsp: Code action"),
["n|gd"] = map_cr("Lspsaga peek_definition"):with_noremap():with_silent():with_desc("lsp: Preview definition"),
["n|gD"] = map_cr("Lspsaga goto_definition"):with_noremap():with_silent():with_desc("lsp: Goto definition"),
["n|gh"] = map_cr("Lspsaga lsp_finder"):with_noremap():with_silent():with_desc("lsp: Show reference"),
["n|<leader>ci"] = map_cr("Lspsaga incoming_calls")
:with_noremap()
:with_silent()
:with_desc("lsp: Show incoming calls"),
["n|<leader>co"] = map_cr("Lspsaga outgoing_calls")
:with_noremap()
:with_silent()
:with_desc("lsp: Show outgoing calls"),
["n|<A-f>"] = map_cmd("<Cmd>FormatToggle<CR>"):with_noremap():with_desc("Formater: Toggle format on save"),
}

bind.nvim_load_mapping(plug_map)

local mapping = {}

function mapping.lsp(buf)
local map = {
-- LSP-related keymaps, work only when event = { "InsertEnter", "LspStart" }
["n|<leader>li"] = map_cr("LspInfo"):with_buffer(buf):with_desc("lsp: Info"),
["n|<leader>lr"] = map_cr("LspRestart"):with_buffer(buf):with_nowait():with_desc("lsp: Restart"),
["n|go"] = map_cr("Lspsaga outline"):with_buffer(buf):with_desc("lsp: Toggle outline"),
["n|g["] = map_cr("Lspsaga diagnostic_jump_prev"):with_buffer(buf):with_desc("lsp: Prev diagnostic"),
["n|g]"] = map_cr("Lspsaga diagnostic_jump_next"):with_buffer(buf):with_desc("lsp: Next diagnostic"),
["n|<leader>ld"] = map_cr("Lspsaga show_line_diagnostics"):with_buffer(buf):with_desc("lsp: Line diagnostic"),
["n|gs"] = map_callback(function()
vim.lsp.buf.signature_help()
end):with_desc("lsp: Signature help"),
["n|gr"] = map_cr("Lspsaga rename"):with_buffer(buf):with_desc("lsp: Rename in file range"),
["n|gR"] = map_cr("Lspsaga rename ++project"):with_buffer(buf):with_desc("lsp: Rename in project range"),
["n|K"] = map_cr("Lspsaga hover_doc"):with_buffer(buf):with_desc("lsp: Show doc"),
["nv|ga"] = map_cr("Lspsaga code_action"):with_buffer(buf):with_desc("lsp: Code action for cursor"),
["n|gd"] = map_cr("Lspsaga peek_definition"):with_buffer(buf):with_desc("lsp: Preview definition"),
["n|gD"] = map_cr("Lspsaga goto_definition"):with_buffer(buf):with_desc("lsp: Goto definition"),
["n|gh"] = map_cr("Lspsaga lsp_finder"):with_buffer(buf):with_desc("lsp: Show reference"),
["n|<leader>ci"] = map_cr("Lspsaga incoming_calls"):with_buffer(buf):with_desc("lsp: Show incoming calls"),
["n|<leader>co"] = map_cr("Lspsaga outgoing_calls"):with_buffer(buf):with_desc("lsp: Show outgoing calls"),
}
bind.nvim_load_mapping(map)
end

return mapping
6 changes: 3 additions & 3 deletions lua/keymap/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ local plug_map = {
end):with_expr(),

-- Plugin: auto_session
["n|<leader>ss"] = map_cu("SaveSession"):with_noremap():with_silent():with_desc("session: Save"),
["n|<leader>sr"] = map_cu("RestoreSession"):with_noremap():with_silent():with_desc("session: Restore"),
["n|<leader>sd"] = map_cu("DeleteSession"):with_noremap():with_silent():with_desc("session: Delete"),
["n|<leader>ss"] = map_cu("SessionSave"):with_noremap():with_silent():with_desc("session: Save"),
["n|<leader>sr"] = map_cu("SessionRestore"):with_noremap():with_silent():with_desc("session: Restore"),
["n|<leader>sd"] = map_cu("SessionDelete"):with_noremap():with_silent():with_desc("session: Delete"),

-- Plugin: nvim-bufdel
["n|<A-q>"] = map_cr("BufDel"):with_noremap():with_silent():with_desc("buffer: Close current"),
Expand Down
2 changes: 1 addition & 1 deletion lua/keymap/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end

local _lazygit = nil
_G._toggle_lazygit = function()
if vim.fn.executable("lazygit") then
if vim.fn.executable("lazygit") == 1 then
if not _lazygit then
_lazygit = require("toggleterm.terminal").Terminal:new({
cmd = "lazygit",
Expand Down
79 changes: 79 additions & 0 deletions lua/keymap/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,82 @@ local plug_map = {
}

bind.nvim_load_mapping(plug_map)

local mapping = {}

function mapping.gitsigns(buf)
local actions = require("gitsigns.actions")
local map = {
["n|]g"] = bind.map_callback(function()
if vim.wo.diff then
return "]g"
end
vim.schedule(function()
actions.next_hunk()
end)
return "<Ignore>"
end)
:with_buffer(buf)
:with_expr()
:with_desc("git: Goto next hunk"),
["n|[g"] = bind.map_callback(function()
if vim.wo.diff then
return "[g"
end
vim.schedule(function()
actions.prev_hunk()
end)
return "<Ignore>"
end)
:with_buffer(buf)
:with_expr()
:with_desc("git: Goto prev hunk"),
["n|<leader>hs"] = bind.map_callback(function()
actions.stage_hunk()
end)
:with_buffer(buf)
:with_desc("git: Stage hunk"),
["v|<leader>hs"] = bind.map_callback(function()
actions.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
:with_buffer(buf)
:with_desc("git: Stage hunk"),
["n|<leader>hu"] = bind.map_callback(function()
actions.undo_stage_hunk()
end)
:with_buffer(buf)
:with_desc("git: Undo stage hunk"),
["n|<leader>hr"] = bind.map_callback(function()
actions.reset_hunk()
end)
:with_buffer(buf)
:with_desc("git: Reset hunk"),
["v|<leader>hr"] = bind.map_callback(function()
actions.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
:with_buffer(buf)
:with_desc("git: Reset hunk"),
["n|<leader>hR"] = bind.map_callback(function()
actions.reset_buffer()
end)
:with_buffer(buf)
:with_desc("git: Reset buffer"),
["n|<leader>hp"] = bind.map_callback(function()
actions.preview_hunk()
end)
:with_buffer(buf)
:with_desc("git: Preview hunk"),
["n|<leader>hb"] = bind.map_callback(function()
actions.blame_line({ full = true })
end)
:with_buffer(buf)
:with_desc("git: Blame line"),
-- Text objects
["ox|ih"] = bind.map_callback(function()
actions.text_object()
end):with_buffer(buf),
}
bind.nvim_load_mapping(map)
end

return mapping
Loading