193 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			193 lines
		
	
	
		
			5.1 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
| local opts = { noremap = true, silent = true }
 | |
| vim.keymap.set('n', '<space>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)
 | |
| 
 | |
| local lsp_attach = function(client, buf)
 | |
| 	vim.api.nvim_buf_set_option(buf, "formatexpr", "v:lua.vim.lsp.formatexpr()")
 | |
| 	vim.api.nvim_buf_set_option(buf, "omnifunc", "v:lua.vim.lsp.omnifunc")
 | |
| 	vim.api.nvim_buf_set_option(buf, "tagfunc", "v:lua.vim.lsp.tagfunc")
 | |
| 
 | |
| 	local bufopts = { noremap = true, silent = true, buffer = buf }
 | |
| 	vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
 | |
| 	vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
 | |
| 	vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
 | |
| 	vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
 | |
| 	vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
 | |
| 	vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
 | |
| 	vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
 | |
| 	vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
 | |
| 	vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
 | |
| end
 | |
| 
 | |
| return {
 | |
| 	-- lsp
 | |
| 	{
 | |
| 		'williamboman/mason.nvim',
 | |
| 		config = true
 | |
| 	},
 | |
| 	{
 | |
| 		'williamboman/mason-lspconfig.nvim',
 | |
| 		config = true
 | |
| 	},
 | |
| 	{
 | |
| 		'neovim/nvim-lspconfig',
 | |
| 		config = function()
 | |
| 			local capabilities = require('cmp_nvim_lsp').default_capabilities()
 | |
| 			local lspconfig = require('lspconfig')
 | |
| 
 | |
| 			lspconfig.lua_ls.setup {
 | |
| 				capabilities = capabilities,
 | |
| 				settings = {
 | |
| 					Lua = {
 | |
| 						diagnostics = {
 | |
| 							globals = { 'vim' }
 | |
| 						}
 | |
| 					}
 | |
| 				},
 | |
| 				on_attach = lsp_attach
 | |
| 			}
 | |
| 			lspconfig.tsserver.setup {
 | |
| 				capabilities = capabilities,
 | |
| 				on_attach = lsp_attach
 | |
| 			}
 | |
| 			lspconfig.gopls.setup {
 | |
| 				capabilities = capabilities,
 | |
| 				on_attach = lsp_attach
 | |
| 			}
 | |
| 			--lspconfig.rust_analyzer.setup {
 | |
| 			--	capabilities = capabilities,
 | |
| 			--	on_attach = lsp_attach
 | |
| 			--}
 | |
| 			require("rust-tools").setup({
 | |
| 				server = {
 | |
| 					capabilities = capabilities,
 | |
| 					on_attach = lsp_attach,
 | |
| 					standalone = false
 | |
| 				}
 | |
| 			})
 | |
| 			lspconfig.bashls.setup {
 | |
| 				capabilities = capabilities,
 | |
| 				on_attach = lsp_attach
 | |
| 			}
 | |
| 			lspconfig.sqlls.setup({
 | |
| 				capabilities = capabilities,
 | |
| 				on_attach = lsp_attach
 | |
| 			})
 | |
| 			lspconfig.html.setup({
 | |
| 				capabilities = capabilities,
 | |
| 				on_attach = lsp_attach
 | |
| 			})
 | |
| 			lspconfig.cssls.setup({
 | |
| 				capabilities = capabilities,
 | |
| 				on_attach = lsp_attach
 | |
| 			})
 | |
| 			lspconfig.tailwindcss.setup({
 | |
| 				capabilities = capabilities,
 | |
| 				on_attach = lsp_attach
 | |
| 			})
 | |
| 			capabilities.textDocument.completion.completionItem.snippetSupport = true
 | |
| 			lspconfig.emmet_ls.setup({
 | |
| 				capabilities = capabilities,
 | |
| 				on_attach = lsp_attach
 | |
| 			})
 | |
| 		end
 | |
| 	},
 | |
| 	{ 'simrat39/rust-tools.nvim' },
 | |
| 	{ 'onsails/lspkind-nvim' }, -- pictograms replace (?) with lspsaga
 | |
| 	{ 'j-hui/fidget.nvim' }, -- show lsp status
 | |
| 	-- completion
 | |
| 	{
 | |
| 		'hrsh7th/nvim-cmp',
 | |
| 		config = function() 
 | |
| 			local cmp = require('cmp')
 | |
| 			local lspkind = require('lspkind')
 | |
| 
 | |
| 			vim.opt.shortmess:append 'c'
 | |
| 
 | |
| 			cmp.setup({
 | |
| 				snippet = {
 | |
| 					expand = function(args)
 | |
| 						require('luasnip').lsp_expand(args.body)
 | |
| 					end,
 | |
| 				},
 | |
| 				mapping = cmp.mapping.preset.insert({
 | |
| 					["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
 | |
| 					["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
 | |
| 					['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
 | |
| 					['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
 | |
| 					['<C-s>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
 | |
| 					['<C-y>'] = cmp.mapping.confirm({
 | |
| 						behavior = cmp.ConfirmBehavior.Insert,
 | |
| 						select = true
 | |
| 					}),
 | |
| 					['<C-e>'] = cmp.mapping({
 | |
| 						i = cmp.mapping.abort(),
 | |
| 						c = cmp.mapping.close(),
 | |
| 					}),
 | |
| 					['<CR>'] = cmp.mapping.confirm({ select = true }),
 | |
| 				}),
 | |
| 				sources = cmp.config.sources({
 | |
| 					{ name = 'nvim_lua' },
 | |
| 					{ name = 'nvim_lsp' },
 | |
| 					{ name = 'path' },
 | |
| 					{ name = 'luasnip' },
 | |
| 					{ name = 'nvim_lsp_signature_help' },
 | |
| 					}, {
 | |
| 						{ name = 'buffer', keyword_length = 5 },
 | |
| 				}),
 | |
| 				formatting = {
 | |
| 					format = lspkind.cmp_format {
 | |
| 						with_text = true,
 | |
| 						menu = {
 | |
| 							buffer = "[buf]",
 | |
| 							nvim_lsp = "[LSP]",
 | |
| 							nvim_lua = "[api]",
 | |
| 							path = "[path]",
 | |
| 							luasnip = "[snip]",
 | |
| 						}
 | |
| 					}
 | |
| 				}
 | |
| 			})
 | |
| 
 | |
| 			-- Use buffer source for `/` (basically search words in buffer)
 | |
| 			cmp.setup.cmdline('/', {
 | |
| 				sources = {
 | |
| 					{ name = 'buffer' }
 | |
| 				}
 | |
| 			})
 | |
| 
 | |
| 			-- Use cmdline & path source for ':'
 | |
| 			cmp.setup.cmdline(':', {
 | |
| 				sources = cmp.config.sources({
 | |
| 					{ name = 'path' }
 | |
| 					}, {
 | |
| 						{ name = 'cmdline' }
 | |
| 				})
 | |
| 			})
 | |
| 		end,
 | |
| 		event = 'InsertEnter',
 | |
| 		dependencies = {
 | |
| 			'hrsh7th/cmp-nvim-lsp',
 | |
| 			'hrsh7th/cmp-nvim-lsp-signature-help',
 | |
| 			'hrsh7th/cmp-buffer',
 | |
| 			'hrsh7th/cmp-path',
 | |
| 			'hrsh7th/cmp-nvim-lua',
 | |
| 			'hrsh7th/cmp-cmdline',
 | |
| 			'saadparwaiz1/cmp_luasnip',
 | |
| 		}
 | |
| 	},
 | |
| 	{
 | |
| 		'L3MON4D3/LuaSnip',
 | |
| 		config = function()
 | |
| 			require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" })
 | |
| 		end
 | |
| 	},
 | |
| 	{
 | |
| 		'windwp/nvim-autopairs',
 | |
| 		config = true
 | |
| 	},
 | |
| }
 | |
| --	-- Linting & formtatting
 | |
| --	'jose-elias-alvarez/null-ls.nvim';
 |