-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use lua for filename-based justfile detection in Neovim >= 0.10
- Loading branch information
1 parent
b46dabb
commit 7b86ee0
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- Vim filetype plugin | ||
-- Language: Justfile | ||
-- Maintainer: Noah Bogart <[email protected]> | ||
-- URL: https://github.com/NoahTheDuke/vim-just.git | ||
-- Last Change: 2024 May 29 | ||
|
||
if vim.fn.has("nvim-0.10") then | ||
vim.filetype.add({ | ||
extension = { | ||
-- Disable extension-based detection of *.just justfiles. | ||
-- The extensions table is also matched against the program in shebang lines, | ||
-- which in case of just scripts is too broad. | ||
just = function() | ||
return nil | ||
end, | ||
}, | ||
|
||
-- Neovim adds start/end anchors to the patterns | ||
pattern = { | ||
['[Jj][Uu][Ss][Tt][Ff][Ii][Ll][Ee]'] = 'just', | ||
['.*%.[Jj][Uu][Ss][Tt][Ff][Ii][Ll][Ee]'] = 'just', | ||
['.*%.[Jj][Uu][Ss][Tt]'] = 'just', | ||
}, | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,9 @@ | |
" Maintainer: Noah Bogart <[email protected]> | ||
" URL: https://github.com/NoahTheDuke/vim-just.git | ||
" Last Change: 2024 Mar 03 | ||
au BufNewFile,BufRead \c{,*.}justfile,\c*.just setfiletype just | ||
|
||
if !has("nvim-0.10") | ||
au BufNewFile,BufRead \c{,*.}justfile,\c*.just setfiletype just | ||
endif | ||
|
||
au BufNewFile,BufRead * if getline(1) =~# '\v^#!/%(\w|[-/])*/%(env%(\s+-S)?\s+)?just\A' | setfiletype just | endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters