From cd9a19d75a8f7d2b8db4fbd770b8224241bce11a Mon Sep 17 00:00:00 2001 From: Eduardo Cueto-Mendoza Date: Fri, 20 Dec 2024 13:43:35 +0000 Subject: [PATCH] Removed none-ls, added lazydev for lua --- .config/nvim/after/plugin/01_color.lua | 36 ++++++--- .config/nvim/after/plugin/04_lspconfig.lua | 90 ++++++++++++--------- .config/nvim/after/plugin/05_completion.lua | 11 ++- .config/nvim/lua/eddie/lazy.lua | 49 +++++++---- 4 files changed, 119 insertions(+), 67 deletions(-) diff --git a/.config/nvim/after/plugin/01_color.lua b/.config/nvim/after/plugin/01_color.lua index 58ce3a2..556caad 100755 --- a/.config/nvim/after/plugin/01_color.lua +++ b/.config/nvim/after/plugin/01_color.lua @@ -1,12 +1,28 @@ -require("tokyonight").setup { - transparent = false, - styles = { - sidebars = "transparent", - floats = "transparent", - } -} +local theme = 'rose' + +if theme == 'tokyo' then + require("tokyonight").setup { + transparent = false, + styles = { + sidebars = "transparent", + floats = "transparent", + } + } + vim.cmd [[colorscheme tokyonight-night]] +elseif theme == 'rose' then + local pine = require('rose-pine.palette') + + vim.cmd.colorscheme('rose-pine') + vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'String', { fg = pine.rose }) + vim.api.nvim_set_hl(0, 'Number', { fg = pine.rose }) + vim.api.nvim_set_hl(0, 'Float', { fg = pine.rose }) + vim.api.nvim_set_hl(0, 'Constant', { fg = pine.rose }) + vim.api.nvim_set_hl(0, 'Character', { fg = pine.rose }) + vim.cmd [[colorscheme rose-pine]] +else + vim.cmd [[set notermguicolors]] +end -vim.cmd [[colorscheme tokyonight-night]] --- vim.cmd [[colorscheme tokyonight-day]] --- vim.cmd [[set notermguicolors]] vim.cmd [[hi Normal guibg=none]] diff --git a/.config/nvim/after/plugin/04_lspconfig.lua b/.config/nvim/after/plugin/04_lspconfig.lua index e23b020..e45d587 100644 --- a/.config/nvim/after/plugin/04_lspconfig.lua +++ b/.config/nvim/after/plugin/04_lspconfig.lua @@ -1,8 +1,10 @@ local lspconfig = require 'lspconfig' -local on_attach = function(client) - require 'completion'.on_attach(client) -end +-- local on_attach = function(client) +-- require 'completion'.on_attach(client) +-- end + +local capabilities = require('cmp_nvim_lsp').default_capabilities() -- BASH lspconfig.bashls.setup({}) @@ -21,7 +23,7 @@ for word in io.open(path, "r"):lines() do table.insert(words, word) end -require('lspconfig').ltex.setup({ +lspconfig.ltex.setup({ settings = { ltex = { language = "en-GB", @@ -33,44 +35,55 @@ require('lspconfig').ltex.setup({ }) -- LUA -lspconfig.lua_ls.setup({ - settings = { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT', - }, - diagnostics = { - -- Get the language server to recognize the `vim` global - globals = { 'vim' }, - neededFileStatus = { - ["codestyle-check"] = "Any", - }, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = { - enable = false, - }, - format = { - enable = true, - -- Put format options here - -- NOTE: the value should be STRING!! - defaultConfig = { - indent_style = "space", - indent_size = "4", - } - }, +lspconfig.lua_ls.setup { + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if vim.loop.fs_stat(path..'/.luarc.json') or vim.loop.fs_stat(path..'/.luarc.jsonc') then + return + end + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT' + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + -- Depending on the usage, you might want to add additional paths here. + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", }, - }, -}) + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189) + -- library = vim.api.nvim_get_runtime_file("", true) + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { 'vim', 'require' }, + }, + format = { + -- Put format options here + -- NOTE: the value should be STRING!! + defaultConfig = { + indent_style = "space", + indent_size = "4", + } + }, + }) + end, + settings = { + Lua = {} + } +} -- PYTHON -require('lspconfig').pylsp.setup { +lspconfig.pylsp.setup { settings = { pylsp = { plugins = { @@ -99,6 +112,7 @@ require('lspconfig').pylsp.setup { -- RUST lspconfig.rust_analyzer.setup({ -- on_attach = on_attach, + capabilities = capabilities, settings = { ["rust-analyzer"] = { imports = { diff --git a/.config/nvim/after/plugin/05_completion.lua b/.config/nvim/after/plugin/05_completion.lua index 8bfcaab..fb254af 100644 --- a/.config/nvim/after/plugin/05_completion.lua +++ b/.config/nvim/after/plugin/05_completion.lua @@ -1,12 +1,15 @@ -- Set up nvim-cmp. local cmp = require 'cmp' +-- Lua Snip +require("luasnip.loaders.from_vscode").lazy_load() + cmp.setup({ snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) - vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. -- require('snippy').expand_snippet(args.body) -- For `snippy` users. -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. -- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+) @@ -25,8 +28,8 @@ cmp.setup({ }), sources = cmp.config.sources({ { name = 'nvim_lsp' }, - { name = 'vsnip' }, -- For vsnip users. - -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'vsnip' }, -- For vsnip users. + { name = 'luasnip' }, -- For luasnip users. -- { name = 'ultisnips' }, -- For ultisnips users. -- { name = 'snippy' }, -- For snippy users. }, { diff --git a/.config/nvim/lua/eddie/lazy.lua b/.config/nvim/lua/eddie/lazy.lua index c4ede77..2677154 100755 --- a/.config/nvim/lua/eddie/lazy.lua +++ b/.config/nvim/lua/eddie/lazy.lua @@ -15,6 +15,11 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' local plugins = { + -- Code highlighting + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, -- Language server configuration { 'neovim/nvim-lspconfig' }, { @@ -33,31 +38,36 @@ local plugins = { { 'hrsh7th/cmp-cmdline' }, -- -- For luasnip users - { 'L3MON4D3/LuaSnip' }, + { + "L3MON4D3/LuaSnip", + dependencies = { "rafamadriz/friendly-snippets" }, + }, { 'saadparwaiz1/cmp_luasnip' }, - { "rafamadriz/friendly-snippets" }, -- Helper package for cmp { - 'nvimtools/none-ls.nvim', - config = function() - require('null-ls').setup({ - - }) - end, - dependencies = { 'nvim-lua/plenary.nvim' }, + 'nvim-lua/plenary.nvim', }, + { 'echasnovski/mini.nvim', version = '*' }, + -- Rust & vim auxiliary packages { "simrat39/rust-tools.nvim" }, - { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - }, { "lervag/vimtex", lazy = false, -- we don't want to lazy load VimTeX -- tag = "v2.15", -- uncomment to pin to a specific release }, - { 'echasnovski/mini.nvim', version = '*' }, + -- Lua auxiliary packages + { + "folke/lazydev.nvim", + ft = "lua", -- only load on lua files + opts = { + library = { + -- See the configuration section for more details + -- Load luvit types when the `vim.uv` word is found + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, + }, + }, -- Minimal { 'nvim-telescope/telescope.nvim', @@ -97,13 +107,22 @@ local plugins = { require('Comment').setup() end }, - -- Colorscheme + -- Colorschemes { "folke/tokyonight.nvim", lazy = false, priority = 1000, opts = {}, }, + { + 'rose-pine/neovim', + name = 'rose-pine', + lazy = false, + priority = 1000, + opts = { + disable_background = true, + }, + }, -- Autoclose parenthesis { 'm4xshen/autoclose.nvim' }, -- tree navigator