Skip to content

nix-utilities/ycm_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

YCM Examples

Nix modules based on ycm-core/lsp-examples

Byte size of Ycm_examples Open Issues Open Pull Requests Latest commits License



Requirements

Install the NixOS and/or Nix package manager via official instructions;

https://nixos.org/nixos/manual/

This repository requires the Vim text editor to be installed the source code is available on GitHub -- vim/vim, and most GNU Linux package managers are able to install Vim directly, eg...

  • Arch based Operating Systems
    sudo packman -Syy
    sudo packman -S vim
  • Debian derived Distributions
    sudo apt-get update
    sudo apt-get install vim

Quick Start

  • Clone this project...
mkdir -vp ~/git/hub/nix-utilities

cd ~/git/hub/nix-utilities

git clone [email protected]:nix-utilities/ycm_examples.git

Usage

Optional if using Home Manager with system flake

Pass system level pkgs through Home-Manager extraSpecialArgs

flake.nix (snippet)

{
  description = "System wide flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, home-manager, nixpkgs, ... }@attrs:
  let
    hostname = "nixos";
    system = "x86_64-linux";
  in
  {
    nixosConfigurations."${hostname}" = nixpkgs.lib.nixosSystem {
      inherit system;
      specialArgs = attrs;
      modules = [
        ./configuration.nix
        home-manager.nixosModules.home-manager
        {
          home-manager.useGlobalPkgs = true;
          home-manager.useUserPackages = true;
          home-manager.extraSpecialArgs = with attrs; {
            inherit nixpkgs;
            pkgs = nixpkgs.legacyPackages.${system};
          };
        }
      ];
    };
  };
}

Import as a configuration module

configuration.nix (snippet)

{
  config,
  lib,
  nixpkgs,
  pkgs,
  ...
}:

{
  imports = [
    (import /home/your-name/git/hub/nix-utilities/ycm_examples {
      inherit config lib pkgs;
    })
  ];

  config.services.ycm_examples.servers = with config.services.ycm_examples; [
    nil
    pest-ide-tools
    vim-language-server
    # ...
  ];
}

Then rebuild as usual;

sudo nixos-rebuild switch

... note if using a flake.nix then instead of above, then use following;

nixos-rebuild switch --flake .

Experimental use as flake input with home-manager

flake.nix (diff)

 {
   description = "System wide flake";

   inputs = {
     nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
     home-manager.url = "github:nix-community/home-manager";
     home-manager.inputs.nixpkgs.follows = "nixpkgs";
+    ycm_examples.url = "github:nix-utilities/ycm_examples?ref=main";
   };
 
   outputs = { self, home-manager, nixpkgs, ... }@attrs:
   let
     hostname = "nixos";
     system = "x86_64-linux";
   in
   {
     nixosConfigurations."${hostname}" = nixpkgs.lib.nixosSystem {
       inherit system;
       specialArgs = attrs;
       modules = [
         ./configuration.nix
         home-manager.nixosModules.home-manager
         {
           home-manager.useGlobalPkgs = true;
           home-manager.useUserPackages = true;
           home-manager.extraSpecialArgs = with attrs; {
-            inherit nixpkgs;
+            inherit nixpkgs ycm_examples;
             pkgs = nixpkgs.legacyPackages.${system};
           };
         }
       ];
     };
   };
 }

configuration.nix (diff)

 {
   config,
   lib,
   nixpkgs,
   pkgs,
+  ycm_examples
   ...
 }:

 {
   imports = [
-    (import /home/your-name/git/hub/nix-utilities/ycm_examples {
+    (import ycm_examples {
       inherit config lib pkgs;
     })
   ];
 
   config.services.ycm_examples.servers = with config.services.ycm_examples; [
     nil
     pest-ide-tools
     vim-language-server
     # ...
   ];
 }

Contributing

Options for contributing to ycm_examples and nix-utilities


Forking

Start making a Fork of this repository to an account that you have write permissions for.

  • Clone this project...
mkdir -vp ~/git/hub/nix-utilities

cd ~/git/hub/nix-utilities

git clone [email protected]:nix-utilities/ycm_examples.git
cd ~/git/hub/nix-utilities/ycm_examples

git remote add fork [email protected]:<NAME>/ycm_examples.git
  • Add a language server sub-directory, for example here's how Astro support was added
mkdir my-language-server

touch astro-language-server/default.nix
  • Populate astro-language-server/default.nix file with configurations
{
  config,
  lib,
  pkgs,
  ...
}:
let
  utils = import ../utils.nix { inherit lib pkgs; };
in
utils.mkModule rec {
  inherit config pkgs;

  name = "astro-language-server";

  lspConfig = {
    ycm-lsp-server = {
      name = "astro";
      filetypes = [ "astro" ];
      cmdline = [ "${pkgs.astro-language-server}/bin/astro-ls" "--stdio" ];
      project_root_files = [ "tsconfig.json" "astro.config.mjs" ];
    };

    ycm_extra_conf.settings =
      let
        dict = utils.convertTo.python.dictFromAttrs {
          ls.typescript.tsdk = "${pkgs.typescript.outPath}/lib/node_modules/typescript/lib";
        };
      in
      ''
        if kwargs[ 'language' ] == 'astro':
            return ${dict}
      '';
  };
}

Notes about configurations;

  • lspConfig.ycm-lsp-server attribute set will be appended to VimRC file's g:ycm_language_server list value, check;

  • lspConfig.ycm_extra_conf.settings will be inserted within the resulting Settings function definition, and file path will appended to VimRC file's g:ycm_global_ycm_extra_conf value, check;

Warnings

  • lspConfig.ycm-lsp-server.name MUST match the value that Vim reports via :echo &filetype in order for YouCompleteMe to load correct settings from ycm_extra_conf.py
  • Add to the imports list within default.nix
 {
   imports = [
+    ./astro-language-server
     ./awk-language-server
     ./bash-language-server
  • Add entry to your configuration.nix
 { config, pkgs, nixpkgs, ... }:
 
 {
   imports = [
     (import /home/your-name/git/hub/nix-utilities/ycm_examples {
       inherit config lib pkgs;
     })
   ];

   config.services.ycm_examples.servers = with config.services.ycm_examples; [
+    ./astro-language-server
     nil
     pest-ide-tools
     vim-language-server
     # ...
   ];
 }
  • Rebuild and test that things work

  • Commit your changes and push to your fork, eg. to fix an issue...

cd ~/git/hub/nix-utilities/ycm_examples

git commit -m "astro-language-server: Add language server"

git push fork main

Note, the -u option may be used to set fork as the default remote, eg. git push -u fork main however, this will also default the fork remote for pulling from too! Meaning that pulling updates from origin must be done explicitly, eg. git pull origin main

  • Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>

Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.


Sponsor

Thanks for even considering it!

Via Liberapay you may sponsor__shields_io__liberapay on a repeating basis.

Regardless of if you're able to financially support projects such as ycm_examples that nix-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.


Status of LSP testing

  • ./astro-language-server works with ycm_extra_conf.py generated by ./default.nix
  • ./awk-language-server error, "POST /run_completer_command HTTP/1.1" 500
  • ./bash-language-server works
  • ./docker-language-server works mostly, provides basic syntax checking
  • ./dockerfile-language-server-nodejs works, and provides GetHover docs too, unlike ./docker-language-server
  • ./erlang-ls works
  • ./haskell-language-server error, may need investigation by Haskell expert
  • ./nil works though may slow-down initial load
  • ./pest works
  • ./postgres-lsp error, might need Docker or other dependencies injected, and checking the configuration documentation maybe wise
  • ./typescript-language-server works not to be confused with tsserver bundled with ycmd which does not seem to work as of 2025-10-31
  • ./vim-language-server works
  • ./vscode-css-languageserver works
  • ./vscode-json-languageserver no errors or server rejections but doesn't seem to do anything

Attribution


License

Nix modules based on `ycm-core/lsp-examples` from GitHub
Copyright 2025 S0AndS0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

For further details review full length version of Apache-2.0 License.

About

Nix modules based on `ycm-core/lsp-examples` from GitHub

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages