A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/f40ce3456313138f2e0f822da9676ed3bc51f608 below:

match on <afile> rather than <abuf> (#16943) · neovim/neovim@f40ce34 · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+16

-17

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+16

-17

lines changed Original file line number Diff line number Diff line change

@@ -9,7 +9,7 @@ end

9 9 10 10

vim.cmd [[

11 11

augroup filetypedetect

12 -

au BufRead,BufNewFile * call v:lua.vim.filetype.match(str2nr(expand('<abuf>')))

12 +

au BufRead,BufNewFile * call v:lua.vim.filetype.match(expand('<afile>'))

13 13 14 14

" These *must* be sourced after the autocommand above is created

15 15

runtime! ftdetect/*.vim

Original file line number Diff line number Diff line change

@@ -1449,15 +1449,20 @@ local function dispatch(ft, path, bufnr, ...)

1449 1449

end

1450 1450 1451 1451

---@private

1452 -

function M.match(bufnr)

1453 -

local path = api.nvim_buf_get_name(bufnr)

1452 +

function M.match(name, bufnr)

1453 +

-- When fired from the main filetypedetect autocommand the {bufnr} argument is omitted, so we use

1454 +

-- the current buffer. The {bufnr} argument is provided to allow extensibility in case callers

1455 +

-- wish to perform filetype detection on buffers other than the current one.

1456 +

bufnr = bufnr or api.nvim_get_current_buf()

1457 + 1454 1458

-- First check for the simple case where the full path exists as a key

1459 +

local path = vim.fn.fnamemodify(name, ":p")

1455 1460

if dispatch(filename[path], path, bufnr) then

1456 1461

return

1457 1462

end

1458 1463 1459 1464

-- Next check against just the file name

1460 -

local tail = vim.fn.fnamemodify(path, ":t")

1465 +

local tail = vim.fn.fnamemodify(name, ":t")

1461 1466

if dispatch(filename[tail], path, bufnr) then

1462 1467

return

1463 1468

end

@@ -1477,7 +1482,7 @@ function M.match(bufnr)

1477 1482

end

1478 1483 1479 1484

-- Finally, check file extension

1480 -

local ext = vim.fn.fnamemodify(path, ":e")

1485 +

local ext = vim.fn.fnamemodify(name, ":e")

1481 1486

if dispatch(extension[ext], path, bufnr) then

1482 1487

return

1483 1488

end

Original file line number Diff line number Diff line change

@@ -24,8 +24,7 @@ describe('vim.filetype', function()

24 24

rs = 'radicalscript',

25 25

},

26 26

})

27 -

vim.api.nvim_buf_set_name(0, 'main.rs')

28 -

vim.filetype.match(0)

27 +

vim.filetype.match('main.rs')

29 28

return vim.bo.filetype

30 29

]])

31 30

end)

@@ -40,8 +39,7 @@ describe('vim.filetype', function()

40 39

['main.rs'] = 'somethingelse',

41 40

},

42 41

})

43 -

vim.api.nvim_buf_set_name(0, 'main.rs')

44 -

vim.filetype.match(0)

42 +

vim.filetype.match('main.rs')

45 43

return vim.bo.filetype

46 44

]])

47 45

end)

@@ -53,8 +51,7 @@ describe('vim.filetype', function()

53 51

['s_O_m_e_F_i_l_e'] = 'nim',

54 52

},

55 53

})

56 -

vim.api.nvim_buf_set_name(0, 's_O_m_e_F_i_l_e')

57 -

vim.filetype.match(0)

54 +

vim.filetype.match('s_O_m_e_F_i_l_e')

58 55

return vim.bo.filetype

59 56

]])

60 57

@@ -66,8 +63,7 @@ describe('vim.filetype', function()

66 63

[root .. '/.config/fun/config'] = 'dosini',

67 64

},

68 65

})

69 -

vim.api.nvim_buf_set_name(0, root .. '/.config/fun/config')

70 -

vim.filetype.match(0)

66 +

vim.filetype.match(root .. '/.config/fun/config')

71 67

return vim.bo.filetype

72 68

]], root))

73 69

end)

@@ -80,8 +76,7 @@ describe('vim.filetype', function()

80 76

[root .. '/blog/.*%.txt'] = 'markdown',

81 77

}

82 78

})

83 -

vim.api.nvim_buf_set_name(0, root .. '/blog/why_neovim_is_awesome.txt')

84 -

vim.filetype.match(0)

79 +

vim.filetype.match(root .. '/blog/why_neovim_is_awesome.txt')

85 80

return vim.bo.filetype

86 81

]], root))

87 82

end)

@@ -97,8 +92,7 @@ describe('vim.filetype', function()

97 92

end,

98 93

}

99 94

})

100 -

vim.api.nvim_buf_set_name(0, 'relevant_to_me')

101 -

vim.filetype.match(0)

95 +

vim.filetype.match('relevant_to_me')

102 96

return vim.bo.filetype

103 97

]])

104 98

end)

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4