On Wed, Jan 6, 2016 at 9:59 AM, Nicola <nvitacolonna@gmail.com> wrote:
I have defined my own PostgreSQL dialect and I would like to use it with
.pgsql files by default. Currently, I have this in my ftdetect/pgsql.vim:
au BufNewFile,BufRead *.pgsql setfiletype sql | SQLSetType pgsql
The problem with this is that it first loads the default syntax files and
then the PostgreSQL variant.
Correct.
So, for example, the default syntax file
(sqloracle.vim) links sqlKeyword to sqlSpecial, while I would want to link
it to a different highlight group (and, of course, still let the user
override the plugin's choice).
That shouldn't happen.
The SQLSetType function does this:
function SQL_SetType(name)
" User has decided to override default SQL scripts and
" specify a vendor specific version
" (ie Oracle, Informix, SQL Anywhere, ...)
" So check for an remove any settings that prevent the
" scripts from being executed, and then source the
" appropriate Vim scripts.
if exists("b:did_ftplugin")
unlet b:did_ftplugin
endif
if exists("b:current_syntax")
" echomsg 'SQLSetType - clearing syntax'
syntax clear
if exists("b:current_syntax")
unlet b:current_syntax
endif
endif
If you execute:
:syntax list
You can see all the items setup.
:syntax clear
:syntax list
Shows they are all gone, which should include your sqlKeyword items.
Can you try the following.
Load a SQL file.
Then run this command:
:function SQL_SetType
You are looking for line #s here, find the line # for:
11 if exists("b:current_syntax")
Then you can execute:
:breakadd func 11 *SQL_SetType
Then run a command:
:SQLSetType pgsql
Breakpoint in "SQL_SetType" line 11
Entering Debug mode. Type "cont" to continue.
function SQL_SetType
line 11: if exists("b:current_syntax")
>n
function SQL_SetType
line 13: syntax clear
>n
function SQL_SetType
line 14: if exists("b:current_syntax")
>syn list
No Syntax items defined for this buffer
Keep hitting "n" for next.
Eventually you hit these lines:
35 let b:sql_type_override = new_sql_type
48 let &filetype = 'sql'
After that line:
line 50: if b:sql_compl_savefunc != ""
>syn list
--- Syntax items ---
sqlSpecial xxx all_encrypted_columns report_formats commit_logging dba_sscr_restore dbms_xdb user_part_col_statistics xml_db_events v$ges_convert_local dbms_outln_edit dba_streams_rename_column
dba_tsm_source parallel_execution_message_size dba_logstdby_not_unique v$logfile v$ges_blocking_enqueue user_cube_dimensionality dba_evaluation_context_tables nls_timestamp_tz_format
d
So you can step through and see where things are going wrong.
If you find an issue, please make sure you include :ver output.
And also make sure you do not have your own ftplugin/sql.vim and others that might get in the way.
Is there a way to have the dialect be loaded directly without requiring
the use to set g:sql_type_default?
Is pgsql not a good choice as a default for you?
HTH,
David
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment