LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 11-10-2012, 02:18 AM   #1
astanton
Member
 
Registered: Nov 2010
Distribution: Slackware64 -current
Posts: 82

Rep: Reputation: 5
Vim with Python support?


I wanted to be able to do quick pasties from vim so I installed codepad.vim to ~/.vim/plugin/

The docs at http://www.vim.org/scripts/script.php?script_id=2298 said, "This requires +python support in vim."

When I'm editing a file and I do a :CPP I get the following:

Code:
~                                                                                                                                            
E354: Invalid register name: '+'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 37, in codepadPaste
vim.error
Press ENTER or type command to continue
Does this indicate that I have Python support compiled into my (stock) version of vim as distributed w/Slackware?

If not, what are some of the preferred ways to add python support to vim?

There's a tool called AAp on the vim.org website, there's downloading and compiling from source, like the website recommends as the best method, and then there's the Slackware logical extension of that, getting the sources for the package from the Slackware repo and running the SlackBuild.

The vim.SlackBuild Here shows the following:

Code:
config_vim() {
CFLAGS="$SLKCFLAGS" \
./configure \
  $* \
  --prefix=/usr \
  --enable-pythoninterp \
  --with-python-config-dir=/usr/lib${LIBDIRSUFFIX}/python$PYVER/config \
  --enable-perlinterp \
  --disable-tclinterp \
  --enable-multibyte \
  --enable-cscope \
  --with-features=huge \
  --with-compiledby="<volkerdi@slackware.com>" \
  --build=$ARCH-slackware-linux

  # I had been adding this, but got 100% complaints and 0% kudos:
  #  --enable-rubyinterp
}
So to me it appears that Python support is compiled in (I suppose I should recompile anyway to add the Ruby support too).

So what might I look at next? Basically, I'm just wanting to paste directly to a pastebin quickly from within vim.

Thanks.
 
Old 11-10-2012, 06:15 AM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,974

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
You can check vim's compile-options with
Code:
vim --version
in this case
Code:
vim --version | grep pyt
it seems that vim is compiled with python-support.

Markus
 
Old 11-10-2012, 08:36 AM   #3
astanton
Member
 
Registered: Nov 2010
Distribution: Slackware64 -current
Posts: 82

Original Poster
Rep: Reputation: 5
Yes it seems Python support is compiled in. I went ahead and re-compiled enabling Ruby, which is something I figured I would like to have, but I'm still wondering how to handle the error below:

Quote:
Originally Posted by astanton View Post

When I'm editing a file and I do a :CPP I get the following:

Code:
~                                                                                                                                            
E354: Invalid register name: '+'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<string>", line 37, in codepadPaste
vim.error
Press ENTER or type command to continue
Any ideas as to how I can address this issue, and what to do next?

Last edited by astanton; 11-10-2012 at 08:38 AM.
 
Old 11-10-2012, 11:42 AM   #4
audriusk
Member
 
Registered: Mar 2011
Location: Klaipėda, Lithuania
Distribution: Slackware
Posts: 248

Rep: Reputation: 107Reputation: 107
I checked the source of this plugin and the error is happening in line 67:
Code:
  vim.command("call setreg('+', '%s')" % url)
  vim.command("call setreg('*', '%s')" % url)
The plugin is trying to set "+ and "* registers which are called selection registers in Vim and represent selection ("*) and clipboard ("+) in X11. In other words, it copies the value of url variable into the clipboard for your convenience.

This works for me in GVim, but doesn't work in console Vim. According to Vim help, "for Unix systems the clipboard is only available when the +xterm_clipboard feature is present", which isn't in my case (:echo has('xterm_clipboard') returns 0). I build Vim myself, but my guess is that the same applies to Slackware's Vim as well.
 
Old 11-10-2012, 12:26 PM   #5
astanton
Member
 
Registered: Nov 2010
Distribution: Slackware64 -current
Posts: 82

Original Poster
Rep: Reputation: 5
Thumbs up

Quote:
Originally Posted by audriusk View Post
This works for me in GVim, but doesn't work in console Vim. According to Vim help, "for Unix systems the clipboard is only available when the +xterm_clipboard feature is present", which isn't in my case (:echo has('xterm_clipboard') returns 0). I build Vim myself, but my guess is that the same applies to Slackware's Vim as well.
Okay that explains it then. It's not satisfactory but it is the answer.

on my system :echo has('xterm_clipboard') returns a 0 in vim and a 1 in gvim. This really doesn't do all that much from me though. I tested pasting via :CPP with the plugin and it worked fine in gvim - but that's not an app I actually use. Typically, I'll use geany or bluefish or kate when I want a gui, and yet I know that I can just launch gvim, I tend to always have a terminal open and invoke the regular console vim there and use it almost exclusively for most things.

Well I'll look around to see if there's any pastie plugins that will work w/regular vim, and thanks so much for your help in determining what the problem was

I'll mark this solved now but if anyone has any suggestions for something that works for a pastebin from console vim I'd appreciate hearing about it.
 
Old 11-10-2012, 01:33 PM   #6
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,298

Rep: Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722
I haven't tested it, but couldn't you just get rid of the two instances of
Code:
vim.command("call setreg('+', '%s')" % url)
vim.command("call setreg('*', '%s')" % url
in the .vim file? You wouldn't get the URL copied into the system buffer but the webbrowser.open(url) line should open the page up in your browser anyway, so you could get the URL from there. Alternatively, you could rebuild vim. Note this line in the SlackBuild:
Code:
config_vim --without-x --disable-gui
You would have to remove --without-x (and possibly change it to --with-x if it isn't the default). Not sure about --disable-gui and I won't bother downloading the source to check just now.
 
Old 11-10-2012, 01:44 PM   #7
astanton
Member
 
Registered: Nov 2010
Distribution: Slackware64 -current
Posts: 82

Original Poster
Rep: Reputation: 5
Exclamation

Yes!

Here's mention of that in the Vim wiki: http://vim.wikia.com/wiki/Script:2298

Essentially, There's three lines in each function to be commented out and then it works in both vim and gvim

I commented out those three lines and the only gripe I have now is that there's no syntax highlighting for shell scripts, but that's a minor issue. I'm able to quickly post text to a pastebin and like you suggested I can just copy the URL from the browser to paste in an IRC channel or share it some other way.

I haven't tried with commenting just the two lines you suggest and don't know what more that would get me. It works now and I'm pretty happy.
 
Old 11-10-2012, 03:47 PM   #8
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,298

Rep: Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722Reputation: 722
Quote:
Originally Posted by astanton View Post
I haven't tried with commenting just the two lines you suggest and don't know what more that would get me. It works now and I'm pretty happy.
Commenting the three lines is more appropriate -- 'import vim' imports vim bindings in python to set the registers, but since they aren't being used anyway importing vim is superfluous. It would work identically either way but importing vim would waste RAM and isn't necessary so what you've done is the best method.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vim intelligent python completion tadeas Programming 6 01-02-2012 02:41 PM
vim no GUI support seeone Linux - Software 7 02-23-2010 12:09 AM
LXer: Turning on Unicode Support in Vim LXer Syndicated Linux News 0 06-22-2009 08:12 PM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 05:26 PM
Make Vim highlight floats and ints in Python files? Shay Linux - Software 1 10-25-2007 10:31 AM


All times are GMT -5. The time now is 11:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration