Sublime, altering behavior of highlighting definions upon mouse-hover - sublimetext3

I have a project with several classes which partly share functions while at other times the functions are different in code, but use the same name.
When hovering over a function name, Sublime highlights every file and line where that definition is found.
In my opinion it would be better if it actually included which class the different highlights belong to.
Is it possible to edit this in some way ?
Assume systems.js contains 4 different classes (1 base, 3 children). I would like to append or prepend the shown strings by the class definition (fetchable via prototype).

The hover popup mentioned in your question is powered by Sublime's internal symbol index, which is created in combination with the syntax definition that's used to syntax highlight files that you're editing. The Sublime syntax system is fairly context free; it parses the structure of the code but it doesn't contain any real structural information about it.
So for example it can determine that getShots is a function or method because of the syntax that was used to define it, but it doesn't know what class it came from.
The code for the hover popup is available in Default/symbol.py (you can use PackageResourceViewer to examine it) and associates symbols under the cursor with other places that it's seen symbols with that name in other files in the project; it literally only knows the information that you see in the popup; places where things by that name are defined and places where things of that name are referenced.
So in one sense, the answer to your question is No; core sublime can't do that because it doesn't have enough code intelligence to be able to figure that sort of thing out; this is exacerbated by dynamic languages like JavaScript where things can theoretically change at runtime as well.
The primary reason for that is because Sublime is extensible enough to support literally every programming language instead of just focusing on one or two (as e.g. PhpStorm does), so it doesn't have the core code to determine the information required.
All that said, since Sublime is indeed extremely extensible, it's possible that external code that does specialize on a language could be leveraged by a package in order to provide the appropriate information.
Two examples of that are SublimeCodeIntel and LSP for example. I don't use either of them myself, so I don't know for sure how good a fit they might be in your workflow.

I highly recommend you shift to Visual Studio Code majorly because sublime is an editor whereas vs code is an IDE. Also, it has very great extension support for all languages. I would recommend you to use jshint which the most popular plugin for js code available for almost all popular editors and IDEs. But still if you want to go with Sublime I suggest you following plugins:
https://www.sitepoint.com/essential-sublime-text-javascript-plugins/

Related

How to enable code folding features on plaintext files on JetBrains IDE?

It seems as if the brackets are recognized based on location and even highlighted, but I'm not allowed to fold those areas. This seems like such a simple thing to do since it could reuse code from other parts of the editor and is half-implemented already. I think it might exist in some form, even as a plugin.

C++ Cross Ref for VIM similar to Source Insight

I wanted a cross reference navigation similar to Source Insight.
Lets take simple example:
classA::MethodB()
{
...
m_variable = value;
}
In this example if I use Ctags / Cscope, then when I try to find m_variable, it will show me all the available m_variable. I need to go through each and then find which one is required.
Where as in Source Insight, it clearly gives me the Class delectation.
Is there any such Cross ref tools available for Vim?
Vim is not an IDE, it's a text editor.
You can't reasonably expect it to understand your code as well or as deeply as an IDE.
IDEs typically keep a dynamic internal representation of your code which makes them able to track declaration and usage even when you have dozens of methods or variables with the same name. Vim, like most text editors, is not able to do that on its own: it must rely on external tools for indexing/navigating through your code. Now, because of architectural constraints, Vim is incapable of running any background process which is the absolute prerequisite for a real "code intelligence" to be added to Vim.
Given all that, you are left with code indexers like ctags, cscope or GLOBAL. These tools do their best trying to give you accurate results but they are not as smart and as specific as the tools used in IDEs.
To compensate, Vim has a bunch of different commands like :tselect or g] which open a list of possible tags to chose from. Read :h tags, :h ctags and :h cscope for how to deal with those limitations.
I've not tried this myself. But sounds like eclim is what you're looking for. http://eclim.org/
It provides eclipse features to be accessible from Vim, including code searching and auto-completion.

Vim context highlighting

I think standard highlighting is useful -- to some extent. When programming with callbacks and nested structures, this does not help. Keywords and strings, they appear everywhere, and it helps when they are shown in a distinct color, but these colors gives no clue about in which scope I am, where I am in a lexical standpoint.
I have heard of context highlighting, in a talk of Douglas Crockford, which I can't remember a url to. The idea is, to highlight lexical levels of scope. Toplevel definitions are colored in color0, inner level block statements are colored in color1, and this repeats recursively every time a new level of scope is introduced. Below is an example for this, using some imaginary node libraries. (Now added a (ish (or scheme lisp)) example)
This is not necessarily for node or javascript. I wonder if there is an editor/vim plugin implementing this kind of feature. I don't know if context highlighting is the word for this, but I can't just find one. Googling for context highlighting brings up results for generic token based highlighting and ConTeXt (which I don't have a clue about).
Does this exists? Is there an editor implements this? And more importantly, can I have this in vim?
Another question which is identical to mine, with no real answer: Is Crockford style Context Coloring implemented in any code editor?
I also couldn't find anything similar, so I wrote one:
rainbow_levels.vim: A different approach to code highlighting.
Of course it is a very simplistic implementation, only considering indentation levels instead of real context, but it gets the job done ;D
Not exactly what you are requesting, but code folding is a powerful feature to let you focus on specific levels of your code. Vim supports folding http://vim.wikia.com/wiki/Folding
Indention guides are very handy also, for focusing in on specific parts of code. The sublime text editor has this (http://sublimetext.userecho.com/topic/98136-indent-guide-highlighting-changed/)
I saw this plugin for vim (https://github.com/nathanaelkane/vim-indent-guides) that appears to do the same thing.
You could possibly create a syntax highlighter that uses the indentation logic of this plugin to change the color scheme. What you describe is more involved where it needs to work not just off the indention, but like a language parser.
There is now a plugin for this in VIM called vim-js-context-coloring. I've only just played with it a little and am not super impressed yet, but it looks promising!
Note: you need to install npm and then run npm install in the directory where the plugin is installed. I regretfully, forgot to read the instructions when I installed it.

Using Sublime 2 for Haskell Development?

What is the current status of Sublime 2 integration for Haskell? I see two possible packages so far. A plugin for code highlighting and a REPL plugin.
Is there an intelli-sense plugin for Haskell?
Maybe integration with Hackage as well?
Thanks.
SublimeHaskell plugin is the modern choice for Haskell development with SublimeText. It is well maintained and has plenty of useful features.
Other quite useful plugins:
Shell Turtlestein, which allows you to quickly type in shell commands under a single keystroke from inside the editor.
SublimeREPL, which allows you to run GHCi from inside the editor. Though without support for cabal repl yet.
SideBarEnhancements, which I primarily use to rename/move files without touching the mouse. With it you can hit Ctrl/Cmd + P and type "rename" or "move" to enter the dialogue.
I use Sublime exclusively at the moment and while it's not all that special out of the box, installing sublime-text-haskell as Cubic suggested makes it a little better (it will compile and highlight errors when you save a file and apparently enhances the auto-completion).
I've experimented with writing my own plugins but the reality is that a lot of really cool possibilities are made difficult to implement because the API is actually kind of restricting (there's no way to add extra information like type signatures to auto-complete options for example).
It seems that the dev(s) are working on adding some requested API features, but until then, sublime-text-haskell is probably the best Haskell plugin.

VIM: More precise C/C++ code parsing solutions?

Pre:
I've been working in VIM for like a year already. Lots of great things: combinations, scripts. Whenever I'm editing something in a different editor, I feel sluggish/uncomfortable without VIM's navigation.
The problem:
The thing that really bothers me most of all is source code navigation using existing tools (ctags, cscope). Often, ctags can't find the declaration of a variable, cscope as opposed to ctags finds all definitions with the same variable name. Same craziness with call tree navigation, finding forward declarations along with a single class definition etc.
Compared to MS Intellisense, Visual Assist or even source code navigation in Eclipse, Exuberant Tags/cscope seems to be deprecated for at least 10 years.
I know there are tools like ViEMU, but they don't really solve the problem, since you lose lots of VIM's functionality.
The question:
I was wondering if there is a tool that does the source parsing better, or there is some way to integrate source parsing engines like Intellisense into VIM ?
Maybe there are commercial solutions or there are people who are ready to implement one ?
All the benefits of VIM seem to save less time than is being wasted while navigating to class definition, compared to Visual Assist, where it's done by a single Alt-G shortcut.
Search and Call tree
You could try eclim, which is a way to use some Eclipse features in Vim.
For C/C++, it provides :
Context sensitive completion (although it is disabled on Windows because it is buggy)
Context sensitive search in Project files (through :CSearchContext)
Call tree for functions/methods (:CCallHierarchy)
Code Validation (:Validate)
It is not great, but it can help in some cases.
Code Completion
Regarding automatic code completion, I primarily use OmniCppComplete, which is using tags to provide Context aware code completion. It is not that bad.
As advised by Luc Hermitte, you can also use clang_complete which does not need ctags, but needs clang installed.
Unfortunatelly, it is a real problem. ctags or cscope can hardly compete with Visual Studio code browsing - it actually uses a C++ compiler front-end to parse the code for the editor.

Resources