Skip to content

Commit 8fb1129

Browse files
committed
feat(config): start building initial configuration
0 parents  commit 8fb1129

File tree

7 files changed

+820
-0
lines changed

7 files changed

+820
-0
lines changed

.luacheckrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Global objects
2+
globals = { "vim" }
3+
4+
-- Rerun tests only if their modification time changed
5+
cache = true
6+
7+
-- Don't report unused self arguments of methods
8+
self = false
9+
10+
ignore = {
11+
"631", -- max_line_length
12+
"212/_.*", -- unused argument, for vars with "_" prefix
13+
}

.neoconf.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"neodev": {
3+
"library": {
4+
"enabled": true,
5+
"plugins": true
6+
}
7+
},
8+
"neoconf": {
9+
"plugins": {
10+
"lua_ls": {
11+
"enabled": true
12+
}
13+
}
14+
},
15+
"lspconfig": {
16+
"lua_ls": {
17+
"Lua.format.enable": false
18+
}
19+
}
20+
}

.stylua.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
column_width = 120
2+
line_endings = "Unix"
3+
indent_type = "Spaces"
4+
indent_width = 2
5+
quote_style = "AutoPreferDouble"
6+
call_parentheses = "None"
7+
collapse_simple_statement = "Always"

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# astrolsp
2+
LSP Configuration Engine built for AstroNvim

lua/astrolsp/config.lua

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
return {
2+
diagnostics = {
3+
virtual_text = true,
4+
signs = {
5+
active = {
6+
{ name = "DiagnosticSignError", text = "", texthl = "DiagnosticSignError" },
7+
{ name = "DiagnosticSignHint", text = "󰌵", texthl = "DiagnosticSignHint" },
8+
{ name = "DiagnosticSignInfo", text = "󰋼", texthl = "DiagnosticSignInfo" },
9+
{ name = "DiagnosticSignWarn", text = "", texthl = "DiagnosticSignWarn" },
10+
{ name = "DapBreakpoint", text = "", texthl = "DiagnosticInfo" },
11+
{ name = "DapBreakpointCondition", text = "", texthl = "DiagnosticInfo" },
12+
{ name = "DapBreakpointRejected", text = "", texthl = "DiagnosticError" },
13+
{ name = "DapLogPoint", text = ".>", texthl = "DiagnosticInfo" },
14+
{ name = "DapStopped", text = "󰁕", texthl = "DiagnosticWarn" },
15+
},
16+
},
17+
update_in_insert = true,
18+
underline = true,
19+
severity_sort = true,
20+
float = {
21+
focused = false,
22+
style = "minimal",
23+
border = "rounded",
24+
source = "always",
25+
header = "",
26+
prefix = "",
27+
},
28+
},
29+
30+
capabilities = vim.tbl_deep_extend("force", vim.lsp.protocol.make_client_capabilities(), {
31+
textDocument = {
32+
completion = {
33+
completionItem = {
34+
documentationFormat = { "markdown", "plaintext" },
35+
snippetSupport = true,
36+
preselectSupport = true,
37+
insertReplaceSupport = true,
38+
labelDetailsSupport = true,
39+
deprecatedSupport = true,
40+
commitCharactersSupport = true,
41+
tagSupport = { valueSet = { 1 } },
42+
resolveSupport = { properties = { "documentation", "detail", "additionalTextEdits" } },
43+
},
44+
},
45+
foldingRange = { dynamicRegistration = false, lineFoldingOnly = true },
46+
},
47+
}),
48+
49+
flags = {},
50+
51+
config = {},
52+
53+
-- on_attach = function(client, bufnr) ... end, -- user can pass in an extension of the on_attach
54+
55+
setup_handlers = {
56+
function(server, opts) require("lspconfig")[server].setup(opts) end,
57+
},
58+
59+
formatting = { format_on_save = { enabled = true }, disable = {} },
60+
61+
mappings = {
62+
n = {
63+
-- no cond will always be set
64+
["<leader>ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" },
65+
["[d"] = { function() vim.diagnostic.goto_prev() end, desc = "Previous diagnostic" },
66+
["]d"] = { function() vim.diagnostic.goto_next() end, desc = "Next diagnostic" },
67+
["gl"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" },
68+
69+
["<leader>lD"] = {
70+
function() require("telescope.builtin").diagnostics() end,
71+
desc = "Search diagnostics",
72+
cond = function(_, _) return true end, -- client, bufnr parameters
73+
},
74+
75+
["<leader>la"] = {
76+
function() vim.lsp.buf.code_action() end,
77+
desc = "LSP code action",
78+
cond = "testDocument/codeAction", -- LSP client capability string
79+
},
80+
},
81+
},
82+
}

lua/astrolsp/init.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
local M = {}
2+
3+
function M.setup(opts)
4+
for section, default in pairs(require "astrolsp.config") do
5+
local opt = opts[section]
6+
if opt then
7+
if type(opt) == "function" then
8+
opts[section] = opt(default) or default
9+
elseif type(opt) == "table" then
10+
opts[section] = vim.tbl_deep_extend("force", default, opt)
11+
else
12+
vim.api.nvim_err_writeln(("AstroLSP: Invalid %s option"):format(section))
13+
end
14+
else
15+
opts[section] = default
16+
end
17+
end
18+
19+
M.options = opts
20+
end
21+
22+
return M

0 commit comments

Comments
 (0)