diff options
Diffstat (limited to 'runtime/ftplugin')
25 files changed, 599 insertions, 32 deletions
diff --git a/runtime/ftplugin/c.vim b/runtime/ftplugin/c.vim index 8b2b784eb4..3b05ce182a 100644 --- a/runtime/ftplugin/c.vim +++ b/runtime/ftplugin/c.vim @@ -39,7 +39,7 @@ endif " When the matchit plugin is loaded, this makes the % command skip parens and " braces in comments properly. if !exists("b:match_words") - let b:match_words = '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>' + let b:match_words = '^\s*#\s*if\%(\|def\|ndef\)\>:^\s*#\s*elif\%(\|def\|ndef\)\>:^\s*#\s*else\>:^\s*#\s*endif\>' let b:match_skip = 's:comment\|string\|character\|special' let b:undo_ftplugin ..= " | unlet! b:match_skip b:match_words" endif diff --git a/runtime/ftplugin/c3.vim b/runtime/ftplugin/c3.vim new file mode 100644 index 0000000000..6db665a03a --- /dev/null +++ b/runtime/ftplugin/c3.vim @@ -0,0 +1,14 @@ +" Vim filetype plugin +" Language: C3 +" Maintainer: Turiiya <34311583+ttytm@users.noreply.github.com> +" Last Change: 2024 Nov 24 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +setl comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,:// +setl commentstring=//\ %s + +let b:undo_ftplugin = 'setl com< cms<' diff --git a/runtime/ftplugin/checkhealth.vim b/runtime/ftplugin/checkhealth.vim index 00f24a2912..cc53d723c2 100644 --- a/runtime/ftplugin/checkhealth.vim +++ b/runtime/ftplugin/checkhealth.vim @@ -1,6 +1,5 @@ " Vim filetype plugin " Language: Nvim :checkhealth buffer -" Last Change: 2022 Nov 10 if exists("b:did_ftplugin") finish diff --git a/runtime/ftplugin/dockerfile.vim b/runtime/ftplugin/dockerfile.vim index 2e3c447b59..e45bf4c1d8 100644 --- a/runtime/ftplugin/dockerfile.vim +++ b/runtime/ftplugin/dockerfile.vim @@ -1,7 +1,7 @@ " Vim filetype plugin " Language: Dockerfile " Maintainer: Honza Pokorny <http://honza.ca> -" Last Change: 2014 Aug 29 +" Last Change: 2024 Dec 20 " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -11,6 +11,6 @@ endif " Don't load another plugin for this buffer let b:did_ftplugin = 1 -let b:undo_ftplugin = "setl commentstring<" - setlocal commentstring=#\ %s + +let b:undo_ftplugin = "setl commentstring<" diff --git a/runtime/ftplugin/editorconfig.vim b/runtime/ftplugin/editorconfig.vim index 6d437351eb..1693a95c0b 100644 --- a/runtime/ftplugin/editorconfig.vim +++ b/runtime/ftplugin/editorconfig.vim @@ -1,7 +1,7 @@ " Vim filetype plugin " Language: EditorConfig " Maintainer: Riley Bruins <ribru17@gmail.com> -" Last Change: 2024 Jul 06 +" Last Change: 2025 Jan 10 if exists('b:did_ftplugin') finish @@ -10,4 +10,6 @@ let b:did_ftplugin = 1 setl comments=:#,:; commentstring=#\ %s -let b:undo_ftplugin = 'setl com< cms<' +setl omnifunc=syntaxcomplete#Complete + +let b:undo_ftplugin = 'setl com< cms< ofu<' diff --git a/runtime/ftplugin/gel.vim b/runtime/ftplugin/gel.vim new file mode 100644 index 0000000000..b1f4def2b8 --- /dev/null +++ b/runtime/ftplugin/gel.vim @@ -0,0 +1,13 @@ +" Vim filetype plugin file +" Language: TI Code Composer Studio General Extension Language +" Document: https://downloads.ti.com/ccs/esd/documents/users_guide/ccs_debug-gel.html +" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu> +" Last Change: 2024 Dec 25 + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,:// +setlocal commentstring=/*\ %s\ */ + +let b:undo_ftplugin = "setl commentstring< comments<" diff --git a/runtime/ftplugin/graphql.vim b/runtime/ftplugin/graphql.vim index 56f6e36e20..1717ebf2cc 100644 --- a/runtime/ftplugin/graphql.vim +++ b/runtime/ftplugin/graphql.vim @@ -1,13 +1,22 @@ " Vim filetype plugin " Language: graphql -" Maintainer: Riley Bruins <ribru17@gmail.com> -" Last Change: 2024 May 18 +" Maintainer: Jon Parise <jon@indelible.org> +" Filenames: *.graphql *.graphqls *.gql +" URL: https://github.com/jparise/vim-graphql +" License: MIT <https://opensource.org/license/mit> +" Last Change: 2024 Dec 21 if exists('b:did_ftplugin') finish endif let b:did_ftplugin = 1 -setl comments=:# commentstring=#\ %s +setlocal comments=:# +setlocal commentstring=#\ %s +setlocal formatoptions-=t +setlocal iskeyword+=$,@-@ +setlocal softtabstop=2 +setlocal shiftwidth=2 +setlocal expandtab -let b:undo_ftplugin = 'setl com< cms<' +let b:undo_ftplugin = 'setlocal com< cms< fo< isk< sts< sw< et<' diff --git a/runtime/ftplugin/help.lua b/runtime/ftplugin/help.lua index 8d991be0e4..a6169a1d9d 100644 --- a/runtime/ftplugin/help.lua +++ b/runtime/ftplugin/help.lua @@ -31,5 +31,56 @@ vim.keymap.set('n', 'gO', function() require('vim.vimhelp').show_toc() end, { buffer = 0, silent = true }) -vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') .. '\n exe "nunmap <buffer> gO"' +-- Add "runnables" for Lua/Vimscript code examples. +---@type table<integer, { lang: string, code: string }> +local code_blocks = {} +local tree = vim.treesitter.get_parser():parse()[1] +local query = vim.treesitter.query.parse( + 'vimdoc', + [[ + (codeblock + (language) @_lang + . + (code) @code + (#any-of? @_lang "lua" "vim") + (#set! @code lang @_lang)) +]] +) +local run_message_ns = vim.api.nvim_create_namespace('nvim.vimdoc.run_message') + +vim.api.nvim_buf_clear_namespace(0, run_message_ns, 0, -1) +for _, match, metadata in query:iter_matches(tree:root(), 0, 0, -1) do + for id, nodes in pairs(match) do + local name = query.captures[id] + local node = nodes[1] + local start, _, end_ = node:parent():range() + + if name == 'code' then + vim.api.nvim_buf_set_extmark(0, run_message_ns, start, 0, { + virt_text = { { 'Run with `g==`', 'LspCodeLens' } }, + }) + local code = vim.treesitter.get_node_text(node, 0) + local lang_node = match[metadata[id].lang][1] --[[@as TSNode]] + local lang = vim.treesitter.get_node_text(lang_node, 0) + for i = start + 1, end_ do + code_blocks[i] = { lang = lang, code = code } + end + end + end +end + +vim.keymap.set('n', 'g==', function() + local pos = vim.api.nvim_win_get_cursor(0)[1] + local code_block = code_blocks[pos] + if not code_block then + vim.print('No code block found') + elseif code_block.lang == 'lua' then + vim.cmd.lua(code_block.code) + elseif code_block.lang == 'vim' then + vim.cmd(code_block.code) + end +end, { buffer = true }) + +vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '') + .. '\n exe "nunmap <buffer> gO" | exe "nunmap <buffer> g=="' vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()' diff --git a/runtime/ftplugin/java.vim b/runtime/ftplugin/java.vim index 55b358374f..cfd25bce6c 100644 --- a/runtime/ftplugin/java.vim +++ b/runtime/ftplugin/java.vim @@ -3,7 +3,7 @@ " Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com> " Former Maintainer: Dan Sharp " Repository: https://github.com/zzzyxwvut/java-vim.git -" Last Change: 2024 Sep 26 +" Last Change: 2024 Dec 25 " 2024 Jan 14 by Vim Project (browsefilter) " 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring') @@ -90,10 +90,269 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") endif endif +"""" Support pre- and post-compiler actions for SpotBugs. +if (!empty(get(g:, 'spotbugs_properties', {})) || + \ !empty(get(b:, 'spotbugs_properties', {}))) && + \ filereadable($VIMRUNTIME . '/compiler/spotbugs.vim') + + function! s:SpotBugsGetProperty(name, default) abort + return get( + \ {s:spotbugs_properties_scope}spotbugs_properties, + \ a:name, + \ a:default) + endfunction + + function! s:SpotBugsHasProperty(name) abort + return has_key( + \ {s:spotbugs_properties_scope}spotbugs_properties, + \ a:name) + endfunction + + function! s:SpotBugsGetProperties() abort + return {s:spotbugs_properties_scope}spotbugs_properties + endfunction + + " Work around ":bar"s and ":autocmd"s. + function! JavaFileTypeExecuteActionOnce(cleanup_cmd, action_cmd) abort + try + execute a:cleanup_cmd + finally + execute a:action_cmd + endtry + endfunction + + if exists("b:spotbugs_properties") + let s:spotbugs_properties_scope = 'b:' + + " Merge global entries, if any, in buffer-local entries, favouring + " defined buffer-local ones. + call extend( + \ b:spotbugs_properties, + \ get(g:, 'spotbugs_properties', {}), + \ 'keep') + elseif exists("g:spotbugs_properties") + let s:spotbugs_properties_scope = 'g:' + endif + + let s:commands = {} + + for s:name in ['DefaultPreCompilerCommand', + \ 'DefaultPreCompilerTestCommand', + \ 'DefaultPostCompilerCommand'] + if s:SpotBugsHasProperty(s:name) + let s:commands[s:name] = remove( + \ s:SpotBugsGetProperties(), + \ s:name) + endif + endfor + + if s:SpotBugsHasProperty('compiler') + " XXX: Postpone loading the script until all state, if any, has been + " collected. + if !empty(s:commands) + let g:spotbugs#state = { + \ 'compiler': remove(s:SpotBugsGetProperties(), 'compiler'), + \ 'commands': copy(s:commands), + \ } + else + let g:spotbugs#state = { + \ 'compiler': remove(s:SpotBugsGetProperties(), 'compiler'), + \ } + endif + + " Merge default entries in global (or buffer-local) entries, favouring + " defined global (or buffer-local) ones. + call extend( + \ {s:spotbugs_properties_scope}spotbugs_properties, + \ spotbugs#DefaultProperties(), + \ 'keep') + elseif !empty(s:commands) + " XXX: Postpone loading the script until all state, if any, has been + " collected. + let g:spotbugs#state = {'commands': copy(s:commands)} + endif + + unlet s:commands s:name + let s:request = 0 + + if s:SpotBugsHasProperty('PostCompilerAction') + let s:request += 4 + endif + + if s:SpotBugsHasProperty('PreCompilerTestAction') + let s:dispatcher = printf('call call(%s, [])', + \ string(s:SpotBugsGetProperties().PreCompilerTestAction)) + let s:request += 2 + endif + + if s:SpotBugsHasProperty('PreCompilerAction') + let s:dispatcher = printf('call call(%s, [])', + \ string(s:SpotBugsGetProperties().PreCompilerAction)) + let s:request += 1 + endif + + " Adapt the tests for "s:FindClassFiles()" from "compiler/spotbugs.vim". + if (s:request == 3 || s:request == 7) && + \ (!empty(s:SpotBugsGetProperty('sourceDirPath', [])) && + \ !empty(s:SpotBugsGetProperty('classDirPath', [])) && + \ !empty(s:SpotBugsGetProperty('testSourceDirPath', [])) && + \ !empty(s:SpotBugsGetProperty('testClassDirPath', []))) + function! s:DispatchAction(paths_action_pairs) abort + let name = expand('%:p') + + for [paths, Action] in a:paths_action_pairs + for path in paths + if name =~# (path . '.\{-}\.java\=$') + call Action() + return + endif + endfor + endfor + endfunction + + let s:dir_cnt = min([ + \ len(s:SpotBugsGetProperties().sourceDirPath), + \ len(s:SpotBugsGetProperties().classDirPath)]) + let s:test_dir_cnt = min([ + \ len(s:SpotBugsGetProperties().testSourceDirPath), + \ len(s:SpotBugsGetProperties().testClassDirPath)]) + + " Do not break up path pairs with filtering! + let s:dispatcher = printf('call s:DispatchAction(%s)', + \ string([[s:SpotBugsGetProperties().sourceDirPath[0 : s:dir_cnt - 1], + \ s:SpotBugsGetProperties().PreCompilerAction], + \ [s:SpotBugsGetProperties().testSourceDirPath[0 : s:test_dir_cnt - 1], + \ s:SpotBugsGetProperties().PreCompilerTestAction]])) + unlet s:test_dir_cnt s:dir_cnt + endif + + if exists("s:dispatcher") + function! s:ExecuteActions(pre_action, post_action) abort + try + execute a:pre_action + catch /\<E42:/ + execute a:post_action + endtry + endfunction + endif + + if s:request + if exists("b:spotbugs_syntax_once") || empty(join(getline(1, 8), '')) + let s:actions = [{'event': 'User'}] + else + " XXX: Handle multiple FileType events when vimrc contains more + " than one filetype setting for the language, e.g.: + " :filetype plugin indent on + " :autocmd BufRead,BufNewFile *.java setlocal filetype=java ... + " XXX: DO NOT ADD b:spotbugs_syntax_once TO b:undo_ftplugin ! + let b:spotbugs_syntax_once = 1 + let s:actions = [{ + \ 'event': 'Syntax', + \ 'once': 1, + \ }, { + \ 'event': 'User', + \ }] + endif + + for s:idx in range(len(s:actions)) + if s:request == 7 || s:request == 6 || s:request == 5 + let s:actions[s:idx].cmd = printf('call s:ExecuteActions(%s, %s)', + \ string(s:dispatcher), + \ string(printf('compiler spotbugs | call call(%s, [])', + \ string(s:SpotBugsGetProperties().PostCompilerAction)))) + elseif s:request == 4 + let s:actions[s:idx].cmd = printf( + \ 'compiler spotbugs | call call(%s, [])', + \ string(s:SpotBugsGetProperties().PostCompilerAction)) + elseif s:request == 3 || s:request == 2 || s:request == 1 + let s:actions[s:idx].cmd = printf('call s:ExecuteActions(%s, %s)', + \ string(s:dispatcher), + \ string('compiler spotbugs')) + else + let s:actions[s:idx].cmd = '' + endif + endfor + + if !exists("#java_spotbugs") + augroup java_spotbugs + augroup END + endif + + " The events are defined in s:actions. + silent! autocmd! java_spotbugs User <buffer> + silent! autocmd! java_spotbugs Syntax <buffer> + + for s:action in s:actions + if has_key(s:action, 'once') + execute printf('autocmd java_spotbugs %s <buffer> ' . + \ 'call JavaFileTypeExecuteActionOnce(%s, %s)', + \ s:action.event, + \ string(printf('autocmd! java_spotbugs %s <buffer>', + \ s:action.event)), + \ string(s:action.cmd)) + else + execute printf('autocmd java_spotbugs %s <buffer> %s', + \ s:action.event, + \ s:action.cmd) + endif + endfor + + if s:SpotBugsHasProperty('PostCompilerActionExecutor') && + \ (s:request == 7 || s:request == 6 || + \ s:request == 5 || s:request == 4) + let s:augroup = s:SpotBugsGetProperty( + \ 'augroupForPostCompilerAction', + \ 'java_spotbugs_post') + let s:augroup = !empty(s:augroup) ? s:augroup : 'java_spotbugs_post' + + for s:candidate in ['java_spotbugs_post', s:augroup] + if !exists("#" . s:candidate) + execute printf('augroup %s | augroup END', s:candidate) + endif + endfor + + silent! autocmd! java_spotbugs_post User <buffer> + + " Define a User ":autocmd" to define a once-only ShellCmdPost + " ":autocmd" that will invoke "PostCompilerActionExecutor" and let + " it decide whether to proceed with ":compiler spotbugs" etc.; and + " seek explicit synchronisation with ":doautocmd ShellCmdPost" by + " omitting "nested" for "java_spotbugs_post" and "java_spotbugs". + execute printf('autocmd java_spotbugs_post User <buffer> ' . + \ 'call JavaFileTypeExecuteActionOnce(%s, %s)', + \ string(printf('autocmd! %s ShellCmdPost <buffer>', s:augroup)), + \ string(printf('autocmd %s ShellCmdPost <buffer> ' . + \ 'call JavaFileTypeExecuteActionOnce(%s, %s)', + \ s:augroup, + \ string(printf('autocmd! %s ShellCmdPost <buffer>', s:augroup)), + \ string(printf('call call(%s, [%s])', + \ string(s:SpotBugsGetProperties().PostCompilerActionExecutor), + \ string(printf('compiler spotbugs | call call(%s, [])', + \ string(s:SpotBugsGetProperties().PostCompilerAction)))))))) + endif + + unlet! s:candidate s:augroup s:action s:actions s:idx s:dispatcher + endif + + delfunction s:SpotBugsGetProperties + delfunction s:SpotBugsHasProperty + delfunction s:SpotBugsGetProperty + unlet! s:request s:spotbugs_properties_scope +endif + +function! JavaFileTypeCleanUp() abort + setlocal suffixes< suffixesadd< formatoptions< comments< commentstring< path< includeexpr< + unlet! b:browsefilter + + " The concatenated ":autocmd" removals may be misparsed as an ":autocmd". + " A _once-only_ ShellCmdPost ":autocmd" is always a call-site definition. + silent! autocmd! java_spotbugs User <buffer> + silent! autocmd! java_spotbugs Syntax <buffer> + silent! autocmd! java_spotbugs_post User <buffer> +endfunction + " Undo the stuff we changed. -let b:undo_ftplugin = "setlocal suffixes< suffixesadd<" . - \ " formatoptions< comments< commentstring< path< includeexpr<" . - \ " | unlet! b:browsefilter" +let b:undo_ftplugin = 'call JavaFileTypeCleanUp() | delfunction JavaFileTypeCleanUp' " See ":help vim9-mix". if !has("vim9script") @@ -114,6 +373,21 @@ if exists("s:zip_func_upgradable") setlocal suffixesadd< endif +if exists("*s:DispatchAction") + def! s:DispatchAction(paths_action_pairs: list<list<any>>) + const name: string = expand('%:p') + + for [paths: list<string>, Action: func: any] in paths_action_pairs + for path in paths + if name =~# (path .. '.\{-}\.java\=$') + Action() + return + endif + endfor + endfor + enddef +endif + " Restore the saved compatibility options. let &cpo = s:save_cpo unlet s:save_cpo diff --git a/runtime/ftplugin/jj.vim b/runtime/ftplugin/jjdescription.vim index cc5d700a30..cc5d700a30 100644 --- a/runtime/ftplugin/jj.vim +++ b/runtime/ftplugin/jjdescription.vim diff --git a/runtime/ftplugin/just.vim b/runtime/ftplugin/just.vim new file mode 100644 index 0000000000..6f2acddf96 --- /dev/null +++ b/runtime/ftplugin/just.vim @@ -0,0 +1,17 @@ +" Vim ftplugin file +" Language: Justfile +" Maintainer: Peter Benjamin <@pbnj> +" Last Change: 2025 Jan 19 +" Credits: The original author, Noah Bogart <https://github.com/NoahTheDuke/vim-just/> + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal iskeyword+=- +setlocal comments=n:# +setlocal commentstring=#\ %s + +let b:undo_ftplugin = "setlocal iskeyword< comments< commentstring<" diff --git a/runtime/ftplugin/karel.vim b/runtime/ftplugin/karel.vim new file mode 100644 index 0000000000..8ccc2b32ce --- /dev/null +++ b/runtime/ftplugin/karel.vim @@ -0,0 +1,16 @@ +" Vim filetype plugin file +" Language: KAREL +" Last Change: 2024-11-18 +" Maintainer: Kirill Morozov <kirill@robotix.pro> +" Credits: Patrick Meiser-Knosowski for the initial implementation. + +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +setlocal comments=:-- +setlocal commentstring=--\ %s +setlocal suffixesadd+=.kl,.KL + +let b:undo_ftplugin = "setlocal com< cms< sua<" diff --git a/runtime/ftplugin/kconfig.vim b/runtime/ftplugin/kconfig.vim index 767490701b..1c2857ec50 100644 --- a/runtime/ftplugin/kconfig.vim +++ b/runtime/ftplugin/kconfig.vim @@ -2,7 +2,7 @@ " Vim syntax file " Maintainer: Christian Brabandt <cb@256bit.org> " Previous Maintainer: Nikolai Weibull <now@bitwi.se> -" Latest Revision: 2024-04-12 +" Latest Revision: 2025 Jan 20 " License: Vim (see :h license) " Repository: https://github.com/chrisbra/vim-kconfig @@ -19,4 +19,5 @@ setlocal comments=:# commentstring=#\ %s formatoptions-=t formatoptions+=croql " For matchit.vim if exists("loaded_matchit") let b:match_words = '^\<menu\>:\<endmenu\>,^\<if\>:\<endif\>,^\<choice\>:\<endchoice\>' + let b:undo_ftplugin .= "| unlet! b:match_words" endif diff --git a/runtime/ftplugin/lnk.vim b/runtime/ftplugin/lnk.vim new file mode 100644 index 0000000000..8b280d9836 --- /dev/null +++ b/runtime/ftplugin/lnk.vim @@ -0,0 +1,14 @@ +" Vim filetype plugin file +" Language: TI linker command file +" Document: https://software-dl.ti.com/ccs/esd/documents/sdto_cgt_Linker-Command-File-Primer.html +" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu> +" Last Change: 2024 Dec 31 + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,:// +setlocal commentstring=/*\ %s\ */ +setlocal iskeyword+=. + +let b:undo_ftplugin = "setl commentstring< comments< iskeyword<" diff --git a/runtime/ftplugin/lnkmap.vim b/runtime/ftplugin/lnkmap.vim new file mode 100644 index 0000000000..46fb070e71 --- /dev/null +++ b/runtime/ftplugin/lnkmap.vim @@ -0,0 +1,16 @@ +" Vim filetype plugin file +" Language: TI Linker map +" Document: https://downloads.ti.com/docs/esd/SPRUI03A/Content/SPRUI03A_HTML/linker_description.html +" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu> +" Last Change: 2024 Dec 25 + +if exists("b:did_ftplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +let b:undo_ftplugin = "setl iskeyword<" + +setl iskeyword+=. diff --git a/runtime/ftplugin/opencl.vim b/runtime/ftplugin/opencl.vim new file mode 100644 index 0000000000..e8570fbe95 --- /dev/null +++ b/runtime/ftplugin/opencl.vim @@ -0,0 +1,12 @@ +" Vim filetype plugin file +" Language: OpenCL +" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu> +" Last Change: 2024 Nov 19 + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,:// +setlocal commentstring=/*\ %s\ */ define& include& + +let b:undo_ftplugin = "setl commentstring< comments<" diff --git a/runtime/ftplugin/proto.vim b/runtime/ftplugin/proto.vim new file mode 100644 index 0000000000..585f4461d3 --- /dev/null +++ b/runtime/ftplugin/proto.vim @@ -0,0 +1,18 @@ +" Vim filetype plugin +" Language: Protobuf +" Maintainer: David Pedersen <limero@me.com> +" Last Change: 2024 Dec 09 + +if exists('b:did_ftplugin') + finish +endif +let b:did_ftplugin = 1 + +setlocal formatoptions-=t formatoptions+=croql + +setlocal comments=s1:/*,mb:*,ex:*/,:// +setlocal commentstring=//\ %s + +let b:undo_ftplugin = "setlocal formatoptions< comments< commentstring<" + +" vim: sw=2 sts=2 et diff --git a/runtime/ftplugin/ptx.vim b/runtime/ftplugin/ptx.vim new file mode 100644 index 0000000000..12b127c8fc --- /dev/null +++ b/runtime/ftplugin/ptx.vim @@ -0,0 +1,16 @@ +" Vim filetype plugin file +" Language: Nvidia PTX (Parellel Thread Execution) +" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com> +" Last Change: 2024-12-05 + +if exists("b:did_ftplugin") + finish +endif + +let b:did_ftplugin = 1 + +" Comments in PTX follow C/C++ syntax +" See: https://docs.nvidia.com/cuda/parallel-thread-execution/#syntax +setlocal commentstring=//\ %s + +let b:undo_ftplugin = 'setl commentstring<' diff --git a/runtime/ftplugin/python.vim b/runtime/ftplugin/python.vim index c000296726..6f20468896 100644 --- a/runtime/ftplugin/python.vim +++ b/runtime/ftplugin/python.vim @@ -3,8 +3,9 @@ " Maintainer: Tom Picton <tom@tompicton.com> " Previous Maintainer: James Sully <sullyj3@gmail.com> " Previous Maintainer: Johannes Zellner <johannes@zellner.org> -" Last Change: 2024/05/13 -" https://github.com/tpict/vim-ftplugin-python +" Repository: https://github.com/tpict/vim-ftplugin-python +" Last Change: 2024/05/13 +" 2024 Nov 30 use pytest compiler (#16130) if exists("b:did_ftplugin") | finish | endif let b:did_ftplugin = 1 @@ -134,6 +135,11 @@ elseif executable('python') setlocal keywordprg=python\ -m\ pydoc endif +if expand('%:t') =~# '\v^test_.*\.py$|_test\.py$' && executable('pytest') + compiler pytest + let &l:makeprg .= ' %:S' +endif + " Script for filetype switching to undo the local stuff we may have changed let b:undo_ftplugin = 'setlocal cinkeys<' \ . '|setlocal comments<' @@ -148,6 +154,7 @@ let b:undo_ftplugin = 'setlocal cinkeys<' \ . '|setlocal softtabstop<' \ . '|setlocal suffixesadd<' \ . '|setlocal tabstop<' + \ . '|setlocal makeprg<' \ . '|silent! nunmap <buffer> [M' \ . '|silent! nunmap <buffer> [[' \ . '|silent! nunmap <buffer> []' diff --git a/runtime/ftplugin/query.lua b/runtime/ftplugin/query.lua index 32d615c65c..aa5cac2f07 100644 --- a/runtime/ftplugin/query.lua +++ b/runtime/ftplugin/query.lua @@ -1,6 +1,5 @@ -- Neovim filetype plugin file -- Language: Treesitter query --- Last Change: 2024 Jul 03 if vim.b.did_ftplugin == 1 then return @@ -22,7 +21,7 @@ local query_lint_on = vim.g.query_lint_on or { 'BufEnter', 'BufWrite' } if not vim.b.disable_query_linter and #query_lint_on > 0 then vim.api.nvim_create_autocmd(query_lint_on, { - group = vim.api.nvim_create_augroup('querylint', { clear = false }), + group = vim.api.nvim_create_augroup('nvim.querylint', { clear = false }), buffer = buf, callback = function() vim.treesitter.query.lint(buf) diff --git a/runtime/ftplugin/sh.vim b/runtime/ftplugin/sh.vim index 4c7695dcc6..54ae73b675 100644 --- a/runtime/ftplugin/sh.vim +++ b/runtime/ftplugin/sh.vim @@ -5,6 +5,7 @@ " Contributor: Enno Nagel <ennonagel+vim@gmail.com> " Eisuke Kawashima " Last Change: 2024 Sep 19 by Vim Project (compiler shellcheck) +" 2024 Dec 29 by Vim Project (improve setting shellcheck compiler) if exists("b:did_ftplugin") finish @@ -44,7 +45,11 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:undo_ftplugin ..= " | unlet! b:browsefilter" endif -if get(b:, "is_bash", 0) +let s:is_sh = get(b:, "is_sh", get(g:, "is_sh", 0)) +let s:is_bash = get(b:, "is_bash", get(g:, "is_bash", 0)) +let s:is_kornshell = get(b:, "is_kornshell", get(g:, "is_kornshell", 0)) + +if s:is_bash if exists(':terminal') == 2 command! -buffer -nargs=1 ShKeywordPrg silent exe ':term bash -c "help "<args>" 2>/dev/null || man "<args>""' else @@ -52,14 +57,21 @@ if get(b:, "is_bash", 0) endif setlocal keywordprg=:ShKeywordPrg let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer ShKeywordPrg" +endif +if (s:is_sh || s:is_bash || s:is_kornshell) && executable('shellcheck') if !exists('current_compiler') compiler shellcheck + let b:undo_ftplugin ..= ' | compiler make' + endif +elseif s:is_bash + if !exists('current_compiler') + compiler bash + let b:undo_ftplugin ..= ' | compiler make' endif - let b:undo_ftplugin .= ' | compiler make' endif let &cpo = s:save_cpo -unlet s:save_cpo +unlet s:save_cpo s:is_sh s:is_bash s:is_kornshell " vim: nowrap sw=2 sts=2 ts=8 noet: diff --git a/runtime/ftplugin/shaderslang.vim b/runtime/ftplugin/shaderslang.vim new file mode 100644 index 0000000000..f3d1ab8c1c --- /dev/null +++ b/runtime/ftplugin/shaderslang.vim @@ -0,0 +1,54 @@ +" Vim filetype plugin file +" Language: Slang +" Maintainer: Austin Shijo <epestr@proton.me> +" Last Change: 2025 Jan 05 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +" Using line continuation here. +let s:cpo_save = &cpo +set cpo-=C + +let b:undo_ftplugin = "setl fo< com< cms< inc<" + +" Set 'formatoptions' to break comment lines but not other lines, +" and insert the comment leader when hitting <CR> or using "o". +setlocal fo-=t fo+=croql + +" Set comment string (Slang uses C-style comments) +setlocal commentstring=//\ %s + +" Set 'comments' to format dashed lists in comments +setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,:// + +" When the matchit plugin is loaded, this makes the % command skip parens and +" braces in comments properly, and adds support for shader-specific keywords +if exists("loaded_matchit") + " Add common shader control structures + let b:match_words = '{\|^\s*\<\(if\|for\|while\|switch\|struct\|class\)\>:}\|^\s*\<break\>,' .. + \ '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>,' .. + \ '\[:\]' + let b:match_skip = 's:comment\|string\|character\|special' + let b:match_ignorecase = 0 + let b:undo_ftplugin ..= " | unlet! b:match_skip b:match_words b:match_ignorecase" +endif + +" Win32 and GTK can filter files in the browse dialog +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") + let b:browsefilter = "Slang Source Files (*.slang)\t*.slang\n" + if has("win32") + let b:browsefilter ..= "All Files (*.*)\t*\n" + else + let b:browsefilter ..= "All Files (*)\t*\n" + endif + let b:undo_ftplugin ..= " | unlet! b:browsefilter" +endif + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime/ftplugin/tiasm.vim b/runtime/ftplugin/tiasm.vim new file mode 100644 index 0000000000..13a3dc64f7 --- /dev/null +++ b/runtime/ftplugin/tiasm.vim @@ -0,0 +1,18 @@ +" Vim filetype plugin file +" Language: TI linear assembly language +" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu> +" Last Change: 2025 Jan 08 + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +setlocal comments=:; +setlocal commentstring=;\ %s + +let b:undo_ftplugin = "setl commentstring< comments<" + +if exists("loaded_matchit") + let b:match_words = '^\s\+\.if\>:^\s\+\.elseif:^\s\+\.else\>:^\s\+\.endif\>,^\s\+\.group:^\s\+\.gmember:^\s\+\.endgroup,^\s\+\.loop:^\s\+\.break:^\s\+\.endloop,^\s\+\.macro:^\s\+\.mexit:^\s\+\.endm,^\s\+\.asmfunc:^\s\+\.endasmfunc,^\s\+\.c\?struct:^\s\+\.endstruct,^\s\+\.c\?union:^\s\+\.endunion,^\s\+\.c\?proc:^\s\+\.return:^\s\+\.endproc' + let b:match_ignorecase = 1 + let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words" +endif diff --git a/runtime/ftplugin/typst.vim b/runtime/ftplugin/typst.vim index 3841e427f3..08929bbdbe 100644 --- a/runtime/ftplugin/typst.vim +++ b/runtime/ftplugin/typst.vim @@ -1,7 +1,8 @@ " Vim filetype plugin file " Language: Typst -" Maintainer: Gregory Anders -" Last Change: 2024 Oct 21 +" Previous Maintainer: Gregory Anders +" Maintainer: Luca Saccarola <github.e41mv@aleeas.com> +" Last Change: 2024 Dec 09 " Based on: https://github.com/kaarmu/typst.vim if exists('b:did_ftplugin') @@ -11,10 +12,14 @@ let b:did_ftplugin = 1 setlocal commentstring=//\ %s setlocal comments=s1:/*,mb:*,ex:*/,:// -setlocal formatoptions+=croq +setlocal formatoptions+=croqn +" Numbered Lists +setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* +" Unordered (-), Ordered (+) and definition (/) Lists +setlocal formatlistpat+=\\\|^\\s*[-+/\]\\s\\+ setlocal suffixesadd=.typ -let b:undo_ftplugin = 'setl cms< com< fo< sua<' +let b:undo_ftplugin = 'setl cms< com< fo< flp< sua<' if get(g:, 'typst_conceal', 0) setlocal conceallevel=2 diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim index b5e8e693f6..6ba057fc03 100644 --- a/runtime/ftplugin/vim.vim +++ b/runtime/ftplugin/vim.vim @@ -1,9 +1,9 @@ " Vim filetype plugin " Language: Vim " Maintainer: Doug Kearns <dougkearns@gmail.com> -" Last Change: 2024 Apr 13 -" 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring') +" Last Change: 2025 Jan 06 " Former Maintainer: Bram Moolenaar <Bram@vim.org> +" Contributors: Riley Bruins <ribru17@gmail.com> ('commentstring') " Only do this when not done yet for this buffer if exists("b:did_ftplugin") @@ -103,8 +103,8 @@ if exists("loaded_matchit") \ '\<try\>:\%(\%(^\||\)\s*\)\@<=\<cat\%[ch]\>:\%(\%(^\||\)\s*\)\@<=\<fina\%[lly]\>:\%(\%(^\||\)\s*\)\@<=\<endt\%[ry]\>,' .. \ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' .. \ '\<class\>:\<endclass\>,' .. - \ '\<inte\%[rface]\>:\<endinterface\>,' .. - \ '\<enu\%[m]\>:\<endenum\>,' + \ '\<interface\>:\<endinterface\>,' .. + \ '\<enum\>:\<endenum\>' " Ignore syntax region commands and settings, any 'en*' would clobber " if-endif. |