diff --git a/nvim/after/plugin/lsp.lua b/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..e097f79 --- /dev/null +++ b/nvim/after/plugin/lsp.lua @@ -0,0 +1,67 @@ +local lsp = require("lsp-zero") + +lsp.preset("recommended") + +lsp.ensure_installed({ + 'tsserver', + 'rust_analyzer', +}) + +-- Fix Undefined global 'vim' +lsp.configure('lua-language-server', { + settings = { + Lua = { + diagnostics = { + globals = { 'vim' } + } + } + } +}) + + +local cmp = require('cmp') +local cmp_select = {behavior = cmp.SelectBehavior.Select} +local cmp_mappings = lsp.defaults.cmp_mappings({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), +}) + +cmp_mappings[''] = nil +cmp_mappings[''] = 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' + } +}) + +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", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", 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", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) +end) + +lsp.setup() + +vim.diagnostic.config({ + virtual_text = true +}) \ No newline at end of file diff --git a/nvim/lua/luke-else/init.lua b/nvim/lua/luke-else/init.lua index 33dc0a4..7c556a7 100644 --- a/nvim/lua/luke-else/init.lua +++ b/nvim/lua/luke-else/init.lua @@ -1 +1,2 @@ -require("luke-else.packer") \ No newline at end of file +require("luke-else.packer") +require("lua.luke-else.set") \ No newline at end of file diff --git a/nvim/lua/luke-else/packer.lua b/nvim/lua/luke-else/packer.lua index c414105..fcb080a 100644 --- a/nvim/lua/luke-else/packer.lua +++ b/nvim/lua/luke-else/packer.lua @@ -23,4 +23,27 @@ return require('packer').startup(function(use) use("mbbill/undotree") use("tpope/vim-fugitive") + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v1.x', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'saadparwaiz1/cmp_luasnip'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/cmp-nvim-lua'}, + + -- Snippets + {'L3MON4D3/LuaSnip'}, + {'rafamadriz/friendly-snippets'}, + } + } + end) \ No newline at end of file diff --git a/nvim/lua/luke-else/set.lua b/nvim/lua/luke-else/set.lua new file mode 100644 index 0000000..736d2ad --- /dev/null +++ b/nvim/lua/luke-else/set.lua @@ -0,0 +1,29 @@ +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"