22
33## Register the language server with neovim
44
5- TODO: contribute some defaults to the nvim-lspconfig repo and link to that instead.
5+ You have 2 options, until a configuration is merged in
6+ [ nvim-lspconfig] ( https://github.com/nvim-lspconfig/nvim-lspconfig ) , you can either use [ my
7+ fork] ( https://github.com/Robzz/nvim-lspconfig ) (recommended), or the raw nvim LSP API if you don't want to trust some
8+ random fork.
69
7- The following code will register the language server with Neovim, and naively attach it to every buffer. ` lsp-ai ` is
8- configured with the ` llama_cpp ` backend to run the CodeGemma v1.1 model .
10+ Both configurations configure ` lsp-ai ` to use the ` llama_cpp ` backend runnning an 8-bit quant of the CodeGemma v1.1
11+ model using FIM, fully offloaded to GPU .
912
1013Note: the model configuration is provided as an example/starting point only and I do not vouch for the quality of the
1114generations. Adjust to taste.
1215
16+ ### Using nvim-lspconfig
17+
18+ Add the following snippet to your LSP configuration:
19+
20+ ``` lua
21+ lspconfig .lsp_ai .setup {
22+ -- Uncomment the following line if using nvim-cmp with the LSP source
23+ -- capabilities = require('cmp_nvim_lsp').default_capabilities()
24+
25+ cmd_env = {
26+ -- Add any environment variables you require here, e.g. for CUDA device selection
27+ -- CUDA_VISIBLE_DEVICES = "1",
28+ },
29+ init_options = {
30+ models = {
31+ model1 = {
32+ type = " llama_cpp" ,
33+ repository = " mmnga/codegemma-1.1-2b-gguf" ,
34+ name = " codegemma-1.1-2b-Q8_0.gguf" ,
35+ n_ctx = 2048 ,
36+ n_gpu_layers = 999
37+ }
38+ },
39+ completion = {
40+ model = " model1" ,
41+ parameters = {
42+ fim = {
43+ start = " <|fim_prefix|>" ,
44+ middle = " <|fim_suffix|>" ,
45+ [" end" ] = " <|fim_middle|>"
46+ },
47+ max_context = 2000 ,
48+ max_new_tokens = 32
49+ }
50+ }
51+ },
52+ }
53+ ```
54+
55+ ### Using the nvim LSP API
56+
57+ This configuration is not recommended for serious use as it does not properly manage the LSP server lifecycle and simply
58+ registers it with every buffer, even the ones you might not want, like terminal buffers.
59+
1360``` lua
1461local lsp_ai_config = {
1562 -- Uncomment the following line if you use nvim-cmp with the cmp_nvim_lsp source.
@@ -19,7 +66,7 @@ local lsp_ai_config = {
1966 -- Add required environment variables here, e.g. for CUDA device selection.
2067 -- CUDA_VISIBLE_DEVICES = "1"
2168 },
22- root_dir = vim . loop . cwd () ,
69+ root_dir = nil ,
2370 init_options = {
2471 -- cmp-ai configuration goes here.
2572 memory = {
0 commit comments