Created
November 8, 2023 15:33
-
-
Save JakWai01/b94079b6fcae15b65b0532d65d553052 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| vim.g.mapleader = ' ' | |
| require("lazy").setup({ | |
| 'rmehri01/onenord.nvim', | |
| "neovim/nvim-lspconfig", | |
| "hrsh7th/nvim-cmp", | |
| "hrsh7th/cmp-nvim-lsp", | |
| "hrsh7th/cmp-vsnip", | |
| "hrsh7th/cmp-path", | |
| "hrsh7th/cmp-buffer", | |
| "hrsh7th/vim-vsnip", | |
| "simrat39/rust-tools.nvim", | |
| "itchyny/lightline.vim", | |
| "nvim-telescope/telescope.nvim", | |
| 'nvim-lua/plenary.nvim', | |
| 'nvim-treesitter/nvim-treesitter', | |
| }) | |
| require('onenord').setup() | |
| -- LSP CONFIGURATION | |
| -- Set completeopt to have a better completion experience | |
| -- :help completeopt | |
| -- menuone: popup even when there's only one match | |
| -- noinsert: Do not insert text until a selection is made | |
| -- noselect: Do not auto-select, nvim-cmp plugin will handle this for us. | |
| vim.o.completeopt = "menuone,noinsert,noselect" | |
| -- Avoid showing extra messages when using completion | |
| vim.opt.shortmess = vim.opt.shortmess + "c" | |
| local function on_attach(client, buffer) | |
| local keymap_opts = { buffer = buffer } | |
| -- Code navigation and shortcuts | |
| vim.keymap.set("n", "<c-]>", vim.lsp.buf.definition, keymap_opts) | |
| vim.keymap.set("n", "K", vim.lsp.buf.hover, keymap_opts) | |
| vim.keymap.set("n", "gD", vim.lsp.buf.implementation, keymap_opts) | |
| vim.keymap.set("n", "<c-k>", vim.lsp.buf.signature_help, keymap_opts) | |
| vim.keymap.set("n", "1gD", vim.lsp.buf.type_definition, keymap_opts) | |
| vim.keymap.set("n", "gr", vim.lsp.buf.references, keymap_opts) | |
| vim.keymap.set("n", "g0", vim.lsp.buf.document_symbol, keymap_opts) | |
| vim.keymap.set("n", "gW", vim.lsp.buf.workspace_symbol, keymap_opts) | |
| vim.keymap.set("n", "gd", vim.lsp.buf.definition, keymap_opts) | |
| end | |
| -- Configure LSP through rust-tools.nvim plugin. | |
| -- rust-tools will configure and enable certain LSP features for us. | |
| -- See https://github.com/simrat39/rust-tools.nvim#configuration | |
| local opts = { | |
| tools = { | |
| runnables = { | |
| use_telescope = true, | |
| }, | |
| inlay_hints = { | |
| auto = true, | |
| show_parameter_hints = false, | |
| parameter_hints_prefix = "", | |
| other_hints_prefix = "", | |
| }, | |
| }, | |
| -- all the opts to send to nvim-lspconfig | |
| -- these override the defaults set by rust-tools.nvim | |
| -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer | |
| server = { | |
| -- on_attach is a callback called when the language server attachs to the buffer | |
| on_attach = on_attach, | |
| settings = { | |
| -- to enable rust-analyzer settings visit: | |
| -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc | |
| ["rust-analyzer"] = { | |
| -- enable clippy on save | |
| checkOnSave = { | |
| command = "clippy", | |
| }, | |
| }, | |
| }, | |
| }, | |
| } | |
| require("rust-tools").setup(opts) | |
| -- Setup Completion | |
| -- See https://github.com/hrsh7th/nvim-cmp#basic-configuration | |
| local cmp = require("cmp") | |
| cmp.setup({ | |
| preselect = cmp.PreselectMode.None, | |
| snippet = { | |
| expand = function(args) | |
| vim.fn["vsnip#anonymous"](args.body) | |
| end, | |
| }, | |
| mapping = { | |
| ["<C-p>"] = cmp.mapping.select_prev_item(), | |
| ["<C-n>"] = cmp.mapping.select_next_item(), | |
| -- Add tab support | |
| ["<S-Tab>"] = cmp.mapping.select_prev_item(), | |
| ["<Tab>"] = cmp.mapping.select_next_item(), | |
| ["<C-d>"] = cmp.mapping.scroll_docs(-4), | |
| ["<C-f>"] = cmp.mapping.scroll_docs(4), | |
| ["<C-Space>"] = cmp.mapping.complete(), | |
| ["<C-e>"] = cmp.mapping.close(), | |
| ["<CR>"] = cmp.mapping.confirm({ | |
| behavior = cmp.ConfirmBehavior.Insert, | |
| select = true, | |
| }), | |
| }, | |
| -- Installed sources | |
| sources = { | |
| { name = "nvim_lsp" }, | |
| { name = "vsnip" }, | |
| { name = "path" }, | |
| { name = "buffer" }, | |
| }, | |
| }) | |
| vim.opt.nu = true | |
| vim.opt.relativenumber = true | |
| vim.opt.tabstop = 4 | |
| vim.opt.softtabstop = 4 | |
| vim.opt.shiftwidth = 4 | |
| vim.opt.expandtab = true | |
| vim.opt.smartindent = true | |
| vim.opt.wrap = false | |
| vim.opt.swapfile = false | |
| vim.opt.backup = false | |
| vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" | |
| vim.opt.undofile = true | |
| vim.opt.hlsearch = false | |
| vim.opt.incsearch = true | |
| vim.opt.termguicolors = true | |
| vim.opt.scrolloff = 8 | |
| vim.opt.signcolumn = "yes" | |
| vim.opt.isfname:append("@-@") | |
| vim.opt.updatetime = 50 | |
| vim.opt.colorcolumn = "80" | |
| vim.opt_global.nu = true | |
| vim.opt_global.relativenumber = true | |
| vim.opt_global.tabstop = 4 | |
| vim.opt_global.softtabstop = 4 | |
| vim.opt_global.shiftwidth = 4 | |
| vim.opt_global.expandtab = true | |
| vim.opt_global.smartindent = true | |
| vim.opt_global.wrap = false | |
| vim.opt_global.swapfile = false | |
| vim.opt_global.backup = false | |
| vim.opt_global.undodir = os.getenv("HOME") .. "/.vim/undodir" | |
| vim.opt_global.undofile = true | |
| vim.opt_global.hlsearch = false | |
| vim.opt_global.incsearch = true | |
| vim.opt_global.termguicolors = true | |
| vim.opt_global.scrolloff = 8 | |
| vim.opt_global.signcolumn = "yes" | |
| vim.opt_global.isfname:append("@-@") | |
| vim.opt_global.updatetime = 50 | |
| vim.opt_global.colorcolumn = "80" | |
| local builtin = require('telescope.builtin') | |
| vim.keymap.set('n', '<leader>ff', builtin.find_files, {}) | |
| vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) | |
| vim.keymap.set('n', '<leader>fb', builtin.buffers, {}) | |
| vim.keymap.set('n', '<leader>fh', builtin.help_tags, {}) | |
| require'lspconfig'.texlab.setup{} | |
| require'lspconfig'.gopls.setup{} | |
| require'lspconfig'.pylsp.setup{ | |
| settings = { | |
| pylsp = { | |
| plugins = { | |
| pycodestyle = { | |
| ignore = {'W391'}, | |
| maxLineLength = 100 | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment