Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Implement missing function calls and fix shebang detection #93

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
469cfa1
fix(functions.lua): implement the missing `dist#ft#SetFileTypeSh`
Xevnar Dec 1, 2022
d067f00
fix(function.lua): replace `dist#ft#CSH`
Xevnar Dec 1, 2022
480ec00
fix(functions.lua): implement the missing `dist#ft#FTasm`
Xevnar Dec 1, 2022
af67c78
feat(functions.lua): implement `dist#ft` function related to euphoria
Xevnar Nov 30, 2022
ae6e8ef
feat(functions.lua): pass table containing file metadata to each func…
Xevnar Dec 1, 2022
6da3c27
fix(functions.lua): implement messing `dist#ft#nroff` and `dist#ft#FT…
Xevnar Dec 1, 2022
576a65f
fix(functions.lua): implement missing `dist#ft#FTVB`
Xevnar Dec 1, 2022
fcbc0a0
fix(functions.lua): implement missing `dist#ft#FThtml`
Xevnar Dec 1, 2022
5feb7d9
fix(functions.lua): implement missing `dist#ft#FTxml` and refactor sg…
Xevnar Dec 1, 2022
ecd1939
fix(functions.lua): implement missing `dist#ft#SQL`
Xevnar Dec 1, 2022
7679f9c
fix(functions.lua): implement missing `dist#ft#FTtex`
Xevnar Dec 1, 2022
7193085
fix(functions.lua): implement missing `dist#ft#FTr`
Xevnar Dec 1, 2022
2f6a091
fix(functions.lua): implement missing `dist#ft#ProtoCheck`
Xevnar Dec 1, 2022
f9e19e0
fix(functions.lua): implement missing `dist#ft#DTraceCheck`
Xevnar Dec 1, 2022
0ef9cd5
fix(functions.lua): implement missing `dist#ft#FTheader` and `dist#ft…
Xevnar Dec 1, 2022
5827b6c
fix(functions.lua): implement missing `dist#ft#FTchange`
Xevnar Dec 1, 2022
6cb826a
fix(functions.lua): implement missing `dist#ft#FTidl`
Xevnar Dec 1, 2022
816a4a8
fix(functions.lua): implement the remaining missing `dist#ft` functions
Xevnar Dec 2, 2022
e251f8b
feat(extensions): add systemd `.service` extension
Xevnar Dec 3, 2022
a32b6f6
fix(star_sets): fix broken muttrc lua pattern
Xevnar Dec 3, 2022
31d41a4
docs(README): document the table passed to function callbacks
Xevnar Dec 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 44 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ creating [800+ of them](https://github.com/vim/vim/blob/master/runtime/filetype.
As you can see, `filetype.vim` is by far the heaviest nvim runtime file

```diff
13.782 [runtime]
13.782 [runtime]
- 9.144 /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/filetype.vim
1.662 /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/plugin/matchit.vim
0.459 /usr/local/Cellar/neovim/0.5.0/share/nvim/runtime/syntax/synload.vim
Expand Down Expand Up @@ -84,12 +84,15 @@ require("filetype").setup({
-- Remove annoying indent jumping
vim.bo.cinoptions = vim.bo.cinoptions .. "L0"
end,
["pdf"] = function()

-- The functions recieves an table table with following fields:
-- args table: * file_path: The absolute path of the file
-- * file_name: The name of the file (including extension)
-- * file_ext: The extention at the end of the file
["pdf"] = function(args)
vim.bo.filetype = "pdf"
-- Open in PDF viewer (Skim.app) automatically
vim.fn.jobstart(
"open -a skim " .. '"' .. vim.fn.expand("%") .. '"'
)
vim.fn.jobstart([[open -a skim "]] .. args.file_path .. '"')
end,
},
function_literal = {
Expand All @@ -103,10 +106,42 @@ require("filetype").setup({
end,
},

-- Force check the first line of the file for a shebang if default_filetype is set
force_shebang_check = true, -- default is false

-- Check if the entirety of the shell file for a hint of the executable being used;
-- currently only checks for `tclsh`
check_sh_contents = true, -- default is false

-- The default behaviour when a shebang is detected is to set the filetype to binary
-- used unless the there is mapping from the binary name to filetype defined.
-- You can define your own mapping here
shebang = {
-- Set the filetype of files with a dash shebang to sh
dash = "sh",

-- You don't need to define mappings where the binary name matches the filetype
gnuplot = "gnuplot" -- this is unnecessary

-- Execute code when a python shebang is detected
-- Version numbers at the end of binary names and the env binary are ignored:
-- => #!/bin/python2 = #!/bin/python3 = #!/bin/python = #!/bin/env python = python
python = {
filetype = "python", -- Required if you override the default mapping
on_detect = function()
vim.bo.expandtab = false
end,
},

-- Binary names must end in an alpha character and not contain a space
-- to be correctly identified
["my-sh_interpeter"] = "sh",
["my-sh_interpeter-Ver2"] = "sh", -- This won't work even if it is the actual binary name
["bash --posix"] = "sh", -- Neither would this
},

-- Set a default filetype in the case no matching filetype is detected
default_filetype = 'foo',
},
})
```
Expand All @@ -126,12 +161,12 @@ Average startup time (100 rounds): **36.410 ms**

<details>
<summary>Sample log</summary>

```diff
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines

000.008 000.008: --- NVIM STARTING ---
000.827 000.819: locale set
001.304 000.477: inits 1
Expand Down Expand Up @@ -229,12 +264,12 @@ Average startup time (100 rounds): **26.492 ms**

<details>
<summary>Sample log</summary>

```diff
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines

000.008 000.008: --- NVIM STARTING ---
000.813 000.805: locale set
001.282 000.470: inits 1
Expand Down
Loading