diff --git a/nvim/.config/nvim/lua/plugins/cmp.lua b/nvim/.config/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..1da5f0b --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,47 @@ +local cmp = require'cmp' + +cmp.setup({ + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = { + [''] = function(fallback) + if cmp.visible() then + if not cmp.select_next_item() then + if vim.bo.buftype ~= 'prompt' and has_words_before() then + cmp.complete() + else + fallback() + end + end + else + return vim.cmd(">") + end + end, + + [''] = function(fallback) + if cmp.visible() then + if not cmp.select_prev_item() then + if vim.bo.buftype ~= 'prompt' and has_words_before() then + cmp.complete() + else + fallback() + end + end + else + return vim.cmd("<") + end + end, + [''] = cmp.mapping.confirm({ select = true }), + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'buffer' }, + }) +}) diff --git a/nvim/.config/nvim/lua/plugins/diagnostics.lua b/nvim/.config/nvim/lua/plugins/diagnostics.lua new file mode 100644 index 0000000..162b636 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/diagnostics.lua @@ -0,0 +1,34 @@ +local levels = vim.diagnostic.severity + +local opts = { + virtual_text = false, + float = { + border = "rounded", + }, + signs = { + text = { + [levels.ERROR] = '✘', + [levels.WARN] = '▲', + [levels.HINT] = '⚑', + [levels.INFO] = '»', + }, + }, +} + +local sign_define = function(name, text) + local hl = 'DiagnosticSign' .. name + vim.fn.sign_define(hl, { + texthl = hl, + text = text, + numhl = '' + }) +end + +if vim.fn.has('nvim-0.10') == 0 then + sign_define('Error', opts.signs.text[levels.ERROR]) + sign_define('Warn', opts.signs.text[levels.WARN]) + sign_define('Hint', opts.signs.text[levels.HINT]) + sign_define('Info', opts.signs.text[levels.INFO]) +end + +vim.diagnostic.config(opts) diff --git a/nvim/.config/nvim/lua/plugins/init.lua b/nvim/.config/nvim/lua/plugins/init.lua index 014a44f..ffab896 100644 --- a/nvim/.config/nvim/lua/plugins/init.lua +++ b/nvim/.config/nvim/lua/plugins/init.lua @@ -1,7 +1,10 @@ require('plugins.colorscheme') +require('plugins.diagnostics') require('plugins.gitsigns') require('plugins.indent-blankline') require('plugins.nvim-autopairs') require('plugins.nvim-tree') require('plugins.telescope') require('plugins.treesitter') +require('plugins.cmp') +require('plugins.mason') diff --git a/nvim/.config/nvim/lua/plugins/mason.lua b/nvim/.config/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..b88f311 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/mason.lua @@ -0,0 +1,15 @@ +require('mason').setup({}) +require('mason-lspconfig').setup({ + ensure_installed = { + 'lua_ls', + 'ts_ls', + 'html', + 'cssls', + 'jsonls', + }, + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, + }, +})