Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use concealed lrv- and love- prefixes; wrap <> for unknown #20

Merged
merged 2 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 16 additions & 2 deletions src/doc/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ local TOC_NAME_REF_SPACING = 2
local TOC_REF_WIDTH_LIMIT = PAGE_WIDTH - TOC_NAME_WIDTH_LIMIT - TOC_NAME_REF_SPACING

local LOVE_TYPES = {}

local LUA_TYPES = {
['boolean'] = '|lrv-boolean|',
['function'] = '|lrv-function|',
['nil'] = '|lrv-nil|',
['number'] = '|lrv-number|',
['string'] = '|lrv-string|',
['table'] = '|lrv-table|',
['thread'] = '|lrv-thread|',
['userdata'] = '|lrv-userdata|',
['light userdata'] = '|lrv-lightuserdata|',
}
-- }}}

-- Misc. functions {{{
Expand Down Expand Up @@ -58,9 +70,11 @@ end

local function formatAsType( str )
if LOVE_TYPES[str] then
return ('|%s|'):format( str )
return ('|love-%s|'):format( str )
elseif LUA_TYPES[str] then
return LUA_TYPES[str]
else
return ('|lrv-%s|'):format( str )
return ('<%s>'):format( str )
end
end

Expand Down
3 changes: 3 additions & 0 deletions src/syntax/gen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ REM Update after\syntax
rd /q /s ..\..\after\syntax
mkdir ..\..\after\syntax

REM Copy nongenerated help syntax
copy help.vim ..\..\after\syntax\.

REM Create syntax files
!lua! lua\main.lua > ..\..\after\syntax\lua.vim
!lua! love-conf\main.lua > ..\..\after\syntax\love-conf.vim
Expand Down
3 changes: 3 additions & 0 deletions src/syntax/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ cp -rf love-api lua
rm -rf ../../after/syntax
mkdir -p ../../after/syntax

# Copy nongenerated help syntax
cp help.vim ../../after/syntax/.

# Create syntax files
$lua lua/main.lua > ../../after/syntax/lua.vim
$lua love-conf/main.lua > ../../after/syntax/love-conf.vim
Expand Down
27 changes: 27 additions & 0 deletions src/syntax/help.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
" Help extensions for vim-love-docs
" This is based on luarefvim

" Only apply syntax changes to our help docs (which will actually contain
" these prefixes).
if -1 == stridx(resolve(expand('%:p')), resolve(expand("<sfile>:p:h:h:h") .'/doc/'))
finish
endif

syn clear helpHyperTextJump
" helpHyperTextJump copied from $VIMRUNTIME/ftplugin/help.vim
if has("ebcdic")
syn match helpHyperTextJump "\\\@<!|[^"*|]\+|" contains=helpBar,helpHideLrv,helpHideLove
else
syn match helpHyperTextJump "\\\@<!|[#-)!+-~]\+|" contains=helpBar,helpHideLrv,helpHideLove
endif

if has("conceal")
syn match helpHideLrv contained "\<lrv-" conceal
syn match helpHideLove contained "\<love-" conceal
else
syn match helpHideLrv contained "\<lrv-"
syn match helpHideLove contained "\<love-"
endif

hi def link helpHideLrv Ignore
hi def link helpHideLove Ignore