This commit is contained in:
Nikos Papadakis 2024-12-07 15:30:19 +02:00
parent 6a92597c9c
commit 80db9b0bd4
Signed by untrusted user who does not match committer: nikos
GPG key ID: 78871F9905ADFF02
5 changed files with 245 additions and 60 deletions

View file

@ -20,6 +20,80 @@
"type": "github" "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": { "flake-utils": {
"inputs": { "inputs": {
"systems": "systems" "systems": "systems"
@ -56,6 +130,77 @@
"type": "github" "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": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -76,6 +221,45 @@
"type": "github" "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": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1729880355, "lastModified": 1729880355,
@ -96,11 +280,27 @@
"locked": { "locked": {
"lastModified": 1733229606, "lastModified": 1733229606,
"narHash": "sha256-FLYY5M0rpa5C2QAE3CKLYAM6TwbKicdRK6qNrSHlNrE=", "narHash": "sha256-FLYY5M0rpa5C2QAE3CKLYAM6TwbKicdRK6qNrSHlNrE=",
"owner": "nixos", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "566e53c2ad750c84f6d31f9ccb9d00f823165550", "rev": "566e53c2ad750c84f6d31f9ccb9d00f823165550",
"type": "github" "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": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixpkgs-unstable", "ref": "nixpkgs-unstable",
@ -113,7 +313,8 @@
"devbox": "devbox", "devbox": "devbox",
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_2",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs_2" "neovim-nightly-overlay": "neovim-nightly-overlay",
"nixpkgs": "nixpkgs_3"
} }
}, },
"systems": { "systems": {

View file

@ -5,18 +5,23 @@
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
devbox.url = "github:jetify-com/devbox/latest"; devbox.url = "github:jetify-com/devbox/latest";
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { nixpkgs, home-manager, flake-utils, devbox, ... }: outputs = { nixpkgs, home-manager, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
user = "nikos"; # change your user here user = "nikos"; # change your user here
dotfilesHome = "/home/${user}/.dotfiles"; # specify your dotfiles path dotfilesHome = "/home/${user}/.dotfiles"; # specify your dotfiles path
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
overlays = [
(self: super: { devbox = inputs.devbox.packages.${system}.default; })
inputs.neovim-nightly-overlay.overlays.default
];
in in
{ {
packages.homeConfigurations.${user} = home-manager.lib.homeManagerConfiguration { packages.homeConfigurations.${user} = home-manager.lib.homeManagerConfiguration {
@ -25,11 +30,7 @@
# Specify your home configuration modules here, for example, # Specify your home configuration modules here, for example,
# the path to your home.nix. # the path to your home.nix.
modules = [ modules = [
({ ... }: { { nixpkgs.overlays = overlays; }
nixpkgs.overlays = [
(self: super: { devbox = devbox.packages.${system}.default; })
];
})
./home.nix ./home.nix
]; ];

View file

@ -71,6 +71,7 @@
programs.neovim = { programs.neovim = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
package = pkgs.neovim;
extraPackages = [ extraPackages = [
pkgs.nil # Nix lsp pkgs.nil # Nix lsp
pkgs.nixpkgs-fmt # Nix formatter pkgs.nixpkgs-fmt # Nix formatter

View file

@ -64,18 +64,18 @@ vmap("<Leader>p", '"_dP')
vmap(">", ">gv") vmap(">", ">gv")
vmap("<", "<gv") vmap("<", "<gv")
M.lsp_keymaps = function(client, bufnr) -- M.lsp_keymaps = function(client, bufnr)
nmap("<Leader>r", vim.lsp.buf.rename, "Rename", bufnr) -- nmap("<Leader>r", vim.lsp.buf.rename, "Rename", bufnr)
nmap("<Leader>cf", vim.lsp.buf.format, "Format document", bufnr) -- nmap("<Leader>cf", vim.lsp.buf.format, "Format document", bufnr)
nmap("<Leader>ca", vim.lsp.buf.code_action, "Code actions", bufnr) -- nmap("<Leader>ca", vim.lsp.buf.code_action, "Code actions", bufnr)
nmap("<Leader>ci", vim.lsp.buf.implementation, "Go to implementation", bufnr) -- nmap("<Leader>ci", vim.lsp.buf.implementation, "Go to implementation", bufnr)
nmap("<Leader>D", vim.lsp.buf.type_definition, "Go to type definition", bufnr) -- nmap("<Leader>D", vim.lsp.buf.type_definition, "Go to type definition", bufnr)
nmap("gr", "<Cmd>Telescope lsp_references<CR>", "View references", bufnr) -- nmap("gr", "<Cmd>Telescope lsp_references<CR>", "View references", bufnr)
--
if client.server_capabilities.hoverProvider then -- if client.server_capabilities.hoverProvider then
nmap("K", vim.lsp.buf.hover, "LSP hover", bufnr) -- nmap("K", vim.lsp.buf.hover, "LSP hover", bufnr)
end -- end
end -- end
M.telescope_keymaps = function(fns) M.telescope_keymaps = function(fns)
nmap("<C-p>", fns.project, "Find project files") nmap("<C-p>", fns.project, "Find project files")

View file

@ -20,42 +20,6 @@ if has_lsp_format then
} }
end 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 = { local prettier = {
formatCommand = 'prettierd "${INPUT}"', formatCommand = 'prettierd "${INPUT}"',
formatStdin = true, formatStdin = true,
@ -251,8 +215,26 @@ local servers = {
} }
for lsp, settings in pairs(servers) do for lsp, settings in pairs(servers) do
lspconfig[lsp].setup(vim.tbl_extend("force", { lspconfig[lsp].setup(vim.tbl_extend("force", { capabilities = capabilities }, settings))
on_attach = on_attach,
capabilities = capabilities,
}, settings))
end 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,
})