From 5335419073d652eef6ed0898ce2412c2b174f041 Mon Sep 17 00:00:00 2001 From: tiago Date: Fri, 10 Nov 2023 21:15:14 +0000 Subject: [PATCH] nvim lazy conf almost finished --- .config/nvim/tsousa/plugins/colorizer.lua | 6 - .config/nvim/tsousa/plugins/fidget.lua | 5 +- .config/nvim/tsousa/plugins/lspconfig.lua | 157 ++++++++---------- .config/nvim/tsousa/plugins/orgmode.lua | 4 +- .config/nvim/tsousa/plugins/statusline.lua | 45 ----- .config/nvim/tsousa/plugins/telescope.lua | 18 +- .../tsousa/plugins/treesitter-context.lua | 67 ++++---- .config/nvim/tsousa/plugins/undotree.lua | 8 +- .config/nvim/tsousa/plugins/vimtex.lua | 2 - 9 files changed, 126 insertions(+), 186 deletions(-) delete mode 100644 .config/nvim/tsousa/plugins/colorizer.lua delete mode 100644 .config/nvim/tsousa/plugins/statusline.lua delete mode 100644 .config/nvim/tsousa/plugins/vimtex.lua diff --git a/.config/nvim/tsousa/plugins/colorizer.lua b/.config/nvim/tsousa/plugins/colorizer.lua deleted file mode 100644 index 276e879..0000000 --- a/.config/nvim/tsousa/plugins/colorizer.lua +++ /dev/null @@ -1,6 +0,0 @@ -require 'colorizer'.setup({ - 'dosini'; - 'css'; - 'javascript'; - html = { mode = 'background' }; -}) diff --git a/.config/nvim/tsousa/plugins/fidget.lua b/.config/nvim/tsousa/plugins/fidget.lua index 4f1ab35..32e8b71 100644 --- a/.config/nvim/tsousa/plugins/fidget.lua +++ b/.config/nvim/tsousa/plugins/fidget.lua @@ -1 +1,4 @@ -require("fidget").setup() +return { + "j-hui/fidget.nvim", + config = true +} diff --git a/.config/nvim/tsousa/plugins/lspconfig.lua b/.config/nvim/tsousa/plugins/lspconfig.lua index a788704..c917295 100644 --- a/.config/nvim/tsousa/plugins/lspconfig.lua +++ b/.config/nvim/tsousa/plugins/lspconfig.lua @@ -1,97 +1,72 @@ -local present, mason = pcall(require, "mason") +return { + "neovim/nvim-lspconfig", + dependencies = "williamboman/mason-lspconfig.nvim", + config = function() + local mason_lspconfig = require "mason-lspconfig" -vim.api.nvim_create_augroup("_mason", { clear = true }) + mason_lspconfig.setup({ + ensure_installed = {}, + automatic_installation = true + }) -local options = { - PATH = "skip", - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - }, + local opts = { noremap = true, silent = true } + vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) + vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) + vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) + vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) - keymaps = { - toggle_server_expand = "", - install_server = "i", - update_server = "u", - check_server_version = "c", - update_all_servers = "U", - check_outdated_servers = "C", - uninstall_server = "X", - cancel_installation = "", - }, - }, + -- Use an on_attach function to only map the following keys + -- after the language server attaches to the current buffer + local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - max_concurrent_installers = 10, -} - -mason.setup(options) - -local mason_lspconfig = require "mason-lspconfig" - -mason_lspconfig.setup({ - ensure_installed = {}, - automatic_installation = true -}) - - -local opts = { noremap = true, silent = true } -vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) - --- Use an on_attach function to only map the following keys --- after the language server attaches to the current buffer -local on_attach = function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - -- vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'ge', function() vim.diagnostic.goto_next() end, bufopts) - vim.keymap.set('n', 'gE', function() vim.diagnostic.goto_prev() end, bufopts) - vim.keymap.set('n', 'fo', function() vim.lsp.buf.format { async = true } end, bufopts) -end - -local lspconfig = require "lspconfig" - --- ADD NVIM CMP AS A CAPABILITY -local lsp_defaults = lspconfig.util.default_config - -local capabilities = vim.tbl_deep_extend( - 'force', - lsp_defaults.capabilities, - require('cmp_nvim_lsp').default_capabilities() -) - - -mason_lspconfig.setup_handlers { - - -- This is a default handler that will be called for each installed server (also for new servers that are installed during a session) - function(server_name) - lspconfig[server_name].setup { - on_attach = on_attach, - on_init = on_init, - flags = lsp_flags, - capabilities = capabilities, - } - end, + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) + -- vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'ge', function() vim.diagnostic.goto_next() end, bufopts) + vim.keymap.set('n', 'gE', function() vim.diagnostic.goto_prev() end, bufopts) + vim.keymap.set('n', 'fo', function() vim.lsp.buf.format { async = true } end, bufopts) + end + + local lspconfig = require "lspconfig" + + -- ADD NVIM CMP AS A CAPABILITY + local lsp_defaults = lspconfig.util.default_config + + local capabilities = vim.tbl_deep_extend( + 'force', + lsp_defaults.capabilities, + require('cmp_nvim_lsp').default_capabilities() + ) + + + mason_lspconfig.setup_handlers { + + -- This is a default handler that will be called for each installed server (also for new servers that are installed during a session) + function(server_name) + lspconfig[server_name].setup { + on_attach = on_attach, + on_init = on_init, + flags = lsp_flags, + capabilities = capabilities, + } + end, + } + end } diff --git a/.config/nvim/tsousa/plugins/orgmode.lua b/.config/nvim/tsousa/plugins/orgmode.lua index 67563c3..95f9f98 100644 --- a/.config/nvim/tsousa/plugins/orgmode.lua +++ b/.config/nvim/tsousa/plugins/orgmode.lua @@ -19,8 +19,8 @@ return { } require('orgmode').setup({ - org_agenda_files = { '~/Nextcloud/Documents/uni/**/*' }, - org_default_notes_file = '~/Nextcloud/Documents/uni/refile.org', + org_agenda_files = { '~/Nextcloud/org/**/*' }, + org_default_notes_file = '~/Nextcloud/org/refile.org', }) end } diff --git a/.config/nvim/tsousa/plugins/statusline.lua b/.config/nvim/tsousa/plugins/statusline.lua deleted file mode 100644 index b7448f9..0000000 --- a/.config/nvim/tsousa/plugins/statusline.lua +++ /dev/null @@ -1,45 +0,0 @@ -return { - "nvim-lualine/lualine.nvim", - config = function() - require('lualine').setup { - options = { - icons_enabled = true, - theme = 'auto', - component_separators = { left = '', right = '' }, - section_separators = { left = '', right = '' }, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - } - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch', 'diff', 'diagnostics' }, - lualine_c = { 'filename' }, - lualine_x = { 'encoding', 'fileformat', 'filetype' }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { 'filename' }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {} - } - end -} diff --git a/.config/nvim/tsousa/plugins/telescope.lua b/.config/nvim/tsousa/plugins/telescope.lua index 7157164..d4f1f71 100644 --- a/.config/nvim/tsousa/plugins/telescope.lua +++ b/.config/nvim/tsousa/plugins/telescope.lua @@ -1,5 +1,13 @@ -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'sf', builtin.find_files, {}) -vim.keymap.set('n', 'sg', builtin.live_grep, {}) -vim.keymap.set('n', 'sb', builtin.buffers, {}) -vim.keymap.set('n', 'sh', builtin.help_tags, {}) +return { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim" + }, + config = function() + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'sf', builtin.find_files, {}) + vim.keymap.set('n', 'sg', builtin.live_grep, {}) + vim.keymap.set('n', 'sb', builtin.buffers, {}) + vim.keymap.set('n', 'sh', builtin.help_tags, {}) + end +} diff --git a/.config/nvim/tsousa/plugins/treesitter-context.lua b/.config/nvim/tsousa/plugins/treesitter-context.lua index ff04b61..0f4d23d 100644 --- a/.config/nvim/tsousa/plugins/treesitter-context.lua +++ b/.config/nvim/tsousa/plugins/treesitter-context.lua @@ -1,36 +1,37 @@ -function ContextSetup(show_all_context) - require("treesitter-context").setup({ - enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) - throttle = true, -- Throttles plugin updates (may improve performance) - max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. - show_all_context = show_all_context, - patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries. - -- For all filetypes - -- Note that setting an entry here replaces all other patterns for this entry. - -- By setting the 'default' entry below, you can control which nodes you want to - -- appear in the context window. - default = { - "function", - "method", - "for", - "while", - "if", - "switch", - "case", - }, +return { + "romgrk/nvim-treesitter-context", + config = function() + require("treesitter-context").setup({ + enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + throttle = true, -- Throttles plugin updates (may improve performance) + max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + show_all_context = false, + patterns = { -- Match patterns for TS nodes. These get wrapped to match at word boundaries. + -- For all filetypes + -- Note that setting an entry here replaces all other patterns for this entry. + -- By setting the 'default' entry below, you can control which nodes you want to + -- appear in the context window. + default = { + "function", + "method", + "for", + "while", + "if", + "switch", + "case", + }, - rust = { - "loop_expression", - "impl_item", - }, + rust = { + "loop_expression", + "impl_item", + }, - typescript = { - "class_declaration", - "abstract_class_declaration", - "else_clause", + typescript = { + "class_declaration", + "abstract_class_declaration", + "else_clause", + }, }, - }, - }) -end - -ContextSetup(false) + }) + end +} diff --git a/.config/nvim/tsousa/plugins/undotree.lua b/.config/nvim/tsousa/plugins/undotree.lua index b6b9276..4bd3b77 100644 --- a/.config/nvim/tsousa/plugins/undotree.lua +++ b/.config/nvim/tsousa/plugins/undotree.lua @@ -1 +1,7 @@ -vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) +return { + "mbbill/undotree", + config = function() + vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + end + +} diff --git a/.config/nvim/tsousa/plugins/vimtex.lua b/.config/nvim/tsousa/plugins/vimtex.lua deleted file mode 100644 index 9b92de7..0000000 --- a/.config/nvim/tsousa/plugins/vimtex.lua +++ /dev/null @@ -1,2 +0,0 @@ -vim.g.vimtex_view_method = 'zathura' -vim.g.vimtex_compiler_methor = 'latexmk'