Skip to content

Commit 505e58a

Browse files
authored
Merge pull request #24 from stsewd/use-stylua
Use stylua to auto format code
2 parents 1a377fa + 7009136 commit 505e58a

File tree

7 files changed

+141
-77
lines changed

7 files changed

+141
-77
lines changed

.github/workflows/lint.yml

+11
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,14 @@ jobs:
1616
sudo luarocks install luacheck
1717
- name: Run Luacheck
1818
run: bash scripts/style-check.sh
19+
20+
stylua:
21+
name: StyLua
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Lint with stylua
26+
uses: JohnnyMorganz/stylua-action@1.0.0
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
args: --check .

.stylua.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
indent_type = "Spaces"
2+
indent_width = 2
3+
no_call_parentheses = true

lua/nvim-treesitter-refactor.lua

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@ local queries = require "nvim-treesitter.query"
33
local M = {}
44

55
function M.init()
6-
require "nvim-treesitter".define_modules {
6+
require("nvim-treesitter").define_modules {
77
refactor = {
88
highlight_definitions = {
9-
module_path = 'nvim-treesitter-refactor.highlight_definitions',
9+
module_path = "nvim-treesitter-refactor.highlight_definitions",
1010
enable = false,
1111
disable = {},
12-
is_supported = queries.has_locals
12+
is_supported = queries.has_locals,
1313
},
1414
highlight_current_scope = {
15-
module_path = 'nvim-treesitter-refactor.highlight_current_scope',
15+
module_path = "nvim-treesitter-refactor.highlight_current_scope",
1616
enable = false,
1717
disable = {},
1818
is_supported = queries.has_locals,
1919
},
2020
smart_rename = {
21-
module_path = 'nvim-treesitter-refactor.smart_rename',
21+
module_path = "nvim-treesitter-refactor.smart_rename",
2222
enable = false,
2323
disable = {},
2424
is_supported = queries.has_locals,
2525
keymaps = {
26-
smart_rename = "grr"
27-
}
26+
smart_rename = "grr",
27+
},
2828
},
2929
navigation = {
30-
module_path = 'nvim-treesitter-refactor.navigation',
30+
module_path = "nvim-treesitter-refactor.navigation",
3131
enable = false,
3232
disable = {},
3333
is_supported = queries.has_locals,
@@ -37,9 +37,9 @@ function M.init()
3737
list_definitions_toc = "gO",
3838
goto_next_usage = "<a-*>",
3939
goto_previous_usage = "<a-#>",
40-
}
41-
}
42-
}
40+
},
41+
},
42+
},
4343
}
4444
end
4545

Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
-- This module highlights the current scope of at the cursor position
22

3-
local ts_utils = require'nvim-treesitter.ts_utils'
4-
local locals = require'nvim-treesitter.locals'
3+
local ts_utils = require "nvim-treesitter.ts_utils"
4+
local locals = require "nvim-treesitter.locals"
55
local api = vim.api
66
local cmd = api.nvim_command
77

88
local M = {}
99

10-
local current_scope_namespace = api.nvim_create_namespace('nvim-treesitter-current-scope')
10+
local current_scope_namespace = api.nvim_create_namespace "nvim-treesitter-current-scope"
1111

1212
function M.highlight_current_scope(bufnr)
1313
M.clear_highlights(bufnr)
@@ -19,7 +19,7 @@ function M.highlight_current_scope(bufnr)
1919
local start_line = current_scope:start()
2020

2121
if start_line ~= 0 then
22-
ts_utils.highlight_node(current_scope, bufnr, current_scope_namespace, 'TSCurrentScope')
22+
ts_utils.highlight_node(current_scope, bufnr, current_scope_namespace, "TSCurrentScope")
2323
end
2424
end
2525
end
@@ -29,19 +29,31 @@ function M.clear_highlights(bufnr)
2929
end
3030

3131
function M.attach(bufnr)
32-
cmd(string.format('augroup NvimTreesitterCurrentScope_%d', bufnr))
33-
cmd 'au!'
32+
cmd(string.format("augroup NvimTreesitterCurrentScope_%d", bufnr))
33+
cmd "au!"
3434
-- luacheck: push ignore 631
35-
cmd(string.format([[autocmd CursorMoved <buffer=%d> lua require'nvim-treesitter-refactor.highlight_current_scope'.highlight_current_scope(%d)]], bufnr, bufnr))
36-
cmd(string.format([[autocmd BufLeave <buffer=%d> lua require'nvim-treesitter-refactor.highlight_current_scope'.clear_highlights(%d)]], bufnr, bufnr))
35+
cmd(
36+
string.format(
37+
[[autocmd CursorMoved <buffer=%d> lua require'nvim-treesitter-refactor.highlight_current_scope'.highlight_current_scope(%d)]],
38+
bufnr,
39+
bufnr
40+
)
41+
)
42+
cmd(
43+
string.format(
44+
[[autocmd BufLeave <buffer=%d> lua require'nvim-treesitter-refactor.highlight_current_scope'.clear_highlights(%d)]],
45+
bufnr,
46+
bufnr
47+
)
48+
)
3749
-- luacheck: pop
38-
cmd 'augroup END'
50+
cmd "augroup END"
3951
end
4052

4153
function M.detach(bufnr)
4254
M.clear_highlights(bufnr)
43-
cmd(string.format('autocmd! NvimTreesitterCurrentScope_%d CursorMoved', bufnr))
44-
cmd(string.format('autocmd! NvimTreesitterCurrentScope_%d BufLeave', bufnr))
55+
cmd(string.format("autocmd! NvimTreesitterCurrentScope_%d CursorMoved", bufnr))
56+
cmd(string.format("autocmd! NvimTreesitterCurrentScope_%d BufLeave", bufnr))
4557
end
4658

4759
return M
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
-- This module highlights reference usages and the corresponding
22
-- definition on cursor hold.
33

4-
local ts_utils = require'nvim-treesitter.ts_utils'
5-
local locals = require'nvim-treesitter.locals'
4+
local ts_utils = require "nvim-treesitter.ts_utils"
5+
local locals = require "nvim-treesitter.locals"
66
local api = vim.api
77
local cmd = api.nvim_command
88

99
local M = {}
1010

11-
local usage_namespace = api.nvim_create_namespace('nvim-treesitter-usages')
11+
local usage_namespace = api.nvim_create_namespace "nvim-treesitter-usages"
1212

1313
function M.highlight_usages(bufnr)
1414
M.clear_usage_highlights(bufnr)
@@ -25,12 +25,12 @@ function M.highlight_usages(bufnr)
2525

2626
for _, usage_node in ipairs(usages) do
2727
if usage_node ~= node_at_point then
28-
ts_utils.highlight_node(usage_node, bufnr, usage_namespace, 'TSDefinitionUsage')
28+
ts_utils.highlight_node(usage_node, bufnr, usage_namespace, "TSDefinitionUsage")
2929
end
3030
end
3131

3232
if def_node ~= node_at_point then
33-
ts_utils.highlight_node(def_node, bufnr, usage_namespace, 'TSDefinition')
33+
ts_utils.highlight_node(def_node, bufnr, usage_namespace, "TSDefinition")
3434
end
3535
end
3636

@@ -39,21 +39,39 @@ function M.clear_usage_highlights(bufnr)
3939
end
4040

4141
function M.attach(bufnr)
42-
cmd(string.format('augroup NvimTreesitterUsages_%d', bufnr))
43-
cmd 'au!'
42+
cmd(string.format("augroup NvimTreesitterUsages_%d", bufnr))
43+
cmd "au!"
4444
-- luacheck: push ignore 631
45-
cmd(string.format([[autocmd CursorHold <buffer=%d> lua require'nvim-treesitter-refactor.highlight_definitions'.highlight_usages(%d)]], bufnr, bufnr))
46-
cmd(string.format([[autocmd CursorMoved <buffer=%d> lua require'nvim-treesitter-refactor.highlight_definitions'.clear_usage_highlights(%d)]], bufnr, bufnr))
47-
cmd(string.format([[autocmd InsertEnter <buffer=%d> lua require'nvim-treesitter-refactor.highlight_definitions'.clear_usage_highlights(%d)]], bufnr, bufnr))
45+
cmd(
46+
string.format(
47+
[[autocmd CursorHold <buffer=%d> lua require'nvim-treesitter-refactor.highlight_definitions'.highlight_usages(%d)]],
48+
bufnr,
49+
bufnr
50+
)
51+
)
52+
cmd(
53+
string.format(
54+
[[autocmd CursorMoved <buffer=%d> lua require'nvim-treesitter-refactor.highlight_definitions'.clear_usage_highlights(%d)]],
55+
bufnr,
56+
bufnr
57+
)
58+
)
59+
cmd(
60+
string.format(
61+
[[autocmd InsertEnter <buffer=%d> lua require'nvim-treesitter-refactor.highlight_definitions'.clear_usage_highlights(%d)]],
62+
bufnr,
63+
bufnr
64+
)
65+
)
4866
-- luacheck: pop
49-
cmd 'augroup END'
67+
cmd "augroup END"
5068
end
5169

5270
function M.detach(bufnr)
5371
M.clear_usage_highlights(bufnr)
54-
cmd(string.format('autocmd! NvimTreesitterUsages_%d CursorHold', bufnr))
55-
cmd(string.format('autocmd! NvimTreesitterUsages_%d CursorMoved', bufnr))
56-
cmd(string.format('autocmd! NvimTreesitterUsages_%d InsertEnter', bufnr))
72+
cmd(string.format("autocmd! NvimTreesitterUsages_%d CursorHold", bufnr))
73+
cmd(string.format("autocmd! NvimTreesitterUsages_%d CursorMoved", bufnr))
74+
cmd(string.format("autocmd! NvimTreesitterUsages_%d InsertEnter", bufnr))
5775
end
5876

5977
return M

0 commit comments

Comments
 (0)