There's an opensource IntelliJ plugin from https://github.com/continuedev/continue that allows you to do this. It supports a couple different providers and models, e.g. LocalAI with Code Llama.
Yesterday I started to explore CodeGPT, it allows to download and run local model via llama.cpp, it's working fine for me so far, at least with with DeepSeek model 6.7b
https://plugins.jetbrains.com/plugin/21056-codegpt