From 8459e26e3f6eb5baed2fdb3e2b7506b2e8b5bb45 Mon Sep 17 00:00:00 2001 From: araison Date: Sun, 14 Jan 2024 00:13:31 +0100 Subject: [PATCH] Updating neovim configuration --- nvim/init.lua | 21 +++++++++++++++ nvim/lazy-lock.json | 23 ++++++++++++++++ nvim/lua/plugins.lua | 3 +++ nvim/lua/plugins/autoclose.lua | 5 ++++ nvim/lua/plugins/comment.lua | 47 +++++++++++++++++++++++++++++++++ nvim/lua/plugins/completion.lua | 44 ++++++++++++++++++++++++++++++ nvim/lua/plugins/fugitive.lua | 10 +++++++ nvim/lua/plugins/lsp-config.lua | 35 ++++++++++++++++++++++++ nvim/lua/plugins/lualine.lua | 8 ++++++ nvim/lua/plugins/neotree.lua | 14 ++++++++++ nvim/lua/plugins/none-ls.lua | 14 ++++++++++ nvim/lua/plugins/telescope.lua | 9 +++++++ nvim/lua/plugins/treesitter.lua | 14 ++++++++++ nvim/lua/plugins/vimtex.lua | 9 +++++++ nvim/lua/vim-options.lua | 7 +++++ 15 files changed, 263 insertions(+) create mode 100644 nvim/init.lua create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lua/plugins.lua create mode 100644 nvim/lua/plugins/autoclose.lua create mode 100644 nvim/lua/plugins/comment.lua create mode 100644 nvim/lua/plugins/completion.lua create mode 100644 nvim/lua/plugins/fugitive.lua create mode 100644 nvim/lua/plugins/lsp-config.lua create mode 100644 nvim/lua/plugins/lualine.lua create mode 100644 nvim/lua/plugins/neotree.lua create mode 100644 nvim/lua/plugins/none-ls.lua create mode 100644 nvim/lua/plugins/telescope.lua create mode 100644 nvim/lua/plugins/treesitter.lua create mode 100644 nvim/lua/plugins/vimtex.lua create mode 100644 nvim/lua/vim-options.lua diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..e4ee6e4 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,21 @@ +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("vim-options") +require("lazy").setup("plugins") + + + + + + diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..6ccc91c --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,23 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "82108e7e31cc6fc223cc5df5cae6d89f70bb199f" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "friendly-snippets": { "branch": "main", "commit": "69a2c1675b66e002799f5eef803b87a12f593049" }, + "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, + "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" }, + "none-ls.nvim": { "branch": "main", "commit": "7e146f3a188853843bb4ca1bff24c912bb9b7177" }, + "nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" }, + "nvim-autopairs": { "branch": "master", "commit": "9fd41181693dd4106b3e414a822bb6569924de81" }, + "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-lspconfig": { "branch": "master", "commit": "e47ccfae775f0d572ef0f3a7d245f043b259dafc" }, + "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, + "nvim-web-devicons": { "branch": "master", "commit": "584038666b0d8124d452a2e8ea9e38e6d6e56490" }, + "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, + "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, + "vimtex": { "branch": "master", "commit": "8352d7380a0ea26f9f2ad09e57ccf90b4bd1c746" } +} \ No newline at end of file diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua new file mode 100644 index 0000000..b30bcbd --- /dev/null +++ b/nvim/lua/plugins.lua @@ -0,0 +1,3 @@ +return { + +} diff --git a/nvim/lua/plugins/autoclose.lua b/nvim/lua/plugins/autoclose.lua new file mode 100644 index 0000000..3a794db --- /dev/null +++ b/nvim/lua/plugins/autoclose.lua @@ -0,0 +1,5 @@ +return { + 'windwp/nvim-autopairs', + event = "InsertEnter", + opts = {} -- this is equalent to setup({}) function +} diff --git a/nvim/lua/plugins/comment.lua b/nvim/lua/plugins/comment.lua new file mode 100644 index 0000000..d238339 --- /dev/null +++ b/nvim/lua/plugins/comment.lua @@ -0,0 +1,47 @@ +return { + "numToStr/Comment.nvim", + opts = { + ---Add a space b/w comment and the line + padding = true, + ---Whether the cursor should stay at its position + sticky = true, + ---Lines to be ignored while (un)comment + ignore = nil, + ---LHS of toggle mappings in NORMAL mode + toggler = { + ---Line-comment toggle keymap + line = "gcc", + ---Block-comment toggle keymap + block = "gcc", + }, + ---LHS of operator-pending mappings in NORMAL and VISUAL mode + opleader = { + ---Line-comment keymap + line = "gc", + ---Block-comment keymap + block = "gb", + }, + ---LHS of extra mappings + extra = { + ---Add comment on the line above + above = "gcO", + ---Add comment on the line below + below = "gco", + ---Add comment at the end of line + eol = "gcA", + }, + ---Enable keybindings + ---NOTE: If given `false` then the plugin won't create any mappings + mappings = { + ---Operator-pending mapping; `gcc` `gbc` `gc[count]{motion}` `gb[count]{motion}` + basic = true, + ---Extra mapping; `gco`, `gcO`, `gcA` + extra = true, + }, + ---Function to call before (un)comment + pre_hook = nil, + ---Function to call after (un)comment + post_hook = nil, + }, + lazy = false, +} diff --git a/nvim/lua/plugins/completion.lua b/nvim/lua/plugins/completion.lua new file mode 100644 index 0000000..b42d5cc --- /dev/null +++ b/nvim/lua/plugins/completion.lua @@ -0,0 +1,44 @@ +return { + { + "hrsh7th/cmp-nvim-lsp", + }, + { + "L3MON4D3/LuaSnip", + dependencies = { + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + }, + }, + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, -- For luasnip users. + }, { + { name = "buffer" }, + }), + }) + end, + }, +} diff --git a/nvim/lua/plugins/fugitive.lua b/nvim/lua/plugins/fugitive.lua new file mode 100644 index 0000000..5efee0e --- /dev/null +++ b/nvim/lua/plugins/fugitive.lua @@ -0,0 +1,10 @@ +return { + "tpope/vim-fugitive", + config = function() + vim.keymap.set("n", "gs", "Git", { desc = "Git status" }) + vim.keymap.set("n", "ga", "Gwrite", { desc = "Git add" }) + vim.keymap.set("n", "gc", "Git commit", { desc = "Git commit" }) + vim.keymap.set("n", "gpl", "Git pull", { desc = "Git pull" }) + vim.keymap.set("n", "gp", "15 split|term git push", { desc = "Git push" }) + end, +} diff --git a/nvim/lua/plugins/lsp-config.lua b/nvim/lua/plugins/lsp-config.lua new file mode 100644 index 0000000..ab81764 --- /dev/null +++ b/nvim/lua/plugins/lsp-config.lua @@ -0,0 +1,35 @@ +return { + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end, + }, + { + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls", "texlab", "clangd", "pylsp" }, + }) + end, + }, + { + "neovim/nvim-lspconfig", + config = function() + local lspconfig = require("lspconfig") + local capabilities = require("cmp_nvim_lsp").default_capabilities() + lspconfig.lua_ls.setup({ + capabilities = capabilities, + }) + lspconfig.texlab.setup({ + capabilities = capabilities, + }) + lspconfig.clangd.setup({ + capabilities = capabilities, + }) + lspconfig.pylsp.setup({ + capabilities = capabilities, + }) + end, + }, +} diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..9d7441b --- /dev/null +++ b/nvim/lua/plugins/lualine.lua @@ -0,0 +1,8 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require('lualine').setup() + end +} + diff --git a/nvim/lua/plugins/neotree.lua b/nvim/lua/plugins/neotree.lua new file mode 100644 index 0000000..1d15c2f --- /dev/null +++ b/nvim/lua/plugins/neotree.lua @@ -0,0 +1,14 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = function() + vim.keymap.set("n", 'n',":Neotree toggle",{}) + end +} + + diff --git a/nvim/lua/plugins/none-ls.lua b/nvim/lua/plugins/none-ls.lua new file mode 100644 index 0000000..a6b3f61 --- /dev/null +++ b/nvim/lua/plugins/none-ls.lua @@ -0,0 +1,14 @@ +return { + "nvimtools/none-ls.nvim", + config = function() + local null_ls = require("null-ls") + null_ls.setup({ + sources = { + null_ls.builtins.formatting.stylua, + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.isort, + }, + }) + vim.keymap.set("n", "gf", vim.lsp.buf.format, {}) + end, +} diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..c414967 --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,9 @@ +return { + 'nvim-telescope/telescope.nvim', tag = '0.1.5', + dependencies = { 'nvim-lua/plenary.nvim' }, + config= function() + local builtin = require("telescope.builtin") + vim.keymap.set("n", '',builtin.find_files,{}) + vim.keymap.set("n", 'fg',builtin.live_grep,{}) + end + } diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..de5c1f2 --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,14 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local config = require("nvim-treesitter.configs") + config.setup({ + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "python", "html", "css", "javascript", "latex" }, + sync_install = false, + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, +} diff --git a/nvim/lua/plugins/vimtex.lua b/nvim/lua/plugins/vimtex.lua new file mode 100644 index 0000000..7194730 --- /dev/null +++ b/nvim/lua/plugins/vimtex.lua @@ -0,0 +1,9 @@ +return { + "lervag/vimtex", + config = function() + vim.g.vimtex_view_general_viewer = 'zathura' + vim.g.vimtex_view_automatic = 1 + vim.keymap.set('n','ll',':VimtexCompile') + vim.keymap.set('n','lv',':VimtexView') + end +} diff --git a/nvim/lua/vim-options.lua b/nvim/lua/vim-options.lua new file mode 100644 index 0000000..1b1c7e2 --- /dev/null +++ b/nvim/lua/vim-options.lua @@ -0,0 +1,7 @@ +vim.cmd("set expandtab") +vim.cmd("set tabstop=2") +vim.cmd("set softtabstop=2") +vim.cmd("set shiftwidth=2") +vim.g.mapleader = " " + +