Comments (10)
As a user, I want an experience where I install the package and it just works without needing a bunch of configuration
True, but LSP needs some setup anyway because you need to install the servers for it to work. Also, I want it to just-work™, but I don't want to lose configurability and I don't want packages that hijack or take away the default behavior. If a package has something that's better than the default I would expect most users won't mind copy-pasting something from a readme to get it.
Providing out of the box functionality in a plugin for an fully customizable editor is super tricky. At Atom they quickly ran into a situation where more packages offered key bindings than there are keys (* modifiers) on the keyboard. Instead of configuring how you want your editor to work, you'd have to spend time undoing whatever package devs thought would be a good ootb experience. Better to provide the features, some copy-pastable config stuff to enable the shortcuts, and don't assume too much about the environment your package is going to be inserted into.
If I can get the enhanced goto definition for the scopes I have configured for LSP by editing key bindings, I'd say that looks better from a package maintenance point of view, makes the behavior predictable, and also empowers me to tweak it to my preferences.
Edit: this setup works excellently for me:
{ "keys": ["super+alt+down"], "command": "goto_definition" },
{
"keys": ["super+alt+down"],
"command": "lsp_symbol_definition",
"context": [
{
"key": "selector",
"operator": "equal",
"operand": "source.ts, source.js"
}
]
}
from lsp.
@chenglou in your general User file (e.g. Default (OSX).sublime-keymap
) you can define a binding using the same key, that is only conditionally activated. e.g.
{
"keys": ["f12"],
"command": "somelang_aware_jump_to_def",
"context": [
{
"key": "selector",
"operator": "equal",
"operand": "source.somelang"
}
]
},
from lsp.
I would like to discuss how we can provide @rmccue's improved experience while being "a good Sublime Text citizen" as a package.
Sublime Text's package submission tool warns against overriding built-in keybindings, overriding built-in commands is a step beyond that.
It might be hard to install the override optionally, but we could consider building a companion package that enables these kinds of overrides. Some other candidates are the "List symbols in document" (cmd+R) and List symbols in workspace commands.
If creating a new package is too much work, we could in the meantime add this override in the documentation so people can paste it into their User Packages if desired.
from lsp.
FWIW, I think a better design from Sublime's end would have been for packages to provide "providers" for autocompletion so we don't have to override, but such is life. :)
As a user, I want an experience where I install the package and it just works without needing a bunch of configuration. I want it to take control of the cross-referencing/goto bits of Sublime, because that's most of the reason that I installed the package in the first place.
That said, a separate package might be a good compromise, if not just a single preference.
It might be hard to install the override optionally
Depends on what "install the override" means; we can easily check prefs in the event handler and skip custom behaviour if it's not enabled, from what I can see.
from lsp.
What about show a link "Show (or Go to) definitions" in LSP popup, like ColorHelper do?
from lsp.
The fallback already exists: https://github.com/tomv564/LSP/blob/master/main.py#L1093
You can create for overrides of ST's keybindings (like F12) to point to lsp_symbol_definition
as described in the documentation (https://lsp.readthedocs.io/en/latest/#features)
How do you trigger ST's Goto Definition? Please share if you use the context menu and found a better solution than going down to the LSP Symbol Definition item.
from lsp.
I trigger it via a shortcut.
Correct me if I'm wrong but for files that don't trigger LSP, I'd have to use ST's fallback goto definition, right? Since lsp_symbol_definition
would be unavailable. And then on LSP-enabled files, I'd use a different shortcut?
from lsp.
For the context menu, you could use @rmccue's approach of intercepting the context_goto_definition
commands with an EventListener if a language server with definition support is available for a given view (see #83)
If you're comfortable overriding the Context menu instead, I found instructions here: https://forum.sublimetext.com/t/altering-default-context-menu/28766
Essentially, create a Default/Context.sublime-menu
under Packages
and paste the contents of https://github.com/twolfson/sublime-files/blob/master/Packages/Default/Context.sublime-menu into it.
Then replace the context-goto-definition
with an lsp_symbol_definition
We can revisit adding a built-in override in the future.
from lsp.
Could be possible to override the f12 and menu only if the setting for the current environment (whether it's a project or not) has the LSP enabled?
from lsp.
This can now be achieved by updating the lsp_symbol_definition
binding to have a context:
"context": [{"key": "setting.lsp_active", "operator": "equal", "operand": true}]
from lsp.
Related Issues (20)
- goto definition cursor position is one char behind HOT 6
- Crash when removing a folder from sublime HOT 7
- setting for 'diagnostics' hover popup HOT 2
- Containerized development workflow HOT 3
- Keep server running without a related source file open? HOT 6
- Latest version breaks on startup HOT 2
- [clangd] Duplicated references HOT 6
- Find references not working across the project but only on opened files HOT 8
- Sublime Text Becomes unresponsive when hovered on variable containing large data (Variable Storing embeded font data) HOT 16
- `KeyError` in LSP plugin when trying to open Preferences HOT 3
- Goto Definition throws HOT 4
- Deprecate ST3 support for LSP-* packages HOT 1
- Feature: Only format when project configured for formatting HOT 8
- Disabling/Uninstalling the package resets Sublime Text's color scheme HOT 4
- Progress for migrating to python 3.8 HOT 7
- Option to disable code lens reference counter to reduce screen clutter HOT 2
- LSP messaging does not properly handle trailing `.0` on integer values HOT 7
- Plugin does not reflect `lsp_code_actions_on_save` settings HOT 3
- Can't disable code lens in settings HOT 4
- Formatting code show in hover popups HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lsp.