Skip to content

Commit 65faba0

Browse files
committed
strict
1 parent c3840ec commit 65faba0

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

lua/fittencode/integrations/filetype.lua

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@ local M = {}
1111
local debound_send_filetype
1212
local pre_request
1313

14-
local function _check(buffer)
14+
local function check(buffer)
1515
local name = vim.api.nvim_buf_get_name(buffer)
16-
local ext = vim.fn.fnamemodify(name, ':e')
17-
if #name > 0 and #ext > 0 then
18-
-- print(ext)
16+
if #name > 0 then
1917
return false
2018
end
2119
local ipl = ''
22-
local success, result = pcall(vim.api.nvim_buf_get_var, buffer, 'FittenCode.FileType')
23-
if success and result and #result > 0 then
20+
local _, result = pcall(vim.api.nvim_buf_get_var, buffer, 'FittenCode.FileType')
21+
if _ and result and #result > 0 then
2422
ipl = result
2523
end
2624
local filetype = vim.api.nvim_get_option_value('filetype', { buf = buffer })
2725
if #filetype > 0 and #ipl == 0 then
28-
-- print(filetype)
2926
return false
3027
end
3128
return true
@@ -36,7 +33,7 @@ local function send_filetype(buffer)
3633
pre_request:abort()
3734
pre_request = nil
3835
end
39-
if not _check(buffer) then
36+
if not check(buffer) then
4037
return
4138
end
4239
-- 前 100 行足够判断语言了?
@@ -47,7 +44,7 @@ local function send_filetype(buffer)
4744
return
4845
end
4946
res:forward(function(lang)
50-
if not _check(buffer) then
47+
if not check(buffer) then
5148
return
5249
end
5350
print(vim.inspect(lang))
@@ -69,7 +66,7 @@ end
6966
function M.setup()
7067
local function _()
7168
local buffer = vim.api.nvim_get_current_buf()
72-
if not _check(buffer) then
69+
if not check(buffer) then
7370
return
7471
end
7572
if not debound_send_filetype then

0 commit comments

Comments
 (0)