diff --git a/flake.lock b/flake.lock index 055adfc..254098c 100644 --- a/flake.lock +++ b/flake.lock @@ -20,6 +20,80 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly-overlay", + "hercules-ci-effects", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -56,6 +130,77 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "gitignore": "gitignore", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ], + "nixpkgs-stable": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733318908, + "narHash": "sha256-SVQVsbafSM1dJ4fpgyBqLZ+Lft+jcQuMtEL3lQWx2Sk=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "6f4e2a2112050951a314d2733a994fbab94864c6", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "neovim-nightly-overlay", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "hercules-ci-effects": { + "inputs": { + "flake-parts": "flake-parts_2", + "nixpkgs": [ + "neovim-nightly-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733333617, + "narHash": "sha256-nMMQXREGvLOLvUa0ByhYFdaL0Jov0t1wzLbKjr05P2w=", + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "rev": "56f8ea8d502c87cf62444bec4ee04512e8ea24ea", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -76,6 +221,45 @@ "type": "github" } }, + "neovim-nightly-overlay": { + "inputs": { + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "git-hooks": "git-hooks", + "hercules-ci-effects": "hercules-ci-effects", + "neovim-src": "neovim-src", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1733530506, + "narHash": "sha256-x8slAzUe1gopASFNhnHO9DmWXvnF7u27YMSwTmIY8bU=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "3930a71f90bacc656e8bdf19cc0faa9ebf10353a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "neovim-src": { + "flake": false, + "locked": { + "lastModified": 1733517821, + "narHash": "sha256-QjFVx/zMyutuW1TWzOKEe5cY7YGqvPkRhi9wQHY52Yo=", + "owner": "neovim", + "repo": "neovim", + "rev": "517ecb85f58ed6ac8b4d5443931612e75e7c7dc2", + "type": "github" + }, + "original": { + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1729880355, @@ -96,11 +280,27 @@ "locked": { "lastModified": 1733229606, "narHash": "sha256-FLYY5M0rpa5C2QAE3CKLYAM6TwbKicdRK6qNrSHlNrE=", - "owner": "nixos", + "owner": "NixOS", "repo": "nixpkgs", "rev": "566e53c2ad750c84f6d31f9ccb9d00f823165550", "type": "github" }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1733330745, + "narHash": "sha256-jy34Nf4Tn1ITZcYyMBn1/7jA8bCCIZDpiVahqlCXfww=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2f9d395f057a50f8076f633c10519035fce8d773", + "type": "github" + }, "original": { "owner": "nixos", "ref": "nixpkgs-unstable", @@ -113,7 +313,8 @@ "devbox": "devbox", "flake-utils": "flake-utils_2", "home-manager": "home-manager", - "nixpkgs": "nixpkgs_2" + "neovim-nightly-overlay": "neovim-nightly-overlay", + "nixpkgs": "nixpkgs_3" } }, "systems": { diff --git a/flake.nix b/flake.nix index 1141c0d..d4011df 100644 --- a/flake.nix +++ b/flake.nix @@ -5,18 +5,23 @@ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; devbox.url = "github:jetify-com/devbox/latest"; + neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { nixpkgs, home-manager, flake-utils, devbox, ... }: + outputs = { nixpkgs, home-manager, flake-utils, ... }@inputs: flake-utils.lib.eachDefaultSystem (system: let user = "nikos"; # change your user here dotfilesHome = "/home/${user}/.dotfiles"; # specify your dotfiles path pkgs = nixpkgs.legacyPackages.${system}; + overlays = [ + (self: super: { devbox = inputs.devbox.packages.${system}.default; }) + inputs.neovim-nightly-overlay.overlays.default + ]; in { packages.homeConfigurations.${user} = home-manager.lib.homeManagerConfiguration { @@ -25,11 +30,7 @@ # Specify your home configuration modules here, for example, # the path to your home.nix. modules = [ - ({ ... }: { - nixpkgs.overlays = [ - (self: super: { devbox = devbox.packages.${system}.default; }) - ]; - }) + { nixpkgs.overlays = overlays; } ./home.nix ]; diff --git a/home.nix b/home.nix index b4c7213..98d10fb 100644 --- a/home.nix +++ b/home.nix @@ -71,6 +71,7 @@ programs.neovim = { enable = true; defaultEditor = true; + package = pkgs.neovim; extraPackages = [ pkgs.nil # Nix lsp pkgs.nixpkgs-fmt # Nix formatter diff --git a/nvim/lua/my/keymaps.lua b/nvim/lua/my/keymaps.lua index 6991666..75f26d3 100644 --- a/nvim/lua/my/keymaps.lua +++ b/nvim/lua/my/keymaps.lua @@ -64,18 +64,18 @@ vmap("p", '"_dP') vmap(">", ">gv") vmap("<", "r", vim.lsp.buf.rename, "Rename", bufnr) - nmap("cf", vim.lsp.buf.format, "Format document", bufnr) - nmap("ca", vim.lsp.buf.code_action, "Code actions", bufnr) - nmap("ci", vim.lsp.buf.implementation, "Go to implementation", bufnr) - nmap("D", vim.lsp.buf.type_definition, "Go to type definition", bufnr) - nmap("gr", "Telescope lsp_references", "View references", bufnr) - - if client.server_capabilities.hoverProvider then - nmap("K", vim.lsp.buf.hover, "LSP hover", bufnr) - end -end +-- M.lsp_keymaps = function(client, bufnr) +-- nmap("r", vim.lsp.buf.rename, "Rename", bufnr) +-- nmap("cf", vim.lsp.buf.format, "Format document", bufnr) +-- nmap("ca", vim.lsp.buf.code_action, "Code actions", bufnr) +-- nmap("ci", vim.lsp.buf.implementation, "Go to implementation", bufnr) +-- nmap("D", vim.lsp.buf.type_definition, "Go to type definition", bufnr) +-- nmap("gr", "Telescope lsp_references", "View references", bufnr) +-- +-- if client.server_capabilities.hoverProvider then +-- nmap("K", vim.lsp.buf.hover, "LSP hover", bufnr) +-- end +-- end M.telescope_keymaps = function(fns) nmap("", fns.project, "Find project files") diff --git a/nvim/lua/my/lsp.lua b/nvim/lua/my/lsp.lua index cd347f2..bf1ac0e 100644 --- a/nvim/lua/my/lsp.lua +++ b/nvim/lua/my/lsp.lua @@ -20,42 +20,6 @@ if has_lsp_format then } end -local on_attach = function(client, bufnr) - require("my.keymaps").lsp_keymaps(client, bufnr) - - if client.server_capabilities.completionProvider then - vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr }) - end - - if client.server_capabilities.definitionProvider then - vim.api.nvim_set_option_value("tagfunc", "v:lua.vim.lsp.tagfunc", { buf = bufnr }) - end - - -- Highlight on cursor hold - if client.server_capabilities.documentHighlightProvider then - vim.api.nvim_create_autocmd({ "CursorHold" }, { - callback = vim.lsp.buf.document_highlight, - buffer = bufnr, - }) - end - - if client.server_capabilities.signatureHelp then - vim.api.nvim_create_autocmd({ "CursorHoldI" }, { - callback = vim.lsp.buf.signature_help, - buffer = bufnr, - }) - end - - vim.api.nvim_create_autocmd({ "CursorMoved" }, { - callback = vim.lsp.buf.clear_references, - buffer = bufnr, - }) - - if has_lsp_format then - lsp_format.on_attach(client) - end -end - local prettier = { formatCommand = 'prettierd "${INPUT}"', formatStdin = true, @@ -251,8 +215,26 @@ local servers = { } for lsp, settings in pairs(servers) do - lspconfig[lsp].setup(vim.tbl_extend("force", { - on_attach = on_attach, - capabilities = capabilities, - }, settings)) + lspconfig[lsp].setup(vim.tbl_extend("force", { capabilities = capabilities }, settings)) end + +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + + if client.server_capabilities.documentHighlightProvider then + vim.api.nvim_create_autocmd({ "CursorHold" }, { + callback = vim.lsp.buf.document_highlight, + buffer = args.buf, + }) + vim.api.nvim_create_autocmd({ "CursorMoved" }, { + callback = vim.lsp.buf.clear_references, + buffer = args.buf, + }) + end + + if has_lsp_format then + lsp_format.on_attach(client) + end + end, +})