aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/dist/ft.vim22
-rw-r--r--runtime/doc/lua.txt43
-rw-r--r--runtime/filetype.vim18
-rw-r--r--runtime/lua/vim/filetype.lua5
-rw-r--r--runtime/syntax/query.lua6
5 files changed, 77 insertions, 17 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 0063e9da0b..866196a7df 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -773,6 +773,28 @@ func dist#ft#SQL()
endif
endfunc
+" This function checks the first 25 lines of file extension "sc" to resolve
+" detection between scala and SuperCollider
+func dist#ft#FTsc()
+ for lnum in range(1, min([line("$"), 25]))
+ if getline(lnum) =~# '[A-Za-z0-9]*\s:\s[A-Za-z0-9]\|var\s<\|classvar\s<\|\^this.*\||\w*|\|+\s\w*\s{\|\*ar\s'
+ setf supercollider
+ return
+ endif
+ endfor
+ setf scala
+endfunc
+
+" This function checks the first line of file extension "scd" to resolve
+" detection between scdoc and SuperCollider
+func dist#ft#FTscd()
+ if getline(1) =~# '\%^\S\+(\d[0-9A-Za-z]*)\%(\s\+\"[^"]*\"\%(\s\+\"[^"]*\"\)\=\)\=$'
+ setf scdoc
+ else
+ setf supercollider
+ endif
+endfunc
+
" If the file has an extension of 't' and is in a directory 't' or 'xt' then
" it is almost certainly a Perl test file.
" If the first line starts with '#' and contains 'perl' it's probably a Perl
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 25c5dd326e..46b9f0576f 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -21,19 +21,44 @@ Nvim includes a "standard library" |lua-stdlib| for Lua. It complements the
which can be used from Lua code. A good overview of using Lua in neovim is
given by https://github.com/nanotee/nvim-lua-guide.
-Module conflicts are resolved by "last wins". For example if both of these
-are on 'runtimepath':
- runtime/lua/foo.lua
- ~/.config/nvim/lua/foo.lua
-then `require('foo')` loads "~/.config/nvim/lua/foo.lua", and
-"runtime/lua/foo.lua" is not used. See |lua-require| to understand how Nvim
-finds and loads Lua modules. The conventions are similar to those of
-Vimscript |plugin|s, with some extra features. See |lua-require-example| for
-a walkthrough.
+The |:source| and |:runtime| commands can run Lua scripts as well as Vim
+scripts. Lua modules can be loaded with `require('name')`, which
+conventionally returns a table but can return any value.
+
+See |lua-require| for details on how Nvim finds and loads Lua modules.
+See |lua-require-example| for an example of how to write and use a module.
==============================================================================
IMPORTING LUA MODULES *lua-require*
+Modules are searched for under the directories specified in 'runtimepath', in
+the order they appear. Any `.` in the module name is treated as a directory
+separator when searching. For a module `foo.bar`, each directory is searched
+for `lua/foo/bar.lua`, then `lua/foo/bar/init.lua`. If no files are found,
+the directories are searched again for a shared library with a name matching
+`lua/foo/bar.?`, where `?` is a list of suffixes (such as `so` or `dll`)
+derived from the initial value of `package.cpath`. If still no files are
+found, Nvim falls back to Lua's default search mechanism. The first script
+found is run and `require()` returns the value returned by the script if any,
+else `true`.
+
+The return value is cached after the first call to `require()` for each
+module, with subsequent calls returning the cached value without searching for
+or executing any script. For further details on `require()`, see the Lua
+documentation at https://www.lua.org/manual/5.1/manual.html#pdf-require.
+
+For example, if 'runtimepath' is `foo,bar` and `package.cpath` was
+`./?.so;./?.dll` at startup, `require('mod')` searches these paths in order
+and loads the first module found:
+ foo/lua/mod.lua
+ foo/lua/mod/init.lua
+ bar/lua/mod.lua
+ bar/lua/mod/init.lua
+ foo/lua/mod.so
+ foo/lua/mod.dll
+ bar/lua/mod.so
+ bar/lua/mod.dll
+
*lua-package-path*
Nvim automatically adjusts `package.path` and `package.cpath` according to
effective 'runtimepath' value. Adjustment happens whenever 'runtimepath' is
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index c5690ba716..f7c0317eff 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -202,12 +202,12 @@ au BufNewFile,BufRead *.iba,*.ibi setf ibasic
au BufNewFile,BufRead *.fb setf freebasic
" Batch file for MSDOS. See dist#ft#FTsys for *.sys
-au BufNewFile,BufRead *.bat setf dosbatch
+au BufNewFile,BufRead *.bat setf dosbatch
" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
au BufNewFile,BufRead *.cmd
\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
" ABB RAPID or Batch file for MSDOS.
-au BufNewFile,BufRead *.sys\c call dist#ft#FTsys()
+au BufNewFile,BufRead *.sys\c call dist#ft#FTsys()
" Batch file for 4DOS
au BufNewFile,BufRead *.btm call dist#ft#FTbtm()
@@ -1140,7 +1140,7 @@ au BufNewFile,BufRead *.mms call dist#ft#FTmms()
au BufNewFile,BufRead *.mmp setf mmp
" ABB Rapid, Modula-2, Modsim III or LambdaProlog
-au BufNewFile,BufRead *.mod\c call dist#ft#FTmod()
+au BufNewFile,BufRead *.mod\c call dist#ft#FTmod()
" Modula-2 (.md removed in favor of Markdown, see dist#ft#FTmod for *.MOD)
au BufNewFile,BufRead *.m2,*.DEF,*.mi setf modula2
@@ -1630,16 +1630,22 @@ au BufNewFile,BufRead *.sass setf sass
au BufNewFile,BufRead *.sa setf sather
" Scala
-au BufNewFile,BufRead *.scala,*.sc setf scala
+au BufNewFile,BufRead *.scala setf scala
" SBT - Scala Build Tool
au BufNewFile,BufRead *.sbt setf sbt
+" SuperCollider
+au BufNewFile,BufRead *.sc call dist#ft#FTsc()
+
+au BufNewFile,BufRead *.quark setf supercollider
+
+" scdoc
+au BufNewFile,BufRead *.scd call dist#ft#FTscd()
+
" Scilab
au BufNewFile,BufRead *.sci,*.sce setf scilab
-" scdoc
-au BufNewFile,BufRead *.scd setf scdoc
" SCSS
au BufNewFile,BufRead *.scss setf scss
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index 880b99a2fa..603f9f854a 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -569,8 +569,6 @@ local extension = {
sa = "sather",
sbt = "sbt",
scala = "scala",
- sc = "scala",
- scd = "scdoc",
ss = "scheme",
scm = "scheme",
sld = "scheme",
@@ -644,6 +642,7 @@ local extension = {
mata = "stata",
ado = "stata",
stp = "stp",
+ quark = "supercollider",
sface = "surface",
svelte = "svelte",
svg = "svg",
@@ -830,6 +829,8 @@ local extension = {
r = function() vim.fn["dist#ft#FTr"]() end,
rdf = function() vim.fn["dist#ft#Redif"]() end,
rules = function() vim.fn["dist#ft#FTRules"]() end,
+ sc = function() vim.fn["dist#ft#FTsc"]() end,
+ scd = function() vim.fn["dist#ft#FTscd"]() end,
sh = function() vim.fn["dist#ft#SetFileTypeSH"](vim.fn.getline(1)) end,
shtml = function() vim.fn["dist#ft#FThtml"]() end,
sql = function() vim.fn["dist#ft#SQL"]() end,
diff --git a/runtime/syntax/query.lua b/runtime/syntax/query.lua
new file mode 100644
index 0000000000..e24ff65360
--- /dev/null
+++ b/runtime/syntax/query.lua
@@ -0,0 +1,6 @@
+-- Neovim syntax file
+-- Language: Tree-sitter query
+-- Last Change: 2022 Apr 13
+
+-- it's a lisp!
+vim.cmd [[ runtime! syntax/lisp.vim ]]