ameyp / cscopesublime Goto Github PK
View Code? Open in Web Editor NEWA Cscope plugin for Sublime Text 2 and 3
A Cscope plugin for Sublime Text 2 and 3
From the tail end discussion of issue #56, I think there's some cleanup needed around the cscope database generating and rebuilding.
CscopeSublime didn't use to ever let you rebuild or build for the first time a cscope database. This was a recent addition I made. We've not been getting a lot of requests for this ability, so I'm not really inclined to sink a lot of time into expanding this functionality. But I do think we could do database rebuild or first-time-build better, so I'll open another issue to track this.
cscope's database building is complicated and non-trivial. The easy way to do this is to have a single source directory and run "cscope -R" on that directory to produce a cscope.out database file at the top level of that directory. But you can do a lot of variations on this approach. You can keep the database file in a different directory entirely by creating a cscope.files file that contains all the filenames you want cscope to index. You have complete control over what files end up in the cscope.files list too, so if you have a huge code base and only want to index the C or C++ files and not Java, Python, Perl, or whatever else, you can do this. But there's no simple way to do this in a way that will work for everybody. Personally, I have a shell script called cscope-indexer that came from an old Linux distro and probably https://github.com/To1ne/xcscope/blob/master/cscope-indexer originally that I use to build and rebuild my cscope database. Other people will have a variety of commands they use to build their cscope index, such as found here: https://stackoverflow.com/questions/11718272/build-cscope-out-files-in-a-separate-directory . I don't see an easy, elegant, and easy-to-maintain way to provide a solution that would work for everyone for this. So I think I'm going to intentionally try to limit the database building/rebuilding functionality that this plugin provides. If there's an existing cscope.out file that we can find, I believe there's a trivial command that we can do to rebuild it. If there's not an existing cscope.out file, but we know where it should go (i.e. a project that only has one path folder defined), we can continue to do what we're doing today and build it the first time. But I don't think I want to put more work into this than that. I'm certainly open to code contributions and pull requests if this functionality is wanted, but I just haven't seen any demand/request for it yet to justify the work.
But I would like to at least separate the "first time build" and "rebuild" logic for the cscope database because I believe these should actually be different arguments passed to cscope.
i like this plugin,
but i found in search result window,
if the file that contains the search symbol have not been opened in sublime,
the GoTo definition menu is invisible.
can not jump to the file .
how to let it can open and jump to this file automatically ?
Thanks a lot~
Tried to use this in ST3 and it doesn't appear to work. (may track issues down later when I have time)
The new goto_definition and goto_symbol_in_project commands don't seem to work very well for some cases (like struct tags etc)
I would like the search result buffers that are opened to act like the built in "find" search results, where you can click around the file and not jump to that selection until you double click.
I see it working like this let me know what you think.
right now if you move the cursor it will jump as soon as it hits a line it can decipher as a file name. This is due to the fact that the event it waits on is the selection changed I'm not well versed in the Sublime API but we should change that for a different event or at least add some thing there to not always evaluate until the users wants it to.
I will look into it more but if anyone has any ideas they will be much appreciated.
Hi,
Whenever I look up something, a new Cscope results output file is opened along with all the other files from previous searches.
Thanks
Thanks a lot for developing this handy tool.
(Maybe I missed something, but..) I'm wondering if it is possible to display the Cscope results on the other column in the 2-column layout. Currently, I always manually drag the Cscope results to the right column if the looked up variable is on the left column.
Thanks in advance. : )
I tried doing a CscopeSublime search and it didn't work. I added some debugging and I see this in the console:
add_to_history
[] []
Doing update database.
database setting found
Traceback (most recent call last):
File "./sublime_plugin.py", line 356, in run_
File "./cscope.py", line 207, in run
File "./cscope.py", line 262, in run_cscope
File "./cscope.py", line 180, in update_database
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/posixpath.py", line 119, in dirname
i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
The problem, IIUC, is that by not providing arguments to get_setting(), the default of None is used and then None is compared to an empty string. I've fixed this by providing an empty string default value. Pull request forthcoming.
It would be nice if you could run Cscope commands when looking at the output pane of the previous command you ran. I tried to do this and got confused because it fails silently with no error message.
In the Cscope output window, press Ctrl-, select Lookup Symbol (or any other command) and press enter. Nothing happens, but the console shows this message:
Traceback (most recent call last):
File "./sublime_plugin.py", line 356, in run_
File "./cscope.py", line 364, in run
File "./cscope.py", line 315, in update_database
File ".\posixpath.py", line 119, in dirname
AttributeError: 'NoneType' object has no attribute 'rfind'
I am using Sublime 2.0.2, build 2221 on Ubuntu 12.04.2 LTS.
I have problem using any find features in the plugin.
I have copied the win version of cscope to the windows directory. I have also used the -R argument to generate the database in the code base.
Hi, every one,
I got this error on Sublime Text 3,
Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 812, in run_
return self.run(edit, **args)
File "/home/wittmann/.config/sublime-text-3/Packages/CscopeSublime/cscope.py", line 467, in run
self.database.update_location(self.view.file_name())
File "/home/wittmann/.config/sublime-text-3/Packages/CscopeSublime/cscope.py", line 60, in update_location
project_info_paths = [folder['path'] for folder in project_info['folders']]
TypeError: 'NoneType' object is not subscriptable
Thank you,
Dmytrii
Instead of performing Cscope queries in the main thread (thereby causing the editor to freeze while cscope is returning the results), display a status message and run cscope in a separate thread, returning the results to the editor when that thread finishes.
Hi,
first of all thank you very much for this nice plugin.
Is it possible to add all the results into the history list and navigate through the list via ctrl+shift+[ ?
the current implementation won't clear the list when querying new symbols, and I can't afford manually hitting enter on every result.
btw, is it possible to update cscope_out automatically?
Thanks for your works on is useful plugin.
The Function Rebuild database works fine in windows 7 x64, but when I trys it in Windows 10 x64, cscope.out does't create.
I have installed the cscope sublime plugin on Linux for Sublime Text 2. It doesn't show any results on UI even when the console says 'cscope database' found.
Here's the console output:
('CscopeDatabase: Database found: ', u'/Users/.../.../cscope.out') add_to_history ([u'/home/.../.../myCat.c:526', u'/home/.../.../myLock0.h:247', u'/home/.../.../myLock0.h:278', u'/home/.../.../myCat.c:529', u'/home/.../.../myCat.c:526', u'/home/.../.../myLock0.h:294', u'/home/.../.../myLock.c:90'], [])
-- I have abbreviated the file paths/ file names/ macro names etc above.
Any help is appreciated. :-)
@ameyp I think I can't make this change because you own the repository. =:)
Thanks!
In comparing the results buffer for CscopeSublime to the Emacs/Cscope results buffer, I think the Emacs/Cscope results buffer is a little easier to read. Here's what it looks like:
Specifically, the Emacs buffer has:
A line at the top of the buffer that gives the user context. In this example, the search type was a "global definition" and the search criteria was "schedule".
An ASCII line separator ("-------"), separating the search criteria from the results. This helps to break up the results page a little and gives a clean separation, I feel.
The file that contains the search result is listed on its own line and is colored differently from the actual result text. All lines that match the search criteria appear on their own lines that list the line number as well as the actual matching text. If there are multiple matches in a single file, the file is listed once with the results listed individually below the file. I feel that this separation makes it a little easier to focus on the result text since the lines aren't as busy and the thing that you're looking for (the result text) is more to the left of the buffer since it's not being pushed to the right by the filename being on the same page.
I would like to help make these changes. Would you be open to them? And if you have any pointers on where I should start making changes, that would be greatly appreciated too, since I'm new to python, SublimeText, and ST plugins. =:)
Thanks again!!
Looks like something is missing for cscope
In folder /home/{username}/volume/db
Being able to search scope is really nice, but when the results menu pops up I can't click through to the file it found.
I once had CscopeSublimeSearchWorker has no attribute "output" so I used Package Resource Viewer to add self.output = "" for Worker class.
It now does not provide any error for such, but I still get only empty file opened when I type commands for cscope.
And here is the new(or existed but ignored because of above error) error that I get when I launch cscope.
Traceback (most recent call last):
File "./python3.3/threading.py", line 901, in _bootstrap_inner
File "/Users/LazyRen/Library/Application Support/Sublime Text 3/Packages/Cscope/cscope.py", line 397, in run
matches = self.run_cscope(self.mode, self.symbol)
File "/Users/LazyRen/Library/Application Support/Sublime Text 3/Packages/Cscope/cscope.py", line 377, in run_cscope
output, erroroutput = proc.communicate()
File "./python3.3/subprocess.py", line 920, in communicate
File "./python3.3/subprocess.py", line 1577, in _communicate
File "./python3.3/subprocess.py", line 848, in _translate_newlines
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 67: ordinal not in range(128)
Hi:
I use sublime text3 and try to create cscope.out, but I don't know how,
my environment is Windows 10, and I have download cscope.exe
Thanks
I installed this plugin through Packet Control, after install finished,I find that nothing exited in the packet dir ,but I can find Cscope.sublime-package in /Users/chenji/Library/Application Support/Sublime Text 3/Installed Packages/Cscope.sublime-package,
It guess something wrong happens but no hit pop out.
In Windows, cscope is downloaded as a standalone executable. User can place it any of his convenient location. It would be better if we can configure the path for it in cscope rather than updating the PATH variable.
It's a very cool tool, thanks for sharing it.
For example, when I use seaching cscope for functions of calling this function, I'd like the search result support to jump to destinations like Sublime Text 3's own seach in files result, you can double click the line number to jump to the destination in the result page.
Sorry for my poor English expression and expect you can improve the plugin, thanks!
Hi!
I just installed CScope on Mac OSX 10.10 and tried to use this plugin in ST2, but it's not working in the current state. When running any commands (Cmd + \ and enter, Cmd + L/Cmd + S, ...), the console is outputting
Traceback (most recent call last):
File "./sublime_plugin.py", line 356, in run_
File "./cscope.py", line 424, in run
File "./cscope.py", line 57, in update_location
AttributeError: 'Window' object has no attribute 'project_data'
From what I gathered from a quick Google search, project_data is only available in ST3. I could fix the issue by adding a line that checks if project_data in an attribute of window() on line 57 of cscope.py:
if hasattr(self.view.window(), 'project_data'):
project_info = self.view.window().project_data()
I didn't try on ST3, so I don't know how it behaves there. I would assume that it sill works though!
Cheers!
error: Error loading syntax file "Packages/CscopeSublime/Lookup Results.hidden-tmLanguage": Error parsing plist xml: Failed to open file In file "Packages/CscopeSublime/Lookup Results.hidden-tmLanguage"
Happens when the plugin opens a tab for it's results.
I'm coming from Emacs to Sublime Text and I'll just say that if this Cscope plugin didn't exist for Sublime Text 2, I would not be using ST2. So THANK YOU very much Amey! =:)
But there's a couple of things that I really like in the Emacs/Cscope integration that aren't there (yet =;)) in CscopeSublime that I'd like to help add.
This first issue is around the user interaction before the Cscope database is searched. In Emacs, the user is allowed to confirm or change the symbol that is being looked up before the database is searched. I use this all the time in Emacs to lookup a symbol that I'm looking for even though I don't know where it is in the source code. For example, I'm doing code review for a colleague and they use the constant FOO_BAR_BAZ. In Emacs, I can open any source file, start a Cscope symbol search for whatever my cursor happens to be on, and when Emacs prompts me for the symbol to lookup, I can change it to FOO_BAR_BAZ.
The Ctags Sublime plugin works kind of the same way in that it pops up an editable menu/list at the top of the window that the user can use to type in and narrow his search results down. I think it would be really nice to provide this same kind of functionality to CscopeSublime.
What do you think?
And I'm more than willing to dive in and add the code to do this, but I wanted to check with you first to see if you'd be open to it.
Thanks very much!!
It seams that it can only use one database_location, but It is really not convinient when develop many project on the same time.
I get this whenever I try to look something up:
Traceback (most recent call last):
File ".\cscope.py", line 334, in
File ".\cscope.py", line 341, in update_status
AttributeError: 'CscopeSublimeWorker' object has no attribute 'output'
The keybindings mentioned in the README file appear to apply only to Windows. @vanrijn Is it ok if I make them the default keybindings (with super instead of ctrl on OSX) on all platforms?
I installed this plugin recently and I'm really thankful that it is actively maintained.
Now after installing the plugin, two of my frequently used keybindings failed because of the following conflicts:
[shift+super+[]
prev_view Default
goback Cscope
[shift+super+]]
next_view Default
forward Cscope
Could we please ensure that there're no conflicts with at least Sublime Text 3's default key bindings? I can open a pull request if we decide on non-conflicting key bindings.
I have no clue how to implement this but I really like the fuzzy finding of files in sublime text [ctrl+p] and if we could somehow create a fuzzy search for symbols without totally destroying responsiveness we should try what's the worst that could happen.
the problem is that sublime text 2 has a list of all files in a project ready to be processed where CscopeSublime has to query the Cscope database to get it's dataset to process. if there was a way to get the list of every symbol in the database and perform a fuzzy search algorithm on that fixed set we should be able to make something work.
then create a function that the users begins to typing in what they think the symbol is and CscopeSublime pop's up options to querty the Cscope Database with. Not a high priority but would certainly make the plug-in stand out. this could be a great addition to #8
Would be more handy if we could refresh Cscope's DB from within Sublime.
It would be great if instead of building the cscope file it would be build from save event of files.
Hi,
I am tying to configure sublime for linux kernel development and found this plugin.
Unfortunately it looks like the plugin is broken and I cannot use it at all (not searches). Reading the documentation it looks like it misses a lot of features such as navigate with mouse click, navigate back... I wish sublimecscope was more feature compatible with sublimectags https://github.com/SublimeText/CTags
in mac os 10.12.3 , sublime 3126, /usr/local/bin/cscope: version 15.8b
rebuild database:
Cscope ERROR: cscope binary "/usr/local/bin/" not found!
When in VI command mode, pressing enter on a result line doesn't navigate to the location of the result. It's not a big issue to go into insert mode, but it took me awhile to figure this out. Maybe this can be explicitly stated somewhere?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.