Sublime Forum

How to give Sublime Text's native auto complete suggestions priority over LSP suggestions?

#1

I’m using the C# OmniSharp language server for a C# project. However, the autocomplete suggestions are now filled with available language keywords instead of the native context-aware completions. Is there a way to give Sublime Text’s native completions priority over LSP completions, and if not, is there a way to disable LSP completions completely and only show native completions? I checked the Sublime settings, LSP settings, and LSP-OmniSharp settings, but I found no relevant setting to configure it.

1 Like

#2

Probably use this for LSP-OmniSharp settings.

{
    "disabled_capabilities": {
        "completionProvider": true,
    },
}
1 Like

#3

I tried that and unfortunately it doesn’t work. I got a popup with this error after saving the settings:

Failed to start OmniSharp - disabling for this window for the duration of the current session.
Re-enable by running “LSP: Enable Language Server In Project” from the Command Palette.

--- Error: ---
neither “command” nor “tcp_port” is provided; cannot start a language server

0 Likes

#4

Could you post your whole LSP-OmniSharp.sublime-settings?

0 Likes

#5

Sure.

{
    "version": "1.37.8",
    "selector": "source.cs | source.cake",
    "env": {
        // TODO: Is this necessary on Windows/Linux?
        "FrameworkPathOverride": "${storage_path}/LSP-OmniSharp/.msbuild/Current"
    },
    "settings": {
        // Enable/disable default C# formatter (requires restart).
        "csharp.format.enable": true,
        // Specifies the maximum number of files for which diagnostics are
        // reported for the whole workspace. If this limit is exceeded,
        // diagnostics will be shown for currently opened files only. Specify 0
        // or less to disable the limit completely.
        "csharp.maxProjectFileCountForDiagnosticAnalysis": 1000,
        // Specifies whether the references CodeLens should be shown.
        "csharp.referencesCodeLens.enabled": false,
        // Array of custom symbol names for which CodeLens should be disabled.
        "csharp.referencesCodeLens.filteredSymbols": [],
        // Enable/disable Semantic Highlighting for C# files (Razor files
        // currently unsupported). Defaults to false. Close open files for
        // changes to take effect.
        "csharp.semanticHighlighting.enabled": false,
        // Specifies whether the run and debug test CodeLens should be shown.
        "csharp.testsCodeLens.enabled": true,
        // The name of the default solution used at start up if the repo has
        // multiple solutions. e.g.'MyAwesomeSolution.sln'. Default value is
        // `null` which will cause the first in alphabetical order to be chosen.
        "omnisharp.defaultLaunchSolution": null,
        // Specifies whether notifications should be shown if OmniSharp
        // encounters warnings or errors loading a project. Note that these
        // warnings/errors are always emitted to the OmniSharp log
        "omnisharp.disableMSBuildDiagnosticWarning": false,
        // Enables support for decompiling external references instead of
        // viewing metadata.
        "omnisharp.enableDecompilationSupport": false,
        // Enables support for reading code style, naming convention and
        // analyzer settings from .editorconfig.
        "omnisharp.enableEditorConfigSupport": true,
        // Enables support for showing unimported types and unimported extension
        // methods in completion lists. When committed, the appropriate using
        // directive will be added at the top of the current file. This option
        // can have a negative impact on initial completion responsiveness,
        // particularly for the first few completion sessions after opening a
        // solution.
        "omnisharp.enableImportCompletion": false,
        // If true, MSBuild project system will only load projects for files
        // that were opened in the editor. This setting is useful for big C#
        // codebases and allows for faster initialization of code navigation
        // features only for projects that are relevant to code that is being
        // edited. With this setting enabled OmniSharp may load fewer projects
        // and may thus display incomplete reference lists for symbols.
        "omnisharp.enableMsBuildLoadProjectsOnDemand": false,
        // Enables support for roslyn analyzers, code fixes and rulesets.
        "omnisharp.enableRoslynAnalyzers": false,
        // Specifies the level of logging output from the OmniSharp server.
        // possible values: trace, debug, information, warning, error, critical
        "omnisharp.loggingLevel": "information",
        // The maximum number of items that 'Go to Symbol in Workspace'
        // operation can show. The limit is applied only when a positive number
        // is specified here.
        "omnisharp.maxFindSymbolsItems": 1000,
        // Specifies whether 'using' directives should be grouped and sorted
        // during document formatting.
        "omnisharp.organizeImportsOnFormat": false,
        // Specifies whether OmniSharp should use Sublime Text settings for C# code
        // formatting (use of tabs, indentation size).
        "omnisharp.useEditorFormattingSettings": true,
        // Specifies whether to disable Razor language features.
        "razor.disabled": false,
        // Enable/disable default Razor formatter.
        "razor.format.enable": true,
        // Specifies whether to output all messages [Verbose], some messages
        // [Messages] or not at all [Off].
        // possible values: Off, Messages, Verbose
        "razor.trace": "Off",
    }
}
0 Likes

#6
{
    "disabled_capabilities": {
        "completionProvider": true,
    },
    "version": "1.37.8",
    "selector": "source.cs | source.cake",
    // blah...
}

Forget to ask: are you using ST 3 or 4?

0 Likes

#7

I’m using ST4

0 Likes

#8

Apparently this worked, I just had to remove the commas. So

{
    "disabled_capabilities": {
        "completionProvider": true
    }
}

works. Thanks!

0 Likes

#9

Does your project compile from the command-line?

0 Likes

#10

No, this is a large code base in form of a Microsoft Visual Studio solution. I’m using Sublime Text for it though because I much prefer it. (I still do stuff like creating files etc with MSVS in order to not break the project management file that it uses to keep track of things). I guess it could compile from the command line, though. I’m not sure.

0 Likes

#11

Then I’m thinking that OmniSharp cannot provide accurate code completion for that reason. It’s very precise if the project is set up as a dotnet project.

0 Likes

#12

It’s precise for me, too, but not at all context-aware to the extent that Sublime Text is. For example, my project is full of classes that all start with

public Guid Id { get; set; }

However, when typing

public Guid

The next thing OmniSharp suggests is guid, and the Id I’m looking for isn’t even in the list. Sublime Text, however, always suggests Id because it knows that’s the only thing that ever appears after public Guid.

0 Likes

#13

I see. You could then also try out setting “inhibit_word_completions” to false in LSP.sublime-settings, as that gives you both ST completions as well as OmniSharp’s.

1 Like

#14

Neat, that was what I was looking for in the first place: the ability to have both. Thank you!
Edit: Actually, apparently that only either gives me Sublime’s completions or OmniSharp’s, not both at the same time? I’m not sure. Just Sublime’s native completions are fine for now, though. Thanks anyway :slight_smile:

0 Likes

#15

Hi, I have the same problem using LSP-Lua.

image

It’s still showing the LSP autocomplete:
image

How to disable it to use the native ST4 autocomplete?

0 Likes

#16

Hi @rogeriodec. As is mentioned some posts above, you can open the preferences of the package by running Preferences: LSP-Lua Settings. On the right-most tab, you can put the following:

// Settings in here override those in "LSP-lua/LSP-lua.sublime-settings"
{
	"disabled_capabilities": {
		"completionProvider": true
	}
}

After that you need to save that preferences file.

1 Like

#17

Thanks, but it seems I don’t have such an option.
I’ve installed Both LSP and LSP-Lua through the normal install package:

image

But LSP-Lua is not appearing on the preferences menu:

image

Also, I don’t have the LSP-lua/LSP-lua.sublime-settings file:

However, LSP-Lua seems to be working ok.

What’s wrong.

0 Likes

#18

You run it from the command palette.

1 Like

#19

Got it.
Now it’s working.
Thank you very much!

1 Like