From 30380008b42c148302344eb0e9fa17914d145ecd Mon Sep 17 00:00:00 2001 From: Adam Jeniski Date: Mon, 18 Jul 2022 09:26:47 -0400 Subject: [PATCH] add auto install lsp --- .config/nvim/init.lua | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 2bb5827..b1b708a 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -15,6 +15,7 @@ vim.o.showmatch = true -- highlight matching parentheses / brackets [{ vim.o.laststatus = 2 -- always show statusline (even with only single window) vim.o.ruler = true -- show line and column number of the cursor on right side of statusline vim.o.visualbell = true -- blink cursor on error, instead of beeping +vim.cmd('set invlist') vim.api.nvim_set_keymap("n", "", "(easymotion-bd-jk)", { noremap = true }) @@ -26,7 +27,7 @@ local Plug = vim.fn['plug#'] vim.call('plug#begin', '~/.config/nvim/plugged') -- Editor basics and navigation Plug 'tpope/vim-sensible' -- some good default configs, we love tpope :) - Plug 'tpope/vim-surround' -- add surround motion (s), example: to change the surrounding double quotes to single quotes type: cs"' + Plug 'tpope/vim-surround' -- add surround motion (s), example: to change the surrounding double quotes to single quotes type: cs"' Plug('scrooloose/nerdtree', {on = {'NERDTreeToggle', 'NERDTree'}}) -- file browser Plug 'junegunn/goyo.vim' -- zen mode Plug('junegunn/fzf', {['do'] = vim.fn['fzf#install']}) @@ -38,6 +39,7 @@ vim.call('plug#begin', '~/.config/nvim/plugged') Plug 'nvim-telescope/telescope.nvim' -- fancy fuzzyfinder -- LSP + Plug "williamboman/nvim-lsp-installer" Plug 'neovim/nvim-lspconfig' Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-buffer' @@ -51,7 +53,7 @@ vim.call('plug#begin', '~/.config/nvim/plugged') Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' - -- Lang Support + -- Lang Support Plug 'sheerun/vim-polyglot' Plug 'evanleck/vim-svelte' Plug 'pantharshit00/vim-prisma' @@ -99,8 +101,6 @@ cmp.setup({ { name = 'buffer' } }) }) --- Mappings. --- See `:help vim.diagnostic.*` for documentation on any of the below functions 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) @@ -138,15 +138,17 @@ vim.api.nvim_create_autocmd( { pattern = { "*" }, command = "if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif" } ) -local lsp_flags = { +require("nvim-lsp-installer").setup { + automatic_installation = true } -require('lspconfig')['tsserver'].setup{ + +local lspconfig = require("lspconfig") +lspconfig.sumneko_lua.setup {} +lspconfig.tsserver.setup{ on_attach = on_attach, - flags = lsp_flags, } -require('lspconfig')['rust_analyzer'].setup{ +lspconfig.rust_analyzer.setup{ on_attach = on_attach, - flags = lsp_flags, -- Server-specific settings... settings = { @@ -155,11 +157,8 @@ require('lspconfig')['rust_analyzer'].setup{ } require('lspconfig')['svelte'].setup{ on_attach = on_attach, - flags = lsp_flags } - - -- fuzzy finder config local telescope = require("telescope") local actions = require("telescope.actions") @@ -175,6 +174,9 @@ telescope.setup({ [""] = actions.close, }, }, + file_ignore_patterns = { + "node_modules" + } }, pickers = {}, extensions = {}, @@ -182,21 +184,26 @@ telescope.setup({ -- keymaps local opts = { noremap=true, silent=true } -vim.keymap.set("n", "", ":wa:echo 'File saved.'") +local loudOpts = { noremap=true } +vim.keymap.set("n", "", ":wa:echo 'File saved.'", loudOpts) vim.keymap.set("n", "", ":NERDTreeToggle", opts) vim.keymap.set("n", "tt", ":TransparentToggle", opts) +vim.keymap.set("n", "tz", ":Goyo 150", opts) +vim.keymap.set("n", "tr", ":set relativenumber!") +vim.keymap.set("n", "ti", ":set invlist!") vim.keymap.set("n", "gt", ":bn", opts) vim.keymap.set("n", "gT", ":bp", opts) vim.keymap.set("n", "", ":nohlsearch", opts) vim.keymap.set("n", "ff", ":Telescope find_files", opts) +vim.keymap.set('n', 'fk', ':Telescope keymaps', opts) vim.keymap.set("n", "", ":Telescope find_files", opts) vim.keymap.set("n", "fg", ":Telescope live_grep", opts) vim.keymap.set("n", "fb", ":Telescope buffers", opts) vim.keymap.set("n", "fh", ":Telescope help_tags", opts) vim.keymap.set("n", "", "", opts) vim.keymap.set("i", "", "", opts) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +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) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts)