From 3cb0415ed3d9aeaaacbcd490a9b63184e3e4728a Mon Sep 17 00:00:00 2001 From: Andy Teijelo Date: Tue, 16 Aug 2022 15:23:30 -0400 Subject: [PATCH] themes, cursor shape, lsp, completion, snippets --- init.lua | 125 +++++++++++++++++++++++++++++++++++++++++++++++- lua/plugins.lua | 21 +++++--- 2 files changed, 139 insertions(+), 7 deletions(-) diff --git a/init.lua b/init.lua index a46a573..5b634e2 100644 --- a/init.lua +++ b/init.lua @@ -23,6 +23,17 @@ vim.opt.hlsearch = true --incsearch vim.cmd([[highlight ColorColumn ctermbg=9]]) +-- don't use NeoVim's thin cursor +vim.opt.guicursor = "" + +vim.g.tokyonight_style = "night" +vim.cmd([[colorscheme tokyonight]]) +--vim.cmd([[colorscheme PaperColor]]) +--vim.cmd([[colorscheme moonfly]]) + +vim.api.nvim_set_keymap("n", "", "", { noremap = true }) +vim.g.mapleader = " " + for _, mode in ipairs({"n", "i"}) do vim.api.nvim_set_keymap(mode, "", "g", { noremap = true }) vim.api.nvim_set_keymap(mode, "", "g", { noremap = true }) @@ -32,8 +43,120 @@ for _, mode in ipairs({"n", "i"}) do vim.api.nvim_set_keymap(mode, "", "", { noremap = true }) end +vim.api.nvim_set_keymap("n", "o", "lua vim.diagnostic.open_float()", { noremap = true }) + require('plugins') -require'lspconfig'.pyright.setup{} +-- require'lspconfig'.pyright.setup{} +local nvim_lsp = require'lspconfig' +nvim_lsp.pyright.setup{} + +-- local on_attach = function(client) +-- require'completion'.on_attach(client) +-- end + + +-- require('snippy').setup({ +-- mappings = { +-- is = { +-- [''] = 'expand_or_advance', +-- [''] = 'previous', +-- }, +-- nx = { +-- ['x'] = 'cut_text', +-- }, +-- }, +-- }) + +local cmp = require'cmp' +local snippy = require('snippy') + +cmp.setup({ + + snippet = { + expand = function(args) + snippy.expand_snippet(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(), + -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif snippy.can_expand_or_advance() then + snippy.expand_or_advance() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif snippy.can_jump(-1) then + snippy.previous() + else + fallback() + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'snippy' }, + { name = 'buffer' }, + }) +}) + +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +nvim_lsp.rust_analyzer.setup({ + capabilities = capabilities, + settings = { + ["rust-analyzer"] = { + } + } +}) + +vim.diagnostic.config({ + underline = true, + signs = true, + virtual_text = true, + float = { + show_header = true, + source = 'if_many', + border = 'rounded', + focusable = false, + } +}) + +-- -- trouble.nvim mappings +-- vim.api.nvim_set_keymap("n", "xx", "Trouble", +-- {silent = true, noremap = true} +-- ) +-- vim.api.nvim_set_keymap("n", "xw", "Trouble workspace_diagnostics", +-- {silent = true, noremap = true} +-- ) +-- vim.api.nvim_set_keymap("n", "xd", "Trouble document_diagnostics", +-- {silent = true, noremap = true} +-- ) +-- vim.api.nvim_set_keymap("n", "xl", "Trouble loclist", +-- {silent = true, noremap = true} +-- ) +-- vim.api.nvim_set_keymap("n", "xq", "Trouble quickfix", +-- {silent = true, noremap = true} +-- ) +-- vim.api.nvim_set_keymap("n", "gR", "Trouble lsp_references", +-- {silent = true, noremap = true} +-- ) + + -- original init.vim diff --git a/lua/plugins.lua b/lua/plugins.lua index 932ef9e..5ad181a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -2,9 +2,18 @@ vim.cmd [[packadd packer.nvim]] local packer = require('packer') -packer.startup(function(use) - use 'wbthomason/packer.nvim' - use 'neovim/nvim-lspconfig' - use 'mg979/vim-visual-multi' - use 'farmergreg/vim-lastplace' -end) +packer.startup( + function(use) + use 'wbthomason/packer.nvim' + use 'neovim/nvim-lspconfig' + use 'mg979/vim-visual-multi' + use 'farmergreg/vim-lastplace' + use 'hrsh7th/cmp-nvim-lsp' + use 'hrsh7th/nvim-cmp' + use 'dcampos/nvim-snippy' + use 'dcampos/cmp-snippy' + use 'folke/tokyonight.nvim' + use 'bluz71/vim-moonfly-colors' + use 'NLKNguyen/papercolor-theme' + end +)