Skip to content

Omnisharp doesn't work at all in Emacs 28.1 #527

@EmilyGraceSeville7cf

Description

@EmilyGraceSeville7cf

I don't know why it doesn't work as expected. I've done the following steps:

  1. add omnisharp to my packages variable in ~/.emacs
  2. M-x load-file RET ~/.emacs
  3. dotnet new console --name Test
  4. dotnet new sln --name Test
  5. dotnet sln add ./Test/Test.csproj
  6. git init
  7. emacs -nw ./Test/Program.cs
  8. M-x omnisharp-install-server
  9. M-x omnisharp-start-omnisharp-server
  10. M-x company-mode RET

Note that I've tried to build project via dotnet build after no completion appeared and restarted Emacs with 7-10 steps repeated with no result...

No completion is shown for Console.. I wanna manually start omnisharp server to check whether it works and after it hook it start to opening C# files.

My ~/.emacs is:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

(setq packages '(soft-stone-theme flycheck markdown-mode json-mode yaml-mode format-all lsp-mode csharp-mode omnisharp lsp-pyright company))

(dolist (package packages)
  (package-install package))

(add-hook 'after-init-hook (lambda () (load-theme 'soft-stone t)))
(add-hook 'after-init-hook #'global-flycheck-mode)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(display-line-numbers 'relative)
 '(package-selected-packages
   '(omnisharp csharp-mode company lsp-pyright lsp-mode format-all yaml-mode json-mode markdown-mode flycheck soft-stone-theme)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

The last failed attempt to fix this problem was adding:

(setq omnisharp-expected-server-version "1.32.0") ; https://github.com/OmniSharp/omnisharp-vscode/issues/1450#issuecomment-432516876
(let ((dotnet-version (string-trim (shell-command-to-string "dotnet --version"))))
  ;; https://github.com/OmniSharp/omnisharp-emacs/issues/459#issuecomment-452656947
  (setenv "MSBuildSDKsPath" (format "/usr/share/dotnet/sdk/%s/Sdks" dotnet-version)))

right before custom-set-variables. I restarted Emacs, M-x omnisharp-start-omnisharp-server asked me to install omnisharp server (again?). I installed it, started via M-x omnisharp-start-omnisharp-server but no completion appeared.

Sometimes I obtain Package cl is deprepated error. It seems it happens only at first server start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions