CodeLite works well with V when you open the code as a File System Workspace and define custom build targets with CodeLite macros.
This guide uses POSIX shell commands, which match Linux and macOS. On Windows,
use .exe outputs and replace rm -f with del.
- Put
von yourPATH. If it is not on yourPATH, replacevbelow with the absolute path to your V compiler. - Create a CodeLite workspace from your existing source tree:
- Open
File->New->New workspace - Choose
File System Workspace - Select the folder containing your V sources
- Open
Open the workspace settings by right-clicking the top-level folder and choosing
Settings....
Set these fields first:
Tool chain:gccorclangFile extensions: addv,vsh, andvv
CodeLite uses the selected tool chain mainly to parse build output, so any GNU-like tool chain is fine here.
For single-file programs, use:
Executable:$(CurrentFilePath)/$(CurrentFileName)Working directory:$(CurrentFilePath)
For a project rooted at the workspace folder, use:
Executable:$(WorkspacePath)/$(WorkspaceName)Working directory:$(WorkspacePath)
The default build and clean targets can not be removed. Add run and
test targets if you want them in the Build menu.
This is the simplest setup for scripts, examples, and small programs:
build:v -g -o "$(CurrentFilePath)/$(CurrentFileName)" "$(CurrentFileFullPath)"clean:rm -f "$(CurrentFilePath)/$(CurrentFileName)"run:v run "$(CurrentFileFullPath)"test:v test "$(CurrentFileFullPath)"
If the workspace root is a V project with v.mod, or the workspace folder is
your app entry point, use:
build:v -g -o "$(WorkspacePath)/$(WorkspaceName)" "$(WorkspacePath)"clean:rm -f "$(WorkspacePath)/$(WorkspaceName)"
If your app starts from a specific file such as src/main.v, replace
"$(WorkspacePath)" with that file path in the build target.
- Press
F7to run thebuildtarget. - Use
RunorDebugafterExecutablepoints to the file produced by the build target. - Keep
-gin the build command sogdborlldbcan show V source locations.
If CodeLite opens the wrong file from compiler errors, add this workspace environment variable:
VERROR_PATHS=absolute
That makes v print absolute file paths, which is often better for IDE
launchers.
For manual formatting, or for a formatter command inside CodeLite, use:
v fmt -w "$(CurrentFileFullPath)"
For completion, go-to-definition, hover information, and related IDE features, use v-analyzer alongside CodeLite.