Thursday, February 20, 2014

Re: trouble using python code with sql code

On Wed, Feb 19, 2014 at 8:53 AM, A Loumiotis
<antonis.loumiotis@gmail.com> wrote:
> On Tue, Feb 18, 2014 at 7:10 PM, David Fishburn <dfishburn.vim@gmail.com> wrote:
>>
>> On Mon, Feb 17, 2014 at 6:45 AM, A Loumiotis <antonis.loumiotis@gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> Omni sql completion does not seem to work with python filetypes. The
>>> example provided in section 4.6 of the helpfile ft_sql.txt works, ie
>>> omni sql completion works within a perl file. If I repeat this
>>> example editing a python file instead:
>>>
>>> :e test.py
>>> :set filetype=sql
>>> :set ft=python
>>>
>>> omni sql completion does not work within a python file. Is this a bug
>>> or am I doing something wrong?
>>>
>>> I use VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 10 2013 14:38:33)
>>> MS-Windows 32-bit GUI version with OLE support.
>>>
>>>
>> That is really interesting, I am seeing the same thing.
>>
>> :e dave.pl
>> :set ft=sql
>> :set ft=perl
>> :imap <buffer>
>>
>>
>> i <C-C>R *@<C-\><C-O>:call sqlcomplete#Map("resetCache")<CR><C-X><C-O>
>> i <C-C>L *@<C-Y><C-\><C-O>:call
>> sqlcomplete#Map("column_csv")<CR><C-X><C-O>
>> i <C-C>l *@<C-\><C-O>:call sqlcomplete#Map("column_csv")<CR><C-X><C-O>
>> i <C-C>c *@<C-\><C-O>:call sqlcomplete#Map("column")<CR><C-X><C-O>
>> i <C-C>v *@<C-\><C-O>:call sqlcomplete#Map("view")<CR><C-X><C-O>
>> i <C-C>p *@<C-\><C-O>:call sqlcomplete#Map("procedure")<CR><C-X><C-O>
>> i <C-C>t *@<C-\><C-O>:call sqlcomplete#Map("table")<CR><C-X><C-O>
>> i <C-C>s *@<C-\><C-O>:call
>> sqlcomplete#Map("sqlStatement\\w*")<CR><C-X><C-O>
>> i <C-C>T *@<C-\><C-O>:call
>> sqlcomplete#Map("sqlType\\w*")<CR><C-X><C-O>
>> i <C-C>o *@<C-\><C-O>:call
>> sqlcomplete#Map("sqlOption\\w*")<CR><C-X><C-O>
>> i <C-C>f *@<C-\><C-O>:call
>> sqlcomplete#Map("sqlFunction\\w*")<CR><C-X><C-O>
>> i <C-C>k *@<C-\><C-O>:call
>> sqlcomplete#Map("sqlKeyword\\w*")<CR><C-X><C-O>
>> i <C-C>a *@<C-\><C-O>:call sqlcomplete#Map("syntax")<CR><C-X><C-O>
>>
>>
>> :e dave.py
>> :set ft=sql
>>
>> :imap <buffer>
>>
>> This should have created all the above imaps, just as it did with Perl.
>>
>> I see why it didn't.
>> At the top of ftplugin/sql.vim there is the "usual" code:
>>
>> if exists("b:did_ftplugin")
>> finish
>> endif
>>
>>
>> Python is defining b:did_ftplugin, so it is not sourcing this file.
>> I guess Perl doesn't.
>>
>> I will update the ftplugin/sql.vim to perform a different test.
>>
>> In the meantime, you can do the following to work around the issue:
>>
>> :e dave.py
>> :unlet b:did_ftplugin
>> :set ft=sql
>> :unlet b:did_ftplugin
>> :set ft=python
>>
>> And completion will be enabled.
>>
>> 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/groups/opt_out.
>
> Thanks David for your help. Your ftplugin has been very useful! I
> thought the issue was related to MS-Windows and perhaps it had to do
> something with the crash of Vim whenever I use the :python command
> that I reported but it was not (could anyone with a Windows machine
> confirm this crash please?). Your workaround works great!

Regarding the Vim crash that I reported it seems that I found what
caused it and how to fix it. I describe this and another problem that
I face now in the following post in the vim_dev group:
https://groups.google.com/forum/?hl=en#!topic/vim_dev/ynYRvTmgKS8

Best,
Antonis

--
--
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/groups/opt_out.

No comments:

Post a Comment