From 1a8b8b142eeb1072b02bfc355d847825e570a92e Mon Sep 17 00:00:00 2001 From: iliya <iliya.saroukha@hes-so.ch> Date: Sat, 30 Sep 2023 15:06:24 +0200 Subject: [PATCH] config migrated to lazy.nvim --- .gitignore | 2 +- README.md | 39 --- after/plugin/colors.lua | 66 +++++- after/plugin/fugitive.lua | 1 + after/plugin/harpoon.lua | 1 - after/plugin/lsp.lua | 222 ++++++++++++------ after/plugin/lualine.lua | 40 ---- after/plugin/markdown-preview.lua | 26 +- after/plugin/telescope.lua | 41 +++- after/plugin/treesitter.lua | 34 +-- after/plugin/trouble.lua | 55 +++++ init.lua | 17 +- .../autocmd.lua => config/autocmds.lua} | 0 lua/{iliya => config}/init.lua | 7 +- lua/{iliya => config}/remap.lua | 8 +- lua/{iliya => config}/set.lua | 0 lua/iliya/packer.lua | 111 --------- lua/plugins.lua | 160 +++++++++++++ 18 files changed, 519 insertions(+), 311 deletions(-) delete mode 100644 README.md delete mode 100644 after/plugin/lualine.lua create mode 100644 after/plugin/trouble.lua rename lua/{iliya/autocmd.lua => config/autocmds.lua} (100%) rename lua/{iliya => config}/init.lua (52%) rename lua/{iliya => config}/remap.lua (71%) rename lua/{iliya => config}/set.lua (100%) delete mode 100644 lua/iliya/packer.lua create mode 100644 lua/plugins.lua diff --git a/.gitignore b/.gitignore index 6d635cb..e033bc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/plugin +lazy-lock.json diff --git a/README.md b/README.md deleted file mode 100644 index a9ffc91..0000000 --- a/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Config files for Neovim - -## Acknowledgement -This config is based on the one provided by the creator of the _CHAD_ (`Cobol`, -`Haskell`, `Alpine` (linux distro), `Docker`) stack: [@ThePrimeagean](https://www.twitch.tv/ThePrimeagen) - -## Install Neovim - -Follow the instructions given on the following page: [Neovim Wiki](https://github.com/neovim/neovim/wiki/Installing-Neovim) - -## Usage - -### Remove previous installation - -```sh -rm -rf ~/.config/nvim -rm -rf ~/.local/share/nvim -``` - -### Installation - -```sh -git clone https://gitedu.hesge.ch/iliya.saroukha/nvim_config.git ~/.config/nvim -``` - -### Open Neovim - -```sh -nvim . -``` - -After opening NeoVim inside your current directory, run the command below: - -``` -:PackerSync -``` - -Wait for the all the plugins to be installed, then close all the windows -and re-open NeoVim. You should be good to go. **Enjoy the ride!** diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua index ae71108..d3b5b73 100644 --- a/after/plugin/colors.lua +++ b/after/plugin/colors.lua @@ -1,9 +1,61 @@ -function ColorMyPencils(color) - color = color or "rose-pine" - vim.cmd.colorscheme(color) +require('rose-pine').setup({ + --- @usage 'auto'|'main'|'moon'|'dawn' + variant = 'moon', + --- @usage 'main'|'moon'|'dawn' + dark_variant = 'main', + bold_vert_split = false, + dim_nc_background = false, + disable_background = false, + disable_float_background = false, + disable_italics = false, - vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) - vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) -end + --- @usage string hex value or named color from rosepinetheme.com/palette + groups = { + background = 'base', + background_nc = '_experimental_nc', + panel = 'surface', + panel_nc = 'base', + border = 'highlight_med', + comment = 'muted', + link = 'iris', + punctuation = 'subtle', -ColorMyPencils() + error = 'love', + hint = 'iris', + info = 'foam', + warn = 'gold', + + headings = { + h1 = 'iris', + h2 = 'foam', + h3 = 'rose', + h4 = 'gold', + h5 = 'pine', + h6 = 'foam', + } + -- or set all headings at once + -- headings = 'subtle' + }, + + -- Change specific vim highlight groups + -- https://github.com/rose-pine/neovim/wiki/Recipes + highlight_groups = { + Normal = { bg = 'none' }, + NormalFloat = { bg = 'none' }, + ColorColumn = { bg = 'rose' }, + + -- Blend colours against the "base" background + CursorLine = { bg = 'foam', blend = 10 }, + StatusLine = { fg = 'love', bg = 'love', blend = 10 }, + + -- By default each group adds to the existing config. + -- If you only want to set what is written in this config exactly, + -- you can set the inherit option: + Search = { bg = 'gold', inherit = false }, + } +}) + +-- vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) +-- vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) +-- Set colorscheme after options +vim.cmd('colorscheme rose-pine') diff --git a/after/plugin/fugitive.lua b/after/plugin/fugitive.lua index 80c9070..435d82a 100644 --- a/after/plugin/fugitive.lua +++ b/after/plugin/fugitive.lua @@ -1 +1,2 @@ vim.keymap.set("n", "<leader>gs", vim.cmd.Git) + diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua index 268ad25..96eff37 100644 --- a/after/plugin/harpoon.lua +++ b/after/plugin/harpoon.lua @@ -9,4 +9,3 @@ vim.keymap.set("n", "<C-s>", function() ui.nav_file(1) end) vim.keymap.set("n", "<C-x>", function() ui.nav_file(2) end) vim.keymap.set("n", "<C-h>", function() ui.nav_file(3) end) vim.keymap.set("n", "<C-t>", function() ui.nav_file(4) end) - diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 3ad6bc3..3daf0eb 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -1,70 +1,152 @@ -local lsp = require('lsp-zero') - -lsp.preset('recommended') - -lsp.ensure_installed({ - 'clangd', - 'rust_analyzer', -}) - --- Fix Undefined global 'vim' -lsp.nvim_workspace() - -local cmp = require('cmp') -local cmp_select = { behavior = cmp.SelectBehavior.Select } -local cmp_mappings = lsp.defaults.cmp_mappings({ - ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), - ['<C-n>'] = cmp.mapping.select_next_item(cmp_select), - ['<Enter>'] = cmp.mapping.confirm({ select = true }), - ["<C-Space>"] = cmp.mapping.complete(), -}) - -cmp_mappings['<Tab>'] = nil -cmp_mappings['<S-Tab>'] = nil - -lsp.setup_nvim_cmp({ - mapping = cmp_mappings -}) - -lsp.set_preferences({ - suggest_lsp_servers = false, - -- sign_icons = { - -- -- error = 'E', - -- -- warn = 'W', - -- -- hint = 'H', - -- -- info = 'I' - -- -- icons / text used for a diagnostic - -- } -}) - -lsp.set_sign_icons({ - -- icons / text used for a diagnostic - error = "", - warning = "", - hint = "", - information = "", - other = "" -}) - -lsp.on_attach(function(client, bufnr) - local opts = { buffer = bufnr, remap = false } - - vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) - vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) - vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts) - vim.keymap.set("n", "<leader>e", function() vim.diagnostic.open_float() end, opts) - vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) - vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) - vim.keymap.set("n", "<leader>ca", function() vim.lsp.buf.code_action() end, opts) - vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts) - vim.keymap.set("n", "<leader>rn", function() vim.lsp.buf.rename() end, opts) - vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts) -end) - -lsp.setup() - - - -vim.diagnostic.config({ - virtual_text = true -}) +-- [[ Configure LSP ]] +-- This function gets run when an LSP connects to a particular buffer. +local on_attach = function(_, bufnr) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('<leader>wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) +end + +-- document existing key chains +-- require('which-key').register({ +-- ['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' }, +-- ['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, +-- ['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' }, +-- ['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' }, +-- ['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' }, +-- ['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' }, +-- ['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, +-- }) + +-- Enable the following language servers +-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. +-- +-- Add any additional override configuration in the following tables. They will be passed to +-- the `settings` field of the server config. You must look up that documentation yourself. +-- +-- If you want to override the default filetypes that your language server will attach to you can +-- define the property 'filetypes' to the map in question. +local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- tsserver = {}, + -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, +} + +-- Setup neovim lua configuration +require('neodev').setup() + +-- nvim-cmp supports additional completion capabilities, so broadcast that to servers +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + +-- Ensure the servers above are installed +local mason_lspconfig = require 'mason-lspconfig' + +mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), +} + +mason_lspconfig.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + filetypes = (servers[server_name] or {}).filetypes, + } + end +} + +-- [[ Configure nvim-cmp ]] +-- See `:help cmp` +local cmp = require 'cmp' +local luasnip = require 'luasnip' +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + ['<C-n>'] = cmp.mapping.select_next_item(), + ['<C-p>'] = cmp.mapping.select_prev_item(), + ['<C-d>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete {}, + ['<CR>'] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + ['<Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + ['<S-Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua deleted file mode 100644 index a51b983..0000000 --- a/after/plugin/lualine.lua +++ /dev/null @@ -1,40 +0,0 @@ -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 = {} -} diff --git a/after/plugin/markdown-preview.lua b/after/plugin/markdown-preview.lua index eab289c..62afaaf 100644 --- a/after/plugin/markdown-preview.lua +++ b/after/plugin/markdown-preview.lua @@ -60,18 +60,18 @@ vim.mkdp_browserfunc = '' -- content_editable: if enable content editable for preview page, default: false -- disable_filename: if disable filename header for preview page, default: false vim.mkdp_preview_options = { - mkit = {}, - katex = {}, - uml = {}, - maid = {}, - disable_sync_scroll = false, - sync_scroll_type = 'middle', - hide_yaml_meta = true, - sequence_diagrams = {}, - flowchart_diagrams = {}, - content_editable = false, - disable_filename = false, - toc = {} + mkit = {}, + katex = {}, + uml = {}, + maid = {}, + disable_sync_scroll = false, + sync_scroll_type = 'middle', + hide_yaml_meta = true, + sequence_diagrams = {}, + flowchart_diagrams = {}, + content_editable = false, + disable_filename = false, + toc = {} } -- Use a custom markdown style (must be absolute path) @@ -95,4 +95,4 @@ vim.mkdp_filetypes = { 'markdown' } -- Set default theme (dark or light) -- By default the theme is defined according to the preferences of the system -vim.mkdp_theme = 'dark' +vim.mkdp_theme = 'light' diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index ee8e5e9..08984ff 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -1,7 +1,34 @@ -local builtin = require('telescope.builtin') -vim.keymap.set('n', '<leader>pf', builtin.find_files, {}) -vim.keymap.set('n', '<C-p>', builtin.git_files, {}) --- vim.keymap.set('n', '<leader>ps', function() - -- builtin.grep_string({ search = vim.fn.input("Grep > ") }); --- end) -vim.keymap.set('n', '<leader>ps', builtin.grep_string, {}) +-- [[ Configure Telescope ]] +-- See `:help telescope` and `:help telescope.setup()` +require('telescope').setup { + defaults = { + mappings = { + i = { + ['<C-u>'] = false, + ['<C-d>'] = false, + }, + }, + }, +} + +-- Enable telescope fzf native, if installed +pcall(require('telescope').load_extension, 'fzf') + +-- See `:help telescope.builtin` +vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '<leader>/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) +end, { desc = '[/] Fuzzily search in current buffer' }) + +vim.keymap.set('n', '<C-p>', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', '<leader>ff', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua index 4ee6c08..3ea204d 100644 --- a/after/plugin/treesitter.lua +++ b/after/plugin/treesitter.lua @@ -1,21 +1,23 @@ -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" (the five listed parsers should always be installed) - ensure_installed = { "rust", "c", "lua", "vim", "vimdoc", "query" }, +-- [[ Configure Treesitter ]] +-- See `:help nvim-treesitter` +require('nvim-treesitter.configs').setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "rust", "c", "lua", "vim", "vimdoc", "query" }, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, - -- Automatically install missing parsers when entering buffer - -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = true, + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, - highlight = { - enable = true, + highlight = { + enable = true, - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, } diff --git a/after/plugin/trouble.lua b/after/plugin/trouble.lua new file mode 100644 index 0000000..cd4e591 --- /dev/null +++ b/after/plugin/trouble.lua @@ -0,0 +1,55 @@ +-- require('trouble').setup { +-- position = "bottom", -- position of the list can be: bottom, top, left, right +-- height = 10, -- height of the trouble list when position is top or bottom +-- width = 50, -- width of the list when position is left or right +-- icons = true, -- use devicons for filenames +-- mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" +-- severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT +-- fold_open = "", -- icon used for open folds +-- fold_closed = "", -- icon used for closed folds +-- group = true, -- group results by file +-- padding = true, -- add an extra new line on top of the list +-- cycle_results = true, -- cycle item list when reaching beginning or end of list +-- action_keys = { -- key mappings for actions in the trouble list +-- -- map to {} to remove a mapping, for example: +-- -- close = {}, +-- close = "q", -- close the list +-- cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor +-- refresh = "r", -- manually refresh +-- jump = { "<cr>", "<tab>", "<2-leftmouse>" }, -- jump to the diagnostic or open / close folds +-- open_split = { "<c-x>" }, -- open buffer in new split +-- open_vsplit = { "<c-v>" }, -- open buffer in new vsplit +-- open_tab = { "<c-t>" }, -- open buffer in new tab +-- jump_close = { "o" }, -- jump to the diagnostic and close the list +-- toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode +-- switch_severity = "s", -- switch "diagnostics" severity filter level to HINT / INFO / WARN / ERROR +-- toggle_preview = "P", -- toggle auto_preview +-- hover = "K", -- opens a small popup with the full multiline message +-- preview = "p", -- preview the diagnostic location +-- open_code_href = "c", -- if present, open a URI with more information about the diagnostic error +-- close_folds = { "zM", "zm" }, -- close all folds +-- open_folds = { "zR", "zr" }, -- open all folds +-- toggle_fold = { "zA", "za" }, -- toggle fold of current file +-- previous = "k", -- previous item +-- next = "j", -- next item +-- help = "?", -- help menu +-- }, +-- multiline = true, -- render multi-line messages +-- indent_lines = true, -- add an indent guide below the fold icons +-- win_config = { border = "single" }, -- window configuration for floating windows. See |nvim_open_win()|. +-- auto_open = false, -- automatically open the list when you have diagnostics +-- auto_close = false, -- automatically close the list when you have no diagnostics +-- auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window +-- auto_fold = false, -- automatically fold a file trouble list at creation +-- auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result +-- include_declaration = { "lsp_references", "lsp_implementations", "lsp_definitions" }, -- for the given modes, include the declaration of the current symbol in the results +-- signs = { +-- -- icons / text used for a diagnostic +-- error = "", +-- warning = "", +-- hint = "", +-- information = "", +-- other = "", +-- }, +-- use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client +-- } diff --git a/init.lua b/init.lua index 7bb5a60..0c87289 100644 --- a/init.lua +++ b/init.lua @@ -1 +1,16 @@ -require("iliya") +require("config") + +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", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("plugins") diff --git a/lua/iliya/autocmd.lua b/lua/config/autocmds.lua similarity index 100% rename from lua/iliya/autocmd.lua rename to lua/config/autocmds.lua diff --git a/lua/iliya/init.lua b/lua/config/init.lua similarity index 52% rename from lua/iliya/init.lua rename to lua/config/init.lua index 166b5d4..145246d 100644 --- a/lua/iliya/init.lua +++ b/lua/config/init.lua @@ -1,7 +1,6 @@ -require("iliya.remap") -require("iliya.set") -require("iliya.packer") -require("iliya.autocmd") +require("config.set") +require("config.autocmds") +require("config.remap") vim.g.netrw_browse_split = 0 vim.g.netrw_banner = 0 diff --git a/lua/iliya/remap.lua b/lua/config/remap.lua similarity index 71% rename from lua/iliya/remap.lua rename to lua/config/remap.lua index 84f7340..8ff6f2d 100644 --- a/lua/iliya/remap.lua +++ b/lua/config/remap.lua @@ -33,5 +33,11 @@ vim.keymap.set("n", "<leader>t", "<cmd>TroubleToggle<CR>") vim.keymap.set("n", "<leader>mp", "<cmd>MarkdownPreviewToggle<CR>") vim.keymap.set("n", "<leader><leader>", function() - vim.cmd("so") + vim.cmd("so") end) + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) diff --git a/lua/iliya/set.lua b/lua/config/set.lua similarity index 100% rename from lua/iliya/set.lua rename to lua/config/set.lua diff --git a/lua/iliya/packer.lua b/lua/iliya/packer.lua deleted file mode 100644 index 22070ca..0000000 --- a/lua/iliya/packer.lua +++ /dev/null @@ -1,111 +0,0 @@ --- This file can be loaded by calling `lua require('plugins')` from your init.vimpacl - --- Only required if you have packer configured as `opt` -vim.cmd [[packadd packer.nvim]] - -return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - use { - 'nvim-telescope/telescope.nvim', tag = '0.1.1', - -- or , branch = '0.1.x', - requires = { { 'nvim-lua/plenary.nvim' } } - } - - use({ - 'rose-pine/neovim', - as = 'rose-pine', - config = function() - vim.cmd('colorscheme rose-pine') - end - }) - - use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) - use('nvim-treesitter/playground') - - use('theprimeagen/harpoon') - use('mbbill/undotree') - use('tpope/vim-fugitive') - - use 'nvim-tree/nvim-web-devicons' - - - use { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', - requires = { - -- LSP Support - { 'neovim/nvim-lspconfig' }, -- Required - { -- Optional - 'williamboman/mason.nvim', - -- run = function() - -- pcall(vim.cmd, 'MasonUpdate') - -- end, - }, - { 'williamboman/mason-lspconfig.nvim' }, -- Optional - - -- Autocompletion - { 'hrsh7th/nvim-cmp' }, -- Required - { 'hrsh7th/cmp-nvim-lsp' }, -- Required - { 'L3MON4D3/LuaSnip' }, -- Required - } - } - - - use 'ThePrimeagen/vim-be-good' - - use { - 'nvim-lualine/lualine.nvim', - requires = { 'nvim-tree/nvim-web-devicons', opt = true } - } - - use 'mfussenegger/nvim-dap' - - use { - 'numToStr/Comment.nvim', - config = function() - require('Comment').setup() - end - } - - use 'lervag/vimtex' - - use { - "iurimateus/luasnip-latex-snippets.nvim", - -- vimtex isn't required if using treesitter - requires = { "L3MON4D3/LuaSnip", "lervag/vimtex" }, - config = function() - require 'luasnip-latex-snippets'.setup({ use_treesitter = true }) - -- or setup({ use_treesitter = true }) - end, - } - - use { - "danymat/neogen", - config = function() - require('neogen').setup {} - end, - requires = "nvim-treesitter/nvim-treesitter", - -- Uncomment next line if you want to follow only stable versions - -- tag = "*" - } - - use { - "folke/trouble.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }, - } - - use 'NvChad/nvim-colorizer.lua' - - -- install without yarn or npm - use({ - "iamcco/markdown-preview.nvim", - run = function() vim.fn["mkdp#util#install"]() end, - }) -end) diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..35d38e3 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,160 @@ +return { + -- NOTE: First, some plugins that don't require any configuration + + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', + + + + -- NOTE: This is where your plugins related to LSP can be installed. + -- The configuration is done below. Search for lspconfig to find it below. + { + -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, + }, + + { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, + }, + + { + 'rose-pine/neovim', + priority = 1000, + config = function() + vim.cmd.colorscheme 'rose-pine' + end, + }, + + { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + 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, + + }, + }, + }, + + }, + + + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opts = {} }, + + -- Fuzzy Finder (files, lsp, etc) + { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, + }, + + { + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, + build = ':TSUpdate', + }, + + 'theprimeagen/harpoon', + + 'mbbill/undotree', + + { + "danymat/neogen", + config = function() + require('neogen').setup {} + end, + requires = "nvim-treesitter/nvim-treesitter", + -- Uncomment next line if you want to follow only stable versions + -- tag = "*" + }, + + { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + -- opts = { + -- -- your configuration comes here + -- -- or leave it empty to use the default settings + -- -- refer to the configuration section below + -- signs = { + -- -- icons / text used for a diagnostic + -- error = "", + -- warning = "", + -- hint = "", + -- information = "", + -- other = "", + -- }, + -- }, + }, + + 'NvChad/nvim-colorizer.lua', + + + -- install without yarn or npm + { + "iamcco/markdown-preview.nvim", + run = function() vim.fn["mkdp#util#install"]() end, + } + +} -- GitLab