this post was submitted on 27 Nov 2023
1 points (100.0% liked)

Emacs

313 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

For my hobby desktop c/c++ projects I started using emacs, and I really like it. I made my own config, which contains only a couple of packages like vertico, lsp-mode, company etc.

Professionally I am an embedded systems consultant, working with lot of different uC-s and IDE-s. I have a bigger job currently where I have to work with PIC32 uC, and the project is created with MPLAB X IDE. I wanted use emacs and lsp-mode, but it seems that clangd could not find some of the headers. I have generated the compile_commands.json with a python script called compiledb, but it is not working properly.... maybe clangd can not understand some of the compile flags from xc32-cc ? (the mplab compiler).

Anyone tried this stuff? Thx for help.

top 2 comments
sorted by: hot top controversial new old
[–] 7ie7an@alien.top 1 points 1 year ago

Hey,same situation here. I am not an emacs expert but am using it for around 6 years now.

My solution is to use clangd with a "compile_flags.txt" file in top level directory of the repository (and add it to ".git/info/exclude") to avoid an accidential commit.

The content is mostly project paths and additionally:

-include

c:/Users/USERNAME/.mchp_packs/Microchip/dsPICxxx/y.y.yyy/COMPILER/support/dsPICxxx/h/pxxx.h

-include

c:/Users/USERNAME/.mchp_packs/Microchip/dsPICxxx/y.y.yyy/COMPILER/support/generic/h/xc.h

-I

path/to/project.X/mcc_generated_files

-O0

-I

C:/MinGW/include

-D

__dsPICxxx__

The paths vary in Controller and pack that is used.

I also use "eglot" instead of "lsp-mode" simply because it's enough for me in functionality and I also have a "build.bat" at the top level of the repo that is used with the emacs internal compile command like "project-compile" (C-c p c).

- build.bat clean

- build.bat cleanbuild

- build.bat makefiles

- build.bat ...

[–] shadowsock@alien.top 1 points 1 year ago

Have you tried Bear? I used it for several projects and overall it works very well.