Skip to content

Commit 5c58276

Browse files
authored
Merge pull request #20 from TonyWu20/ayamir-main
ayamir main
2 parents 4b2fe46 + bfe73c8 commit 5c58276

21 files changed

+394
-537
lines changed

lazy-lock.json

+93-361
Large diffs are not rendered by default.

lua/core/settings.lua

+11-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ settings["format_notify"] = true
1616
-- Set it to false if diagnostics virtual text is annoying.
1717
-- If disabled, you may browse lsp diagnostics using trouble.nvim (press `gt` to toggle it).
1818
---@type boolean
19-
settings["diagnostics_virtual_text"] = false
19+
settings["diagnostics_virtual_text"] = true
2020

2121
-- Set it to one of the values below if you want to change the visible severity level of lsp diagnostics.
2222
-- Priority: `Error` > `Warning` > `Information` > `Hint`.
@@ -31,7 +31,6 @@ settings["format_disabled_dirs"] = {
3131
home .. "/format_disabled_dir_under_home",
3232
}
3333

34-
-- NOTE: The startup time will be slowed down when it's true.
3534
-- Set it to false if you don't use nvim to open big files.
3635
---@type boolean
3736
settings["load_big_files_faster"] = true
@@ -105,4 +104,14 @@ settings["null_ls_deps"] = {
105104
"vint",
106105
}
107106

107+
-- Set the Debug Adapter Protocol (DAP) clients that will be installed and configured during bootstrap here.
108+
-- Check the below link for all supported DAPs:
109+
-- https://github.com/jay-babu/mason-nvim-dap.nvim/blob/main/lua/mason-nvim-dap/mappings/source.lua
110+
---@type string[]
111+
settings["dap_deps"] = {
112+
"codelldb", -- C-Family
113+
"delve", -- Go
114+
"python", -- Python (debugpy)
115+
}
116+
108117
return settings

lua/modules/configs/completion/cmp.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ return function()
106106
},
107107
performance = {
108108
async_budget = 1,
109-
max_view_entries = 150,
109+
max_view_entries = 120,
110110
},
111111
-- You can set mappings if you want
112112
mapping = cmp.mapping.preset.insert({
@@ -142,7 +142,7 @@ return function()
142142
},
143143
-- You should specify your *installed* sources.
144144
sources = {
145-
{ name = "nvim_lsp" },
145+
{ name = "nvim_lsp", max_item_count = 350 },
146146
{ name = "nvim_lua" },
147147
{ name = "luasnip" },
148148
{ name = "path" },

lua/modules/configs/completion/lsp.lua

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
return function()
22
local diagnostics_virtual_text = require("core.settings").diagnostics_virtual_text
33
local diagnostics_level = require("core.settings").diagnostics_level
4+
local is_windows = require("core.global").is_windows
45

56
local nvim_lsp = require("lspconfig")
67
local mason = require("mason")
78
local mason_registry = require("mason-registry")
89
local mason_lspconfig = require("mason-lspconfig")
9-
require("lspconfig.ui.windows").default_options.border = "single"
10+
require("lspconfig.ui.windows").default_options.border = "rounded"
1011

1112
local icons = {
1213
ui = require("modules.utils.icons").get("ui", true),
@@ -34,8 +35,6 @@ return function()
3435
},
3536
})
3637

37-
local is_win = require("core.global").is_windows
38-
3938
-- Additional plugins for pylsp
4039
mason_registry:on(
4140
"package:install:success",
@@ -45,9 +44,10 @@ return function()
4544
end
4645

4746
local venv = vim.fn.stdpath("data") .. "/mason/packages/python-lsp-server/venv"
48-
local python = is_win and venv .. "/Scripts/python.exe" or venv .. "/bin/python"
49-
local black = is_win and venv .. "/Scripts/black.exe" or venv .. "/bin/black"
50-
local ruff = is_win and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff"
47+
local python = is_windows and venv .. "/Scripts/python.exe" or venv .. "/bin/python"
48+
local black = is_windows and venv .. "/Scripts/black.exe" or venv .. "/bin/black"
49+
local ruff = is_windows and venv .. "/Scripts/ruff.exe" or venv .. "/bin/ruff"
50+
5151
require("plenary.job")
5252
:new({
5353
command = python,
@@ -129,7 +129,7 @@ return function()
129129

130130
---A handler to setup all servers defined under `completion/servers/*.lua`
131131
---@param lsp_name string
132-
local function mason_handler(lsp_name)
132+
local function mason_lsp_handler(lsp_name)
133133
local ok, custom_handler = pcall(require, "completion.servers." .. lsp_name)
134134
if not ok then
135135
-- Default to use factory config for server(s) that doesn't include a spec
@@ -155,7 +155,7 @@ return function()
155155
end
156156
end
157157

158-
mason_lspconfig.setup_handlers({ mason_handler })
158+
mason_lspconfig.setup_handlers({ mason_lsp_handler })
159159

160160
-- Setup lsps that are not supported by `mason.nvim` but supported by `nvim-lspconfig` here.
161161
if vim.fn.executable("dart") == 1 then

lua/modules/configs/completion/servers/clangd.lua

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
local global = require("core.global")
21
local function switch_source_header_splitcmd(bufnr, splitcmd)
32
bufnr = require("lspconfig").util.validate_bufnr(bufnr)
43
local clangd_client = require("lspconfig").util.get_active_client_by_name(bufnr, "clangd")
@@ -54,7 +53,7 @@ return function(options)
5453
"--header-insertion-decorators",
5554
"--header-insertion=iwyu",
5655
"--limit-references=3000",
57-
"--limit-results=270",
56+
"--limit-results=350",
5857
},
5958
commands = {
6059
ClangdSwitchSourceHeader = {

lua/modules/configs/editor/bigfile.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ return function()
1515
end,
1616
}
1717

18-
require("bigfile").config({
18+
require("bigfile").setup({
1919
filesize = 1, -- size of the file in MiB
2020
pattern = { "*" }, -- autocmd pattern
2121
features = { -- features to disable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- https://github.com/mfussenegger/nvim-dap/wiki/C-C---Rust-(via--codelldb)
2+
return function()
3+
local dap = require("dap")
4+
local utils = require("modules.utils.dap")
5+
local is_windows = require("core.global").is_windows
6+
7+
dap.adapters.codelldb = {
8+
type = "server",
9+
port = "${port}",
10+
executable = {
11+
command = vim.fn.exepath("codelldb"), -- Find codelldb on $PATH
12+
args = { "--port", "${port}" },
13+
detached = is_windows and false or true,
14+
},
15+
}
16+
dap.configurations.c = {
17+
{
18+
name = "Launch the debugger",
19+
type = "codelldb",
20+
request = "launch",
21+
program = utils.input_exec_path(),
22+
args = utils.input_args(),
23+
cwd = "${workspaceFolder}",
24+
stopOnEntry = false,
25+
},
26+
}
27+
dap.configurations.cpp = dap.configurations.c
28+
dap.configurations.rust = dap.configurations.c
29+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#go-using-delve-directly
2+
-- https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_dap.md
3+
return function()
4+
local dap = require("dap")
5+
local utils = require("modules.utils.dap")
6+
7+
dap.adapters.go = function(callback)
8+
local stdout = vim.loop.new_pipe(false)
9+
local handle
10+
local pid_or_err
11+
local port = 28695
12+
local opts = {
13+
stdio = { nil, stdout },
14+
args = { "dap", "-l", "127.0.0.1:" .. port },
15+
detached = true,
16+
}
17+
handle, pid_or_err = vim.loop.spawn(vim.fn.exepath("dlv"), opts, function(code)
18+
stdout:close()
19+
handle:close()
20+
if code ~= 0 then
21+
vim.notify(
22+
string.format('"dlv" exited with code: %d, please check your configs for correctness.', code),
23+
vim.log.levels.WARN,
24+
{ title = "[go] DAP Warning!" }
25+
)
26+
end
27+
end)
28+
assert(handle, "Error running dlv: " .. tostring(pid_or_err))
29+
stdout:read_start(function(err, chunk)
30+
assert(not err, err)
31+
if chunk then
32+
vim.schedule(function()
33+
require("dap.repl").append(chunk)
34+
end)
35+
end
36+
end)
37+
-- Wait for delve to start
38+
vim.defer_fn(function()
39+
callback({ type = "server", host = "127.0.0.1", port = port })
40+
end, 100)
41+
end
42+
dap.configurations.go = {
43+
{ type = "go", name = "Debug", request = "launch", program = "${file}" },
44+
{
45+
type = "go",
46+
name = "Debug with args",
47+
request = "launch",
48+
program = "${file}",
49+
args = utils.input_args(),
50+
},
51+
{
52+
type = "go",
53+
name = "Debug test", -- configuration for debugging test files
54+
request = "launch",
55+
mode = "test",
56+
program = "${file}",
57+
}, -- works with go.mod packages and sub packages
58+
{
59+
type = "go",
60+
name = "Debug test (go.mod)",
61+
request = "launch",
62+
mode = "test",
63+
program = "./${relativeFileDirname}",
64+
},
65+
}
66+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#ccrust-via-lldb-vscode
2+
return function()
3+
local dap = require("dap")
4+
local utils = require("modules.utils.dap")
5+
6+
dap.adapters.lldb = {
7+
type = "executable",
8+
command = "lldb-vscode",
9+
name = "lldb",
10+
}
11+
dap.configurations.c = {
12+
{
13+
name = "Launch",
14+
type = "lldb",
15+
request = "launch",
16+
program = utils.input_exec_path(),
17+
cwd = "${workspaceFolder}",
18+
args = utils.input_args(),
19+
env = utils.get_env(),
20+
21+
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
22+
--
23+
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
24+
--
25+
-- Otherwise you might get the following error:
26+
--
27+
-- Error on launch: Failed to attach to the target process
28+
--
29+
-- But you should be aware of the implications:
30+
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
31+
runInTerminal = false,
32+
},
33+
}
34+
35+
dap.configurations.cpp = dap.configurations.c
36+
dap.configurations.rust = dap.configurations.c
37+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#python
2+
return function()
3+
local dap = require("dap")
4+
local debugpy = vim.fn.exepath("debugpy-adapter")
5+
6+
local function is_empty(s)
7+
return s == nil or s == ""
8+
end
9+
10+
dap.adapters.python = function(callback, config)
11+
if config.request == "attach" then
12+
---@diagnostic disable-next-line: undefined-field
13+
local port = (config.connect or config).port
14+
---@diagnostic disable-next-line: undefined-field
15+
local host = (config.connect or config).host or "127.0.0.1"
16+
callback({
17+
type = "server",
18+
port = assert(port, "`connect.port` is required for a python `attach` configuration"),
19+
host = host,
20+
options = { source_filetype = "python" },
21+
})
22+
else
23+
callback({
24+
type = "executable",
25+
command = debugpy,
26+
options = { source_filetype = "python" },
27+
})
28+
end
29+
end
30+
dap.configurations.python = {
31+
{
32+
-- The first three options are required by nvim-dap
33+
type = "python", -- the type here established the link to the adapter definition: `dap.adapters.python`
34+
request = "launch",
35+
name = "Launch file",
36+
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
37+
program = "${file}", -- This configuration will launch the current file if used.
38+
pythonPath = function()
39+
if not is_empty(vim.env.CONDA_PREFIX) then
40+
return vim.env.CONDA_PREFIX .. "/bin/python"
41+
else
42+
return "python3"
43+
end
44+
end,
45+
},
46+
}
47+
48+
-- NOTE: This setting is for people using venv
49+
-- pythonPath = function()
50+
-- -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
51+
-- -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
52+
-- -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
53+
-- local cwd, venv = vim.fn.getcwd(), os.getenv("VIRTUAL_ENV")
54+
-- if venv and vim.fn.executable(venv .. "/bin/python") == 1 then
55+
-- return venv .. "/bin/python"
56+
-- elseif vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
57+
-- return cwd .. "/venv/bin/python"
58+
-- elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
59+
-- return cwd .. "/.venv/bin/python"
60+
-- else
61+
-- return "python3"
62+
-- end
63+
-- end,
64+
end

lua/modules/configs/tool/dap/dap-debugpy.lua

-46
This file was deleted.

0 commit comments

Comments
 (0)