Open segeljakt opened 6 years ago
Do you get other results from cquery
? You'll have to share the kind of code your working with. The command does work in general, but it relies on the server running correctly and responding to the request.
I have for example tried with this code, when placing the cursor above test
inside main
:
void test() {
printf("Hello");
}
int main() {
test();
}
I get the same results with cquery
as gcc
😕
` I have the same problem. please help
vim8 ////////////////////////// set bs=2 mouse=a shortmess=atI set autoread autoindent number ruler hidden autochdir cursorline set smartindent incsearch nowrapscan ignorecase smartcase set tabstop=4 shiftwidth=4 softtabstop=4 set nobackup backupcopy=yes set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,latin1,gbk set encoding=utf-8 set hls hlsearch set helplang=cn set fdm=marker set fenc=
syntax on syntax enable filetype plugin indent on hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white
call plug#begin('~/.vim/plugged') let g:ale_completion_enabled = 1 let g:ale_completion_delay = 500 Plug 'w0rp/ale' let g:ale_linters = { \'cpp': ['cquery','clang','gcc'], \'c': ['cquery','clang', 'gcc'], \'python': ['pylint'], \'bash': ['shellcheck'], \'go': ['golint'],}
let g:ale_fix_on_save = 0 let g:ale_sign_column_always = 1
"let g:ale_set_quickfix = 1 let g:ale_open_list = 1 let g:ale_echo_delay = 20 let g:ale_lint_delay = 500 let g:ale_linters_explicit = 1 let g:ale_c_gcc_options = '-Wall -O2 -std=c99' let g:ale_cpp_gcc_options = '-Wall -O2 -std=c++14' let g:ale_c_cppcheck_options = '' let g:ale_cpp_cppcheck_options = ''
let g:ale_lint_on_insert_leave = 1 let g:ale_lint_on_text_changed = 'normal'
let g:ale_echo_msg_error_str = 'E' let g:ale_echo_msg_warning_str = 'W' let g:ale_echo_msg_format = '[%linter%] %code: %%s'
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚡'
let g:airline#extensions#ale#enabled = 1
let g:ale_statusline_format = ['✗ %d', '⚡ %d', '✔ OK']
nmap sp
Your problem might be down to project configuration, or caused by ALE not yet looking for compile_commands.json
in enough places. The latter will eventually be addressed.
in same directory. thanks.
$ ls /usr/local/bin compile_commands.json cquery cquery-clang cquery-clang-format
Is there any chance you could share either your project's code, or something somewhat similar to the structure of your project, such as a directory structure with a source file that repeats the same issue on other machines?
I think I might have the same issue.
test.cpp:
int foo(){
return 1;
}
int main(int argc, char *argv[]){
return foo();
}
With cursor over foo in main function I type command :ALEGoToDefinition
and nothing happens.
System: Msys2, Vim 8.1
Project: test.zip Project structure:
$ ls -l
total 355
-rw-r--r-- 1 sleigh sleigh 1382 Feb 3 14:22 cmake_install.cmake
-rw-r--r-- 1 sleigh sleigh 15568 Feb 3 14:22 CMakeCache.txt
drwxr-xr-x 1 sleigh sleigh 0 Feb 3 14:22 CMakeFiles
-rw-r--r-- 1 sleigh sleigh 134 Feb 3 14:18 CMakeLists.txt
-rw-r--r-- 1 sleigh sleigh 185 Feb 3 14:22 compile_commands.json
-rw-r--r-- 1 sleigh sleigh 4989 Feb 3 14:22 Makefile
-rw-r--r-- 1 sleigh sleigh 83 Feb 3 14:11 test.cpp
-rwxr-xr-x 1 sleigh sleigh 323991 Feb 3 14:22 TestExecutable.exe
Output from :ALEInfo
after running :ALEGoToDefinition
:
ALEInfo
Current Filetype: cpp
Available Linters: ['ccls', 'clang', 'clangcheck', 'clangd', 'clangtidy', 'clazy', 'cppcheck', 'cpplint', 'cquery', 'flawfinder', 'gcc']
Linter Aliases:
'gcc' -> ['g++']
Enabled Linters: ['cquery']
Suggested Fixers:
'clang-format' - Fix C/C++ files with clang-format.
'remove_trailing_lines' - Remove all blank lines at the end of a file.
'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
'uncrustify' - Fix C, C++, C#, ObjectiveC, ObjectiveC++, D, Java, Pawn, and VALA files with uncrustify.
Linter Variables:
let g:ale_cpp_cquery_cache_directory = '/c/Users/sleigh/.cache/cquery'
let g:ale_cpp_cquery_executable = 'cquery'
Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = v:null
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 1
let g:ale_completion_max_suggestions = 50
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = v:null
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 0
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'always'
let g:ale_linter_aliases = {}
let g:ale_linters = {'cpp': ['cquery']}
let g:ale_linters_explicit = 0
let g:ale_list_vertical = v:null
let g:ale_list_window_size = v:null
let g:ale_loclist_msg_format = v:null
let g:ale_lsp_root = {}
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = v:null
let g:ale_maximum_file_size = v:null
let g:ale_open_list = v:null
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = v:null
let g:ale_sign_error = v:null
let g:ale_sign_info = v:null
let g:ale_sign_offset = v:null
let g:ale_sign_style_error = v:null
let g:ale_sign_style_warning = v:null
let g:ale_sign_warning = v:null
let g:ale_statusline_format = v:null
let g:ale_type_map = {}
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
Command History:
(started) ['/usr/bin/bash', '-c', '''cquery''']
Press ENTER or type command to continue
Output from cquery --check test.cpp
seems ok:
$ cquery --check test.cpp
( 0.001s) [main thread ] command_line.cc:438 | Running --check
( 0.001s) [main thread ] utils.cc:298 | Reading c:/test/test.cpp
( 0.001s) [main thread ] command_line.cc:451 | Using path c:/test/test.cpp
( 0.002s) [main thread ] project.cc:69 | Failed to normalize c:/test/build
( 0.002s) [main thread ] project.cc:630 | Trying to load c:/test/build/compile_commands.json
( 0.002s) [main thread ] project.cc:637 | Trying to load c:/test/compile_commands.json
( 0.002s) [main thread ]clang_system_include_extractor.cc:108 | Using compiler drivers c:/msys32/mingw32/bin/c++.exe
( 0.009s) [main thread ] platform.cc:163 | Executed "c:/msys32/mingw32/bin/c++.exe --version"
( 0.009s) [main thread ]clang_system_include_extractor.cc:120 | Running c:/msys32/mingw32/bin/c++.exe -E -x c++ - -v
( 0.032s) [main thread ] platform.cc:163 | Executed "c:/msys32/mingw32/bin/c++.exe -E -x c++ - -v"
( 0.032s) [main thread ]clang_system_include_extractor.cc:125 | Output:
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
Using built-in specs.
COLLECT_GCC=c:/msys32/mingw32/bin/c++.exe
Target: i686-w64-mingw32
Configured with: ../gcc-7.4.0/configure --prefix=/mingw32 --with-local-prefix=/mingw32/local --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-native-system-header-dir=/mingw32/i686-w64-mingw32/include --libexecdir=/mingw32/lib --enable-bootstrap --with-arch=i686 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --enable-libstdcxx-filesystem-ts=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw32 --with-mpfr=/mingw32 --with-mpc=/mingw32 --with-isl=/mingw32 --with-pkgversion='Rev1, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld --disable-sjlj-exceptions --with-dwarf2
Thread model: posix
gcc version 7.4.0 (Rev1, Built by MSYS2 project)
COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=i686'
c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/cc1plus.exe -E -quiet -v -iprefix c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/ -D_REENTRANT - -mtune=generic -march=i686
ignoring duplicate directory "c:/msys32/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0"
ignoring duplicate directory "c:/msys32/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0/i686-w64-mingw32"
ignoring duplicate directory "c:/msys32/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0/backward"
ignoring duplicate directory "c:/msys32/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.4.0/include"
ignoring nonexistent directory "F:/msys64/mingw32/include"
ignoring nonexistent directory "/mingw32/include"
ignoring duplicate directory "c:/msys32/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.4.0/include-fixed"
ignoring duplicate directory "c:/msys32/mingw32/lib/gcc/../../lib/gcc/i686-w64-mingw32/7.4.0/../../../../i686-w64-mingw32/include"
ignoring nonexistent directory "F:/msys64/mingw32/i686-w64-mingw32/include"
#include "..." search starts here:
#include <...> search starts here:
c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0
c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0/i686-w64-mingw32
c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0/backward
c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/include
c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include
c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/include-fixed
c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../i686-w64-mingw32/include
End of search list.
COMPILER_PATH=c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/;c:/msys32/mingw32/bin/../lib/gcc/;c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../i686-w64-mingw32/bin/
LIBRARY_PATH=c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/;c:/msys32/mingw32/bin/../lib/gcc/;c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../i686-w64-mingw32/lib/../lib/;c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../lib/;c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../i686-w64-mingw32/lib/;c:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../
COLLECT_GCC_OPTIONS='-E' '-v' '-shared-libgcc' '-mtune=generic' '-march=i686'
( 0.032s) [main thread ]clang_system_include_extractor.cc:138 | Using compiler drivers c:/msys32/mingw32/bin/c++.exe
( 0.032s) [main thread ]clang_system_include_extractor.cc:150 | Running c:/msys32/mingw32/bin/c++.exe -E -x c++ -dM -
( 0.052s) [main thread ] platform.cc:163 | Executed "c:/msys32/mingw32/bin/c++.exe -E -x c++ -dM -"
( 0.052s) [main thread ]clang_system_include_extractor.cc:155 | Output:
#define __DBL_MIN_EXP__ (-1021)
#define __FLT32X_MAX_EXP__ 1024
#define __cpp_attributes 200809
#define __pentiumpro__ 1
#define __UINT_LEAST16_MAX__ 0xffff
#define __ATOMIC_ACQUIRE 2
#define __FLT128_MAX_10_EXP__ 4932
#define __FLT_MIN__ 1.17549435082228750796873653722224568e-38F
.
.
.
#define __ATOMIC_ACQ_REL 4
#define __ATOMIC_RELEASE 3
#define __declspec(x) __attribute__((x))
( 0.053s) [main thread ] project.cc:172 | Using system include directory flags
-isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0
-isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0/i686-w64-mingw32
-isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0/backward
-isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/include
-isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include
-isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/include-fixed
-isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../i686-w64-mingw32/include
( 0.053s) [main thread ] project.cc:176 | Using system preprocessor defines
( 0.053s) [main thread ] project.cc:180 | To disable this set the discoverSystemIncludes config option to false.
( 0.053s) [main thread ] timer.cc:41 | compile_commands.json clang time took 0.0ms
( 0.054s) [main thread ] timer.cc:41 | compile_commands.json our time took 46.46827ms
( 0.054s) [main thread ] command_line.cc:461 | Using arguments c:/msys32/mingw32/bin/c++.exe -working-directory=C:/test -fms-extensions -fms-compatibility -fdelayed-template-parsing c:/test/test.cpp -Wno-unknown-warning-option -fparse-all-comments -isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0 -isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0/i686-w64-mingw32 -isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include/c++/7.4.0/backward -isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/include -isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../include -isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/include-fixed -isystemc:/msys32/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.4.0/../../../../i686-w64-mingw32/include
( 0.060s) [main thread ] clang_indexer.cc:2402 | Got 0 diagnostics
( 0.061s) [main thread ] loguru.hpp:1767 | atexit
vimrc:
set nocompatible
set encoding=utf-8
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
Plug 'vim-airline/vim-airline'
Plug 'w0rp/ale'
call plug#end()
syntax on
set background=dark
colorscheme gruvbox
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
set number
set wildmenu
set wildmode=longest:full,full
set hlsearch
set ignorecase
set smartcase
let g:ale_linters = {'cpp': ['cquery']}
let g:ale_completion_enabled = 1
I tested the same project with clang-tidy linter and it works fine.
I also tested this same configuration with VS Code cquery extension (pointing to the same cquery executable) and it worked
Check the log of the messages being sent back and forth with :call ch_logfile(expand('~/channel.log'), 'w')
try to go to the definition of something, and share that file.
I have the same problem
$ cat channel.log ==== start log session ==== 17.270394 on 1: Freeing job 17.270488 on 0: Freeing job 17.270508 on 1: Closing channel 17.270520 on 1: Clearing channel 17.270532 on 1: Freeing channel 17.270541 on 0: Closing channel 17.270550 on 0: Clearing channel 17.270559 on 0: Freeing channel 17.270610 : looking for messages on channels 30.155883 : Exiting...
I had same problem.
My vimrc have this config:
let g:ale_linters = { 'c': ['gcc', 'clangcheck', 'clangtidy', 'cppcheck', 'cpplint', 'cquery', 'flawfinder', 'clang'] }
Looks like after build cquery (https://github.com/cquery-project/cquery/wiki/Building-cquery),
here a bit incomplete things.
Try to exec cquery
at the terminal, after last step cmake --build . --target install
. Maybe need to install libclang-7-dev.
And make two links:
sudo ln -s ~/cquery/build/cquery /usr/bin/cquery
(for exec cquery from any place).
ln -s ~/cquery/build/compile_commands.json ~/compile_commands.json
(to make available default config).
After that my cquery works well.
Information
VIM version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 18 2018 12:24:36) macOS version Included patches: 1-280
Operating System:
macOS High Sierra 10.13.6
:ALEInfo
What went wrong
:ALEGotoDefinition
does not seem to do anything, nor report any error messages.Reproducing the bug
:ALEGotoDefinition