Giter VIP home page Giter VIP logo

Comments (6)

MaskRay avatar MaskRay commented on July 29, 2024

Wrong type argument: listp, "-Wall -Werror"

Did you specify -Wall -Werror in compile_commands.json or .ccls?

This choice, in order to avoid providing any compile_commands.json and/or .ccls files to facilitate debugging.

Neither compile_commands.json nor .ccls is mandatory. See https://github.com/MaskRay/ccls/wiki/Project-Setup But ensure (lsp--suggest-project-root) return the correct project root.

A minimal example is: mkdir /tmp/c; cd /tmp/c; git init; echo 'int a;' > a.cc

Open a.cc, and execute M-x lsp

from emacs-ccls.

rememberYou avatar rememberYou commented on July 29, 2024

Thank you for your quick answer.

I have created the ccls file at /tmp/c that contains the following content:

clang
%c -std=c11
-Wall
-Werror

NOTE: I started from your example and I did not generate the recommanded compile_commands.json file with CMake since this folder does not have a CMakeLists.txt file.

However, after restarting GNU Emacs, opening the /tmp/c/a.cc file and execute M-x lsp, but the error is still the same.

As requested, I have checked that the (lsp--suggest-project-root) function returns the right path. To do this, I changed the mode of the file for lisp-mode and executed this function that sends me back: "/tmp/c/"

If it can help:

M-x emacs-version
GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-07-05
$ uname -a
Linux ThinkPad 4.20.11-arch1-1-ARCH #1 SMP PREEMPT Wed Feb 20 21:11:12 UTC 2019 x86_64 GNU/Linux
$ ccls --version
ccls version 7.0.1 (tags/RELEASE_701/final)

from emacs-ccls.

MaskRay avatar MaskRay commented on July 29, 2024

-Werror

Unrelated to this issue report, but just wanted to mention that -Werror is probably not the flag you want to add to .ccls. If for some reason clang cannot parse your source file (sometimes due to gcc compatibility, sometimes due to clang's own bugs when some clang features like preamble being used), By default, clang stops parsing the file when it encounters 19 errors (cc1 flag: -ferror-limit 19).

M-x toggle-debug-on-error and try again.

from emacs-ccls.

rememberYou avatar rememberYou commented on July 29, 2024

This is what M-x toggle-debug-on-error provides me after opened back the /tmp/c/a.cc file:

Debugger entered--Lisp error: (wrong-type-argument listp "-Wall -Werror")
  make-process(:name "ccls" :connection-type pipe :buffer "*ccls*" :coding no-conversion :command ("/usr/bin/ccls" . "-Wall -Werror") :filter #f(compiled-function (proc output) #<bytecode 0x18031b1>) :sentinel #f(compiled-function (process exit-str) #<bytecode 0x1803c41>) :stderr "*ccls::stderr*" :noquery t)
  #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>)(#f(compiled-function (proc output) #<bytecode 0x18031b1>) #f(compiled-function (process exit-str) #<bytecode 0x1803c41>) "ccls")
  lsp--start-workspace(#s(lsp-session :folders ("/tmp/c/" "~/Desktop/test/" "/home/someone/Desktop/test/" "~/.local/share/git/sfml-game/" "/home/someone/.local/share/git/sfml-game/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x15fdd39> :folder->servers #<hash-table equal 0/65 0x185bd8d> :metadata #<hash-table equal 0/65 0x13fcef9>) #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil) "/tmp/c/" nil)
  lsp--start-connection(#s(lsp-session :folders ("/tmp/c/" "~/Desktop/test/" "/home/someone/Desktop/test/" "~/.local/share/git/sfml-game/" "/home/someone/.local/share/git/sfml-game/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x15fdd39> :folder->servers #<hash-table equal 0/65 0x185bd8d> :metadata #<hash-table equal 0/65 0x13fcef9>) #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil) "/tmp/c/")
  #f(compiled-function (client) #<bytecode 0x1b25365>)(#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil))
  mapcar(#f(compiled-function (client) #<bytecode 0x1b25365>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil)))
  -map(#f(compiled-function (client) #<bytecode 0x1b25365>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil)))
  lsp--ensure-lsp-servers(#s(lsp-session :folders ("/tmp/c/" "~/Desktop/test/" "/home/someone/Desktop/test/" "~/.local/share/git/sfml-game/" "/home/someone/.local/share/git/sfml-game/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x15fdd39> :folder->servers #<hash-table equal 0/65 0x185bd8d> :metadata #<hash-table equal 0/65 0x13fcef9>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil)) "/tmp/c/" nil)
  lsp--try-project-root-workspaces(nil)
  lsp()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c++-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c++-mode-hook))
  run-mode-hooks(c++-mode-hook)
  c++-mode()
  set-auto-mode-0(c++-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer a.cc> "/tmp/c/a.cc" nil nil "/tmp/c/a.cc" (248214 48))
  find-file-noselect("/tmp/c/a.cc" nil nil nil)
  find-file("/tmp/c/a.cc")
  dired-find-file()
  funcall-interactively(dired-find-file)
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)

NOTE: I generally use gccto compile my .c and .cpp files, so I changed clang for gcc in the .ccls file. However, clang a.cc works fine in a terminal.

This is the .ccls file with these modifications:

gcc
%c -std=c11
-Wall

One thing I don't understand is how and why I have to provide the -Wall and -Werror flags if I haven't specified to use them everywhere.

In fact, these flags are only defined as compilation options in a CMakeLists.txt file that I specified in another C++ project (sfml-game) where I also tried to use lsp-mode and ccls. That's why, I tried with a minimal project, in vain.

from emacs-ccls.

MaskRay avatar MaskRay commented on July 29, 2024

ccls-args is a list of strings. Don't use (setq ccls-args "-Wall -Werror")

from emacs-ccls.

rememberYou avatar rememberYou commented on July 29, 2024

A huge thank you for your patience and help. Indeed, the arguments of ccls-args was the error. I wonder how it could have been redefined because I don't use it anywhere in my GNU Emacs configuration.

from emacs-ccls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.