Skip to content

Instantly share code, notes, and snippets.

@ironlungx
Last active September 13, 2025 09:43
Show Gist options
  • Save ironlungx/a2b620de74f875c49c1d06999a8c41f8 to your computer and use it in GitHub Desktop.
Save ironlungx/a2b620de74f875c49c1d06999a8c41f8 to your computer and use it in GitHub Desktop.

Revisions

  1. ironlungx revised this gist May 10, 2025. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@

    > [!Caution]
    > I've moved this gist over to a template repository [here](https://github.com/ironlungx/nvim-pio/).
    > Everything here is unmaintained...
    > **I've moved this gist over to a template repository [here](https://github.com/ironlungx/nvim-pio/). Everything here is unmaintained...**
    # Extensions
    Following are the extensions required for neovim:
  2. ironlungx revised this gist May 5, 2025. 1 changed file with 3 additions and 42 deletions.
    45 changes: 3 additions & 42 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -1,43 +1,4 @@
    #!/bin/bash
    #!/bin/sh

    create_file() {
    echo "$2" > "$1"
    echo "Created $1"
    }

    create_file ".clangd" "# clangd controls options for the LSP *server*
    CompileFlags:
    Add: [
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    -Wno-unknown-warning-option
    ]
    Remove: [
    -mlong-calls,
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    -march=*,
    -mabi=*,
    -mcpu=*
    ]
    Diagnostics:
    Suppress: \"pp_including_mainfile_in_preamble\""

    create_file ".clang-tidy" "Checks: '-*, -misc-definitions-in-headers' # Fixes some issue with header reinclusion
    IndentWidth: 2 # Only if you like 2, replace with 3/4/.. if you'd like
    "

    create_file "gen_compile_commands.py" "import os
    Import(\"env\") # platformio specific stuff
    # include toolchain paths (i.e. to have stuff like the Arduino framework headers present in the compile commands)
    env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
    # override compilation DB path
    env.Replace(COMPILATIONDB_PATH=\"compile_commands.json\")"
    echo "This script is no longer maintained"
    echo "Use this repo instead: https://github.com/ironlungx/nvim-pio"
  3. ironlungx revised this gist May 4, 2025. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@

    > [!Caution]
    > I've moved this gist over to a template repository [here](https://github.com/ironlungx/nvim-pio/).
    > Everything here is unmaintained...
    # Extensions
    Following are the extensions required for neovim:
    * [mason](https://github.com/williamboman/mason.nvim)
  4. ironlungx revised this gist Apr 4, 2025. 2 changed files with 5 additions and 47 deletions.
    30 changes: 2 additions & 28 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -42,15 +42,6 @@ lspconfig.clangd.setup({
    "clangd",
    "--background-index",
    "-j=12",
    "--query-driver=**",
    "--clang-tidy",
    "--all-scopes-completion",
    "--cross-file-rename",
    "--completion-style=detailed",
    "--header-insertion-decorators",
    "--header-insertion=iwyu",
    "--pch-storage=memory",
    "--suggest-missing-includes",
    },
    })
    ```
    @@ -98,25 +89,8 @@ $ pio run -t compiledb
    - `.clang-tidy`: (thanks @omani for adding more flags!)
    ```yaml
    # Formatter options
    Checks: "*,
    -abseil-*,
    -altera-*,
    -android-*,
    -fuchsia-*,
    -google-*,
    -llvm*,
    -modernize-use-trailing-return-type,
    -zircon-*,
    -readability-else-after-return,
    -readability-static-accessed-through-instance,
    -readability-avoid-const-params-in-decls,
    -cppcoreguidelines-non-private-member-variables-in-classes,
    -misc-non-private-member-variables-in-classes,
    "
    WarningsAsErrors: ''
    HeaderFilterRegex: ''
    FormatStyle: none
    Checks: '-*, -misc-definitions-in-headers' # Fixes some issue with header reinclusion
    IndentWidth: 2 # Only if you like 2, replace with 3/4/.. if you'd like
    ```

    - `gen_compile_commands.py`:
    22 changes: 3 additions & 19 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -29,25 +29,9 @@ CompileFlags:
    Diagnostics:
    Suppress: \"pp_including_mainfile_in_preamble\""

    create_file ".clang-tidy" "# Formatter options
    Checks: \"*,
    -abseil-*,
    -altera-*,
    -android-*,
    -fuchsia-*,
    -google-*,
    -llvm*,
    -modernize-use-trailing-return-type,
    -zircon-*,
    -readability-else-after-return,
    -readability-static-accessed-through-instance,
    -readability-avoid-const-params-in-decls,
    -cppcoreguidelines-non-private-member-variables-in-classes,
    -misc-non-private-member-variables-in-classes,
    \"
    WarningsAsErrors: ''
    HeaderFilterRegex: ''
    FormatStyle: none"
    create_file ".clang-tidy" "Checks: '-*, -misc-definitions-in-headers' # Fixes some issue with header reinclusion
    IndentWidth: 2 # Only if you like 2, replace with 3/4/.. if you'd like
    "

    create_file "gen_compile_commands.py" "import os
    Import(\"env\") # platformio specific stuff
  5. ironlungx revised this gist Feb 26, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ return {
    config = function()
    local lspconfig = require("lspconfig")
    lspconfig.lua_ls.setup({})
    lspconfig.clangd.setup({}) -- Minimal setup
    lspconfig.clangd.setup({}) -- Minimal setup
    end,
    },
    }
  6. ironlungx revised this gist Feb 26, 2025. No changes.
  7. ironlungx revised this gist Feb 26, 2025. 2 changed files with 8 additions and 12 deletions.
    10 changes: 4 additions & 6 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -73,16 +73,14 @@ $ pio run -t compiledb
    ```yaml
    # clangd controls options for the LSP *server*
    CompileFlags:
    Add:
    [
    Add: [
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    -Wno-unknown-warning-option,
    -Wno-unknown-warning-option
    ]
    Remove:
    [
    Remove: [
    -mlong-calls,
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    @@ -92,7 +90,7 @@ $ pio run -t compiledb
    -fipa-pta,
    -march=*,
    -mabi=*,
    -mcpu=*,
    -mcpu=*
    ]
    Diagnostics:
    Suppress: "pp_including_mainfile_in_preamble"
    10 changes: 4 additions & 6 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -7,16 +7,14 @@ create_file() {

    create_file ".clangd" "# clangd controls options for the LSP *server*
    CompileFlags:
    Add:
    [
    Add: [
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    -Wno-unknown-warning-option,
    -Wno-unknown-warning-option
    ]
    Remove:
    [
    Remove: [
    -mlong-calls,
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    @@ -26,7 +24,7 @@ CompileFlags:
    -fipa-pta,
    -march=*,
    -mabi=*,
    -mcpu=*,
    -mcpu=*
    ]
    Diagnostics:
    Suppress: \"pp_including_mainfile_in_preamble\""
  8. ironlungx revised this gist Feb 26, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -60,7 +60,7 @@ lspconfig.clangd.setup({
    **I've made a script to do all this for you**:
    ```bash
    $ cd path/to/the/project
    $ curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/script.sh | sh
    $ curl -sSL https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/script.sh | sh
    $ rm compile_commands.json
    $ pio run -t compiledb
    ```
  9. ironlungx revised this gist Feb 26, 2025. 2 changed files with 113 additions and 35 deletions.
    69 changes: 59 additions & 10 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -26,52 +26,101 @@ return {
    config = function()
    local lspconfig = require("lspconfig")
    lspconfig.lua_ls.setup({})
    lspconfig.clangd.setup({})
    lspconfig.clangd.setup({}) -- Minimal setup
    end,
    },
    }
    ```

    For the LSP server setup (as recommended by @omani) this is what I use, it improves auto complete functionality

    ```lua
    lspconfig.clangd.setup({
    on_attach = on_attach,
    capabilities = capabilities,
    cmd = {
    "clangd",
    "--background-index",
    "-j=12",
    "--query-driver=**",
    "--clang-tidy",
    "--all-scopes-completion",
    "--cross-file-rename",
    "--completion-style=detailed",
    "--header-insertion-decorators",
    "--header-insertion=iwyu",
    "--pch-storage=memory",
    "--suggest-missing-includes",
    },
    })
    ```

    # Setting up the project

    **I've made a script to do all this for you**:
    ```bash
    $ cd path/to/the/project
    $ curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/3f0d5d46c0d6369fc7e51e32487772ac194c27b1/script.sh | sh
    $ curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/script.sh | sh
    $ rm compile_commands.json
    $ pio run -t compiledb
    ```

    **__BUT I DONT LIKE `curl|sh`__**:

    1. Initialize a project with `pio init`
    2. In the project root create the following files
    - `.clangd`:
    - `.clangd`: (thanks @omani for fixing and adding flags to the file)
    ```yaml
    # clangd controls options for the LSP *server*
    CompileFlags:
    Add:
    # clangd controls options for the LSP *server*
    CompileFlags:
    Add:
    [
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    -Wno-unknown-warning-option,
    ]
    Remove:
    Remove:
    [
    -mlong-calls,
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    -march=*,
    -mabi=*,
    -mcpu=*,
    ]
    Diagnostics:
    Suppress: "pp_including_mainfile_in_preamble"
    ```
    - `.clang-tidy`:
    - `.clang-tidy`: (thanks @omani for adding more flags!)
    ```yaml
    # Formatter options
    Checks: '-*, -misc-definitions-in-headers' # Fixes some issue with header reinclusion
    IndentWidth: 2 # Only if you like 2, replace with 3/4/.. if you'd like
    Checks: "*,
    -abseil-*,
    -altera-*,
    -android-*,
    -fuchsia-*,
    -google-*,
    -llvm*,
    -modernize-use-trailing-return-type,
    -zircon-*,
    -readability-else-after-return,
    -readability-static-accessed-through-instance,
    -readability-avoid-const-params-in-decls,
    -cppcoreguidelines-non-private-member-variables-in-classes,
    -misc-non-private-member-variables-in-classes,
    "
    WarningsAsErrors: ''
    HeaderFilterRegex: ''
    FormatStyle: none
    ```

    - `gen_compile_commands.py`:
    ```python
    import os
    79 changes: 54 additions & 25 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -1,32 +1,61 @@
    #! /usr/bin/env bash
    #!/bin/bash

    echo 'CompileFlags:
    Add:
    [
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]' > .clangd
    create_file() {
    echo "$2" > "$1"
    echo "Created $1"
    }

    echo "Checks: '-*, -misc-definitions-in-headers' " > .clangd-tidy
    create_file ".clangd" "# clangd controls options for the LSP *server*
    CompileFlags:
    Add:
    [
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    -Wno-unknown-warning-option,
    ]
    Remove:
    [
    -mlong-calls,
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    -march=*,
    -mabi=*,
    -mcpu=*,
    ]
    Diagnostics:
    Suppress: \"pp_including_mainfile_in_preamble\""

    echo 'import os
    Import("env")
    create_file ".clang-tidy" "# Formatter options
    Checks: \"*,
    -abseil-*,
    -altera-*,
    -android-*,
    -fuchsia-*,
    -google-*,
    -llvm*,
    -modernize-use-trailing-return-type,
    -zircon-*,
    -readability-else-after-return,
    -readability-static-accessed-through-instance,
    -readability-avoid-const-params-in-decls,
    -cppcoreguidelines-non-private-member-variables-in-classes,
    -misc-non-private-member-variables-in-classes,
    \"
    WarningsAsErrors: ''
    HeaderFilterRegex: ''
    FormatStyle: none"

    # include toolchain paths
    create_file "gen_compile_commands.py" "import os
    Import(\"env\") # platformio specific stuff
    # include toolchain paths (i.e. to have stuff like the Arduino framework headers present in the compile commands)
    env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
    # override compilation DB path
    env.Replace(COMPILATIONDB_PATH="compile_commands.json")' > gen_compile_commands.py

    echo 'extra_scripts = pre:gen_compile_commands.py' >> platformio.ini
    env.Replace(COMPILATIONDB_PATH=\"compile_commands.json\")"
  10. ironlungx revised this gist Feb 17, 2025. No changes.
  11. ironlungx revised this gist Feb 17, 2025. No changes.
  12. ironlungx revised this gist Feb 17, 2025. No changes.
  13. ironlungx revised this gist Feb 17, 2025. 2 changed files with 41 additions and 40 deletions.
    48 changes: 25 additions & 23 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -46,36 +46,38 @@ $ pio run -t compiledb
    1. Initialize a project with `pio init`
    2. In the project root create the following files
    - `.clangd`:
    ```yml
    CompileFlags:
    Add:
    [
    # -mlong-calls,
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    ```yaml
    # clangd controls options for the LSP *server*
    CompileFlags:
    Add:
    [
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    ```
    - `.clang-tidy`:
    ```yaml
    Checks: '-*, -misc-definitions-in-headers'
    # Formatter options
    Checks: '-*, -misc-definitions-in-headers' # Fixes some issue with header reinclusion
    IndentWidth: 2 # Only if you like 2, replace with 3/4/.. if you'd like
    ```
    - `gen_compile_commands.py`:
    ```python
    import os
    Import("env")
    Import("env") # platformio specific stuff
    # include toolchain paths
    # include toolchain paths (i.e. to have stuff like the Arduino framework headers present in the compile commands)
    env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
    # override compilation DB path
    @@ -89,4 +91,4 @@ $ pio run -t compiledb
    4. Now in your terminal run: `pio run -t compiledb` (Just delete the old `compile_commands.json` before executing this)


    Hopefully this helped, I spent a lot of time figuring it out
    Hopefully this helped, I spent a lot of time figuring it out
    33 changes: 16 additions & 17 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,22 @@
    #! /usr/bin/env bash

    echo 'CompileFlags:
    Add:
    [
    # -mlong-calls,
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]' > .clangd
    Add:
    [
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]' > .clangd

    echo "Checks: '-*, -misc-definitions-in-headers' " > .clangd-tidy

  14. ironlungx revised this gist Aug 23, 2024. No changes.
  15. ironlungx revised this gist Aug 23, 2024. 2 changed files with 20 additions and 24 deletions.
    40 changes: 19 additions & 21 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -47,26 +47,24 @@ $ pio run -t compiledb
    2. In the project root create the following files
    - `.clangd`:
    ```yml
    CompileFlags:
    Add:
    [
    # -mlong-calls,
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    Diagnostics:
    Suppress: "pp_including_mainfile_in_preamble"
    CompileFlags:
    Add:
    [
    # -mlong-calls,
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    ```
    - `.clang-tidy`:
    ```yaml
    @@ -88,7 +86,7 @@ $ pio run -t compiledb
    ```ini
    extra_scripts = pre:gen_compile_commands.py
    ```
    4. Now in your terminal run: `pio run -t compiledb`
    4. Now in your terminal run: `pio run -t compiledb` (Just delete the old `compile_commands.json` before executing this)


    Hopefully this helped, I spent a lot of time figuring it out
    4 changes: 1 addition & 3 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -17,9 +17,7 @@ echo 'CompileFlags:
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    Diagnostics:
    Suppress: "pp_including_mainfile_in_preamble' > .clangd
    ]' > .clangd

    echo "Checks: '-*, -misc-definitions-in-headers' " > .clangd-tidy

  16. ironlungx revised this gist Jul 27, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ return {
    **I've made a script to do all this for you**:
    ```bash
    $ cd path/to/the/project
    $ curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/003652be7dc8864ce269a605bf84a0fe76f612ad/script.sh | sh
    $ curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/3f0d5d46c0d6369fc7e51e32487772ac194c27b1/script.sh | sh
    $ pio run -t compiledb
    ```

  17. ironlungx revised this gist Jul 27, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion script.sh
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,4 @@ env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
    # override compilation DB path
    env.Replace(COMPILATIONDB_PATH="compile_commands.json")' > gen_compile_commands.py

    echo 'extra_scripts = pre:gen_compile_commands.py' >> platform.ini
    echo 'extra_scripts = pre:gen_compile_commands.py' >> platformio.ini
  18. ironlungx revised this gist Jul 27, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion script.sh
    Original file line number Diff line number Diff line change
    @@ -32,4 +32,4 @@ env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
    # override compilation DB path
    env.Replace(COMPILATIONDB_PATH="compile_commands.json")' > gen_compile_commands.py

    echo 'extra_scripts = pre:gen_compile_commands.py' >> .platformio
    echo 'extra_scripts = pre:gen_compile_commands.py' >> platform.ini
  19. ironlungx revised this gist Jul 26, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,7 @@ $ curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c
    $ pio run -t compiledb
    ```

    **__ BUT I DONT LIKE `curl|sh`__**:
    **__BUT I DONT LIKE `curl|sh`__**:

    1. Initialize a project with `pio init`
    2. In the project root create the following files
  20. ironlungx revised this gist Jul 26, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -41,6 +41,8 @@ $ curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c
    $ pio run -t compiledb
    ```

    **__ BUT I DONT LIKE `curl|sh`__**:

    1. Initialize a project with `pio init`
    2. In the project root create the following files
    - `.clangd`:
  21. ironlungx revised this gist Jul 26, 2024. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,12 @@ return {

    # Setting up the project

    **I've made a script to do all this for you**: `curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/003652be7dc8864ce269a605bf84a0fe76f612ad/script.sh | sh`
    **I've made a script to do all this for you**:
    ```bash
    $ cd path/to/the/project
    $ curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/003652be7dc8864ce269a605bf84a0fe76f612ad/script.sh | sh
    $ pio run -t compiledb
    ```

    1. Initialize a project with `pio init`
    2. In the project root create the following files
  22. ironlungx revised this gist Jul 26, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,8 @@ return {

    # Setting up the project

    **I've made a script to do all this for you**: `curl https://gist.github.com/ironlungx/a2b620de74f875c49c1d06999a8c41f8/raw/003652be7dc8864ce269a605bf84a0fe76f612ad/script.sh | sh`

    1. Initialize a project with `pio init`
    2. In the project root create the following files
    - `.clangd`:
  23. ironlungx revised this gist Jul 26, 2024. 1 changed file with 35 additions and 0 deletions.
    35 changes: 35 additions & 0 deletions script.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #! /usr/bin/env bash

    echo 'CompileFlags:
    Add:
    [
    # -mlong-calls,
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    Diagnostics:
    Suppress: "pp_including_mainfile_in_preamble' > .clangd

    echo "Checks: '-*, -misc-definitions-in-headers' " > .clangd-tidy

    echo 'import os
    Import("env")
    # include toolchain paths
    env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
    # override compilation DB path
    env.Replace(COMPILATIONDB_PATH="compile_commands.json")' > gen_compile_commands.py

    echo 'extra_scripts = pre:gen_compile_commands.py' >> .platformio
  24. ironlungx revised this gist Jul 26, 2024. 1 changed file with 21 additions and 22 deletions.
    43 changes: 21 additions & 22 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -38,28 +38,27 @@ return {
    2. In the project root create the following files
    - `.clangd`:
    ```yml
    CompileFlags:
    Add:
    [
    # -mlong-calls,
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    Diagnostics:
    Suppress: "pp_including_mainfile_in_preamble"
    ```
    CompileFlags:
    Add:
    [
    # -mlong-calls,
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    Diagnostics:
    Suppress: "pp_including_mainfile_in_preamble"
    ```
    - `.clang-tidy`:
    ```yaml
    Checks: '-*, -misc-definitions-in-headers'
  25. ironlungx revised this gist Apr 4, 2024. 2 changed files with 86 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    test
    86 changes: 86 additions & 0 deletions nvim-pio.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@
    # Extensions
    Following are the extensions required for neovim:
    * [mason](https://github.com/williamboman/mason.nvim)
    * [mason-lspconfig](https://github.com/williamboman/mason-lspconfig.nvim)
    * [lspconfig](https://github.com/neovim/nvim-lspconfig)

    I use `lazy.nvim` so, just add the following to your plugins table, or create a new file in `lua/plugins/lsp.lua`
    ```lua
    return {
    {
    "williamboman/mason.nvim",
    config = function()
    require("mason").setup({})
    end,
    },
    {
    "williamboman/mason-lspconfig.nvim",
    config = function()
    require("mason-lspconfig").setup({
    ensure_installed = { "lua_ls", "clangd" },
    })
    end,
    },
    {
    "neovim/nvim-lspconfig",
    config = function()
    local lspconfig = require("lspconfig")
    lspconfig.lua_ls.setup({})
    lspconfig.clangd.setup({})
    end,
    },
    }
    ```

    # Setting up the project

    1. Initialize a project with `pio init`
    2. In the project root create the following files
    - `.clangd`:
    ```yml
    CompileFlags:
    Add:
    [
    # -mlong-calls,
    -DSSIZE_MAX,
    -DLWIP_NO_UNISTD_H=1,
    -Dssize_t=long,
    -D_SSIZE_T_DECLARED,
    ]
    Remove:
    [
    -fno-tree-switch-conversion,
    -mtext-section-literals,
    -mlongcalls,
    -fstrict-volatile-bitfields,
    -free,
    -fipa-pta,
    ]
    Diagnostics:
    Suppress: "pp_including_mainfile_in_preamble"
    ```
    - `.clang-tidy`:
    ```yaml
    Checks: '-*, -misc-definitions-in-headers'
    ```
    - `gen_compile_commands.py`:
    ```python
    import os
    Import("env")
    # include toolchain paths
    env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True)
    # override compilation DB path
    env.Replace(COMPILATIONDB_PATH="compile_commands.json")
    ```

    3. Now add the following to your platformio.ini
    ```ini
    extra_scripts = pre:gen_compile_commands.py
    ```
    4. Now in your terminal run: `pio run -t compiledb`


    Hopefully this helped, I spent a lot of time figuring it out
  26. ironlungx created this gist Apr 4, 2024.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    test