Skip to content

Commit 9832a14

Browse files
feat(#96): improve DX (#97)
* feat(#96): added linting, formatting and diagnostics rules * fix(#96): applied formatting and linting rules
1 parent 1dcf519 commit 9832a14

File tree

7 files changed

+91
-2
lines changed

7 files changed

+91
-2
lines changed

.editorconfig

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
end_of_line = lf
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
max_line_length = 120
11+
12+
[*.yml]
13+
indent_style = space
14+
indent_size = 2
15+
16+
# This makes it a lot less painful to write YAMLs in docs
17+
[*.md]
18+
indent_style = space
19+
indent_size = 2
20+
21+
[Makefile]
22+
indent_style = tab
23+
indent_size = 4

.luarc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
3+
"diagnostics": {
4+
"unusedLocalExclude": ["_*"]
5+
}
6+
}

Makefile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
GREEN="\033[00;32m"
2+
RESTORE="\033[0m"
3+
4+
# makes the output of the message appear green
5+
define style_calls
6+
$(eval $@_msg = $(1))
7+
echo ${GREEN}${$@_msg}
8+
echo ${RESTORE}
9+
endef
10+
11+
lint:
12+
@$(call style_calls,"Linting lua files")
13+
@selene --display-style quiet --config ./selene.toml lua/llm
14+
@$(call style_calls,"Running stylua check")
15+
@stylua --color always -f ./.stylua.toml --check .
16+
@$(call style_calls,"Done!")
17+
18+
format:
19+
@$(call style_calls,"Running stylua format")
20+
@stylua --color always -f ./.stylua.toml .
21+
@$(call style_calls,"Done!")
22+
23+
.PHONY: lint format

lua/llm/completion.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function M.schedule()
6868
end
6969

7070
function M.lsp_suggest()
71-
M.request_id = llm_ls.get_completions(function(err, result, context, config)
71+
M.request_id = llm_ls.get_completions(function(err, result, context, _conf)
7272
if err ~= nil then
7373
vim.notify("[LLM] " .. err.message, vim.log.levels.ERROR)
7474
return

lua/llm/language_server.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ local function build_binary_name()
3636
elseif linux_distribution == "raspbian" then
3737
arch_map.armv7l = "arm"
3838
os_map.Linux = "unknown-linux-gnueabihf"
39-
else
39+
-- else
4040
-- Add mappings for other distributions as needed
4141
end
4242
end

neovim.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
base: lua51
3+
4+
globals:
5+
jit:
6+
any: true
7+
vim:
8+
any: true
9+
assert:
10+
args:
11+
- type: bool
12+
- type: string
13+
required: false
14+
after_each:
15+
args:
16+
- type: function
17+
before_each:
18+
args:
19+
- type: function
20+
describe:
21+
args:
22+
- type: string
23+
- type: function
24+
it:
25+
args:
26+
- type: string
27+
- type: function

selene.toml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
std="neovim"
2+
3+
[rules]
4+
global_usage = "warn"
5+
deprecated = "warn" # If changed to `allow` it will rely on `lua_ls` diagnostics.
6+
multiple_statements = "allow"
7+
incorrect_standard_library_use = "allow" # This is for cases like `string.format`, `package.config`, etc.
8+
mixed_table = "allow"
9+
unused_variable = "warn"
10+
undefined_variable = "warn"

0 commit comments

Comments
 (0)