Skip to content
Open
Changes from 2 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
39 changes: 38 additions & 1 deletion sc/SCVim.sc
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,30 @@
SCVim.generateTagsFile();
*/

Document {
Comment thread
grirgz marked this conversation as resolved.
// needed for thisProcess.nowExecutingPath to work.. see Kernel::interpretCmdLine
var <path, <dataptr;
*new {|path, dataptr|
^super.newCopyArgs(path, dataptr);
}
*current {
var path = SCVim.currentPath;
^Document(path, true);
}
*dir {
^SCVim.currentPath
}
}


SCVim {
classvar nodes, <>vimPath;
classvar nodes, <>vimPath, <>vimServerEnabled=false, <>vimServerName="SCVIM";

*initClass {
nodes = List[];

// TODO this has to be not so mac-centric
vimPath = "vim";
Platform.case(\osx) {

var whichVim = "which mvim".unixCmdGetStdOut;
Expand All @@ -41,6 +58,10 @@ SCVim {
vimPath = vimPath.replace("\n", "");
};

vimServerEnabled = "% --version".format(vimPath).unixCmdGetStdOut.contains("+clientserver") and: {
"% --serverlist".format(vimPath).unixCmdGetStdOut.contains(vimServerName.toUpper)
};

Comment thread
grirgz marked this conversation as resolved.
StartUp.add {
var classList, file, hugeString = "syn keyword scObject", basePath;
// search two folders deep below ~/.vim for a folder named "*scvim*"
Expand Down Expand Up @@ -221,4 +242,20 @@ SCVim {
tagfile.close();
"finished generating tagsfile".postln;
}

*currentPath {
var cmd = "expand(\"%:p\")";
var path;
if(vimServerEnabled) {
path = "% --servername % --remote-expr '%'".format(vimPath, vimServerName, cmd).unixCmdGetStdOut;
if( path == "" ) {
//"can't get Vim current path".error; // also happen on unsaved files, but there is already an error message with .loadRelative
^nil
};
if (PathName(path).isAbsolutePath) {
^path;
};
}
^nil;
}
} // end class