aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorschererleander <leander@schererleander.de>2025-12-12 11:57:27 +0100
committerschererleander <leander@schererleander.de>2025-12-12 11:57:27 +0100
commitdc14a6885438637dbdf1f611f3a3bb19e8493557 (patch)
treebba0713618695b70502c4b03b48f603e8ba9f4a2 /modules
parent0d06ddf14a7717baf4d66f1f9afedc485b0c06d0 (diff)
transition to the new nvim-lpsconfig setup api, as old one is deprecated
Diffstat (limited to 'modules')
-rw-r--r--modules/programs/neovim/init.lua188
1 files changed, 95 insertions, 93 deletions
diff --git a/modules/programs/neovim/init.lua b/modules/programs/neovim/init.lua
index 7d0d918..bd83eb9 100644
--- a/modules/programs/neovim/init.lua
+++ b/modules/programs/neovim/init.lua
@@ -19,28 +19,39 @@ local map = vim.keymap.set
map('n', '<leader>o', '<CMD>update<BAR>source %<CR>', { desc = 'Save & reload init.lua' })
map('n', '<leader>w', '<CMD>write<CR>')
map('n', '<leader>q', '<CMD>quit<CR>')
-map('n', '<leader>lf', vim.lsp.buf.format)
-vim.pack.add({
- { src = "https://github.com/ellisonleao/gruvbox.nvim" },
- { src = "https://github.com/echasnovski/mini.starter" },
- { src = "https://github.com/lewis6991/gitsigns.nvim" },
- { src = "https://github.com/windwp/nvim-autopairs" },
- { src = "https://github.com/zbirenbaum/copilot.lua" },
- { src = "https://github.com/zbirenbaum/copilot-cmp" },
- { src = "https://github.com/nvim-telescope/telescope.nvim" },
- { src = "https://github.com/j-hui/fidget.nvim" },
- { src = "https://github.com/nvim-lua/plenary.nvim" },
- { src = "https://github.com/nvim-treesitter/nvim-treesitter" },
- { src = "https://github.com/neovim/nvim-lspconfig" },
- { src = "https://github.com/hrsh7th/nvim-cmp" },
- { src = "https://github.com/hrsh7th/cmp-nvim-lsp" },
- { src = "https://github.com/hrsh7th/cmp-buffer" },
- { src = "https://github.com/hrsh7th/cmp-path" },
- { src = "https://github.com/hrsh7th/cmp-cmdline" },
- { src = "https://github.com/L3MON4D3/LuaSnip" },
- { src = "https://github.com/saadparwaiz1/cmp_luasnip" },
- { src = "https://github.com/onsails/lspkind-nvim" }
+-- Bootstrap lazy.nvim
+local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
+if not vim.loop.fs_stat(lazypath) then
+ vim.fn.system({
+ "git",
+ "clone",
+ "--filter=blob:none",
+ "https://github.com/folke/lazy.nvim.git",
+ "--branch=stable",
+ lazypath,
+ })
+end
+vim.opt.rtp:prepend(lazypath)
+
+-- Plugin specifications
+require("lazy").setup({
+ { "ellisonleao/gruvbox.nvim" },
+ { "echasnovski/mini.starter" },
+ { "lewis6991/gitsigns.nvim" },
+ { "windwp/nvim-autopairs" },
+ { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
+ { "j-hui/fidget.nvim" },
+ { "nvim-treesitter/nvim-treesitter" },
+ { "neovim/nvim-lspconfig" },
+ { "hrsh7th/nvim-cmp" },
+ { "hrsh7th/cmp-nvim-lsp" },
+ { "hrsh7th/cmp-buffer" },
+ { "hrsh7th/cmp-path" },
+ { "hrsh7th/cmp-cmdline" },
+ { "L3MON4D3/LuaSnip" },
+ { "saadparwaiz1/cmp_luasnip" },
+ { "onsails/lspkind-nvim" }
})
require("nvim-treesitter.configs").setup({
@@ -69,10 +80,7 @@ cmp.setup({
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Tab>'] = cmp.mapping(function(fallback)
- local copilot = require('copilot.suggestion')
- if copilot.is_visible() then
- copilot.accept()
- elseif cmp.visible() then
+ if cmp.visible() then
cmp.select_next_item()
else
fallback()
@@ -87,7 +95,6 @@ cmp.setup({
end, { 'i', 's' }),
}),
sources = cmp.config.sources({
- { name = 'copilot' },
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
}, {
@@ -104,72 +111,71 @@ cmp.event:on(
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-require("lspconfig").nixd.setup({
- capabilities = capabilities,
- settings = {
- nixd = {
- formatting = {
- command = { "nixfmt" },
- },
- },
- },
-})
-
-require("lspconfig").lua_ls.setup({
- capabilities = capabilities,
- settings = {
- lua_ls = {
- formatting = {
- command = { "luaformatter" },
- },
- },
- Lua = {
- runtime = {
- version = 'LuaJIT',
- },
- diagnostics = {
- globals = {
- 'vim', 'require'
- },
- },
- workspace = {
- library = vim.api.nvim_get_runtime_file("", true),
- },
- telemetry = {
- enable = false,
- },
- },
- },
-})
-
-require("lspconfig").pyright.setup({
- capabilities = capabilities,
+vim.api.nvim_create_autocmd('LspAttach', {
+ group = vim.api.nvim_create_augroup('UserLspConfig', {}),
+ callback = function(ev)
+ local opts = { buffer = ev.buf, noremap = true, silent = true }
+ vim.keymap.set('n', '<leader>lf', function() vim.lsp.buf.format { async = true } end, opts)
+ end,
})
-require("lspconfig").ts_ls.setup({
- capabilities = capabilities,
-})
-
-require("lspconfig").tailwindcss.setup({
- capabilities = capabilities,
-})
+local servers = {
+ nixd = {
+ settings = {
+ nixd = {
+ formatting = {
+ command = { "nixfmt" },
+ },
+ },
+ },
+ },
+ lua_ls = {
+ settings = {
+ lua_ls = {
+ formatting = {
+ command = { "luaformatter" },
+ },
+ },
+ Lua = {
+ runtime = {
+ version = 'LuaJIT',
+ },
+ diagnostics = {
+ globals = { 'vim', 'require' },
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ telemetry = {
+ enable = false,
+ },
+ },
+ },
+ },
+ pyright = {},
+ tailwindcss = {},
+ gopls = {
+ settings = {
+ gopls = {
+ analyses = {
+ unusedparams = true,
+ unusedwrite = true,
+ },
+ staticcheck = true,
+ },
+ },
+ },
+ rust_analyzer = {},
+}
-require("lspconfig").gopls.setup({
- capabilities = capabilities,
- settings = {
- gopls = {
- analyses = {
- unusedparams = true,
- unusedwrite = true,
- },
- staticcheck = true,
- },
- },
-})
+local server_names = {}
+for server, config in pairs(servers) do
+ config.capabilities = capabilities
+ vim.lsp.config(server, config)
+ table.insert(server_names, server)
+end
-require("lspconfig").rust_analyzer.setup({
- capabilities = capabilities,
-})
+vim.lsp.enable(server_names)
vim.diagnostic.config({
virtual_text = { source = "if_many" },
@@ -196,11 +202,6 @@ require("mini.starter").setup({
require("gitsigns").setup()
require("nvim-autopairs").setup()
require("fidget").setup()
-require("copilot").setup({
- suggestion = { enabled = false },
- panel = { enabled = false },
-})
-require("copilot_cmp").setup()
vim.cmd("colorscheme gruvbox")
@@ -215,3 +216,4 @@ hl(0, "DiagnosticSignError", { bg = "none" })
hl(0, "DiagnosticSignHint", { bg = "none" })
hl(0, "DiagnosticSignInfo", { bg = "none" })
hl(0, "DiagnosticSignWarn", { bg = "none" })
+