Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive errors when working with Monogame #772

Closed
ebiscaia opened this issue Apr 22, 2022 · 7 comments
Closed

False positive errors when working with Monogame #772

ebiscaia opened this issue Apr 22, 2022 · 7 comments

Comments

@ebiscaia
Copy link

Hi,

I have trying to work on Vim and monogame and it is being hard because everytime I try to change anything in the file, lots of errors appears on the screen.
Capture

System: Windows 10/(Ubuntu 21.10 in WSL2)
Vim 8.2.4295

.vimrc

" Disable compatibility with vi which can cause unexpected issues.
set nocompatible

" Set encoding
set encoding=UTF-8

" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on

" Enable plugins and load plugin for the detected file type.
filetype plugin on

" Load an indent file for the detected file type.
filetype indent on

" Set numbers to be shown.
set nu rnu

" Highlight cursor line underneath the cursor horizontall:AirlineTheme tomorrowy.
set cursorline

" Highlight cursor line underneath the cursor vertically.
set cursorcolumn

" Turn syntax highlight on
syntax on

" size of an indent
set shiftwidth=2

" Tab to move by 2 characters
set tabstop=2

" Enabled automatic indentation
set autoindent

" Replace tabs with with spaces
set expandtab

" Backspace to remove 2 white spaces at once
set softtabstop=2

" Show the number of lines before/after when scrolling up/down
set scrolloff=10

" While searching through a file incrementally highlight matching characters as
" you type.
set incsearch

" Ignore capital letters during search.
set ignorecase

" Override the ignorecase option if searching for capital letters.
" This will allow you to search specifically for capital letters.
set smartcase

" Show partial command you type in the last line of the screen.
set showcmd

" how the mode you are on the last line.
set showmode

" Set the commands to save in history default number is 20.
set history=500

" Status bar
" set laststatus=2

" Set status line display
" set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [POS=%l,%v][%p%%]\ [BUFFER=%n]\ %{strftime('%c')}

" Define where splits should be shown
set splitbelow

" Keybindings
" split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

" Move around open buffers
map <S-Tab> :bn<CR>

" Define jj to leave insert mode
inoremap jj <esc>

" Define Space as the leader key
let mapleader = " "

" Edit vimr configuration file
nnoremap <Leader>ve :e $HOME/.vimrc<CR>
" Reload vimr configuration file
nnoremap <Leader>vr :source $HOME/.vimrc<CR>
" Edit vimrc.plug config file
nnoremap <Leader>vep :e $HOME/.vimrc.plug<CR>

" Plugin Specific Settings
" Nerd Tree
map <C-n> :NERDTreeToggle<CR>


" CCO autocompletion
set signcolumn=number

" Keybindings for COC
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

" COC prettier
command! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument
vmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

" Omnisharp
autocmd FileType cs nmap <silent> gd :OmniSharpGotoDefinition<CR>
autocmd FileType cs nnoremap <buffer> <Leader>fu :OmniSharpFindUsages<CR>
autocmd FileType cs nnoremap <buffer> <Leader>fi :OmniSharpFindImplementations<CR>
autocmd FileType cs nnoremap <buffer> <Leader>f :OmniSharpCodeFormat<CR>
let g:OmniSharp_translate_cygwin_wsl = 0
let g:OmniSharp_server_use_net6 = 1
let g:OmniSharp_highlighting = 1

"  Vim colorizer
let g:colorizer_auto_filetype='css,html,json,vim,python'
let g:colorizer_skip_comments = 1
let g:colorizer_colornames = 0
nnoremap <leader>cl :ColorToggle<CR>

" Language Specific Settings
" Python
autocmd FileType python imap <F5> <Esc>:w<CR>:!clear;python3 %<CR>
autocmd FileType python nmap <F5> <Esc>:w<CR>:!clear;python3 %<CR>
autocmd FileType python nnoremap <buffer> <Leader>f :Black<CR>
autocmd BufWritePre *.py execute ':Black'

" C#
autocmd FileType cs imap <F5> <Esc>:OmniSharpCodeFormat<CR>:w<CR>:!clear;dotnet run %<CR>
autocmd FileType cs nmap <F5> <Esc>:OmniSharpCodeFormat<CR>:w<CR>:!clear;dotnet run %<CR>
autocmd BufWritePre *.cs execute ':OmniSharpCodeFormat'


" Fugitive
nmap <silent> Gco <Esc>:Git commit<CR>
nmap <silent> Gps <Esc>:Git push<CR>
nmap <silent> Gpu <Esc>:Git pull<CR>
nmap <leader>gf :diffget //2
nmap <leader>gj :diffget //3


" AutoPairs
let g:AutoPairsShortcutToggle = '<C-y>'
let g:AutoPairsShortcutFastWrap = '<C-e>'

" Arline Config
let g:airline#extensions#tabline#enabled = 1 " Enable the list of buffers
let g:airline_theme='nord'
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_powerline_fonts = 1

if !exists('g:airline_symbols')
 let g:airline_symbols = {}
endif

" powerline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ' ☰ '
let g:airline_symbols.maxlinenr = ' '
let g:airline_symbols.dirty='⚡ '

let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = ' '
let g:airline_symbols.colnr = ' ℅:'


" Colorscheme
colorscheme nord

" Enable plugins
if filereadable(expand("~/.vimrc.plug"))
 source ~/.vimrc.plug
endif

.vimplug

call plug#begin('~/.vim/plugged')

"Fugitive Vim Github Wrapper
Plug 'tpope/vim-fugitive'

" Language support
Plug 'sheerun/vim-polyglot'

" Status bar
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

" Matching brackets
Plug 'jiangmiao/auto-pairs'

" Nerdtree
Plug 'scrooloose/nerdtree'
Plug 'ryanoasis/vim-devicons'

" FZF finder
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'

"C# Support
Plug 'OmniSharp/omnisharp-vim'

" Code completion
Plug 'neoclide/coc.nvim', {'branch': 'release'}

" A plugin to color colornames and codes
Plug 'chrisbra/colorizer'

" Python formatting
Plug 'psf/black', { 'branch': 'stable' }

" ColorSchemes
" Nord colorscheme
Plug 'arcticicestudio/nord-vim'

call plug#end()

Thanks

Eddie

@nickspoons
Copy link
Member

Let's see what the log says: :OmniSharpOpenLog

@ebiscaia
Copy link
Author

Sure> Here it goes:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 18 2022 19:26:30), Included patches: 1-3995                                                                                              
OmniSharp server started.
Path: /home/ebisc/.cache/omnisharp-vim/omnisharp-roslyn/OmniSharp
Target: /mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame/CannonGame.sln
PID: 9280

[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Unknown 0.0 (Unknown)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
 [info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.202 17.1.1 - "/usr/share/dotnet/sdk/6.0.202/"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.202 17.1.1 - "/usr/share/dotnet/sdk/6.0.202/"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame/CannonGame.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
 Queue project update for '/mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame/CannonGame.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame' on host -1.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame/CannonGame.csproj                                                                            [info]: OmniSharp.OmniSharpWorkspace
Miscellaneous file: /mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame/Game1.cs added to workspace
Replaying requests for buffer 1
[fail]: OmniSharp.MSBuild.ProjectLoader
Windows is required to build Windows desktop applications.
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file  /mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame/CannonGame.csproj'.
All projects loaded
/mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame/CannonGame.csproj
 /usr/share/dotnet/sdk/6.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): Error: Windows is required to build Windows desktop applications.
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /mnt/c/Users/ebisc/Documents/Nextcloud/Programs/monogame/CannonGame/CannonGame.csproj
Workspace complete: 1 project(s)
Replaying on-load requests

@nickspoons
Copy link
Member

Ok well you can see from those [warn] and [fail] messages that the server isn't loading properly, presumably you can't run it from wsl2? Is it a .NET Framework project?

@ebiscaia
Copy link
Author

As I am not 100% sure about your question (I am doing this for university purposes) here is the list of packages I installed on Ubuntu:

dotnet-apphost-pack-3.1/hirsute,now 3.1.24-1 amd64 [installed,automatic]
dotnet-apphost-pack-6.0/hirsute,now 6.0.4-1 amd64 [installed,automatic]
dotnet-host/hirsute,now 6.0.4-1 amd64 [installed,automatic]
dotnet-hostfxr-3.1/hirsute,now 3.1.24-1 amd64 [installed,automatic]
dotnet-hostfxr-6.0/hirsute,now 6.0.4-1 amd64 [installed,automatic]
dotnet-runtime-3.1/hirsute,now 3.1.24-1 amd64 [installed,automatic]
dotnet-runtime-6.0/hirsute,now 6.0.4-1 amd64 [installed,automatic]
dotnet-runtime-deps-3.1/hirsute,now 3.1.24-1 amd64 [installed,automatic]
dotnet-runtime-deps-6.0/hirsute,now 6.0.4-1 amd64 [installed,automatic]
dotnet-sdk-3.1/hirsute,now 3.1.418-1 amd64 [installed]
dotnet-sdk-6.0/hirsute,now 6.0.202-1 amd64 [installed]
dotnet-targeting-pack-3.1/hirsute,now 3.1.0-1 amd64 [installed,automatic]
dotnet-targeting-pack-6.0/hirsute,now 6.0.4-1 amd64 [installed,automatic]

@ebiscaia
Copy link
Author

I tried to create an OpenGL MonoGame project under my WSL home folder to try to address the two issues pointed by the logs (the project not being written on Windows and the path lenght). Still having the same issues despite the logs seems that everything is fine).

Capture

@ebiscaia
Copy link
Author

Well seems like the problem is when I try to run monogame for Windows as I am having no issues with the openGL version. Just tried them side-by-side.

@nickspoons
Copy link
Member

I don't think there's an error here, just a bit of confusion about where the project has been built, and where omnisharp-roslyn is running.

  • When the project has been built in Windows, you'll need to be running a Windows build of omnisharp-roslyn. This can be done by using let g:OmniSharp_translate_cygwin_wsl = 1 in your .vimrc, although there are issues with how omnisharp-roslyn communicates with Windows from WSL2, see Omnisharp-vim not doing anything on WSL2 #706
  • When the project has been build in linux (locally inside WSL) then you'll need to be running a linux build of omnisharp-roslyn, which is what you've done here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants