diff options
Diffstat (limited to 'lua')
-rw-r--r-- | lua/core/init.lua | 14 | ||||
-rw-r--r-- | lua/plugins/lsp.lua | 103 |
2 files changed, 103 insertions, 14 deletions
diff --git a/lua/core/init.lua b/lua/core/init.lua index 51c6532..7b47875 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -23,17 +23,3 @@ vim.keymap.set("v", "<s-h>", ":m '<-2<CR>gv=gv") vim.g.netrw_liststyle = 3 vim.g.netrw_banner = 0 vim.g.netrw_bufsettings = "noma nomod nu nobl nowrap ro" - -local function set_git_root_dir() - local git_dir = vim.fn.finddir('.git', '.;') - if git_dir ~= '' then - local git_root = vim.fn.fnamemodify(git_dir, ':h') - vim.cmd('cd ' .. git_root) - end -end - -vim.api.nvim_create_autocmd('VimEnter', { - pattern = '*', - callback = set_git_root_dir -}) - diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..ffb48fa --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,103 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/nvim-cmp", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "j-hui/fidget.nvim", + }, + + config = function() + local cmp = require('cmp') + local cmp_lsp = require("cmp_nvim_lsp") + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + cmp_lsp.default_capabilities()) + + require("fidget").setup({}) + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { + "vimls", + "lua_ls", + + "gopls", + "golangci_lint_ls", + + "sqlls", + "dockerls", + "docker_compose_language_service", + + "graphql", + "yamlls", + + "rust_analyzer", + "clangd", + }, + handlers = { + function(server_name) -- default handler (optional) + + require("lspconfig")[server_name].setup { + capabilities = capabilities + } + end, + + ["lua_ls"] = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup { + capabilities = capabilities, + settings = { + Lua = { + runtime = { version = "Lua 5.1" }, + diagnostics = { + globals = { "vim", "it", "describe", "before_each", "after_each" }, + } + } + } + } + end, + } + }) + + local cmp_select = { behavior = cmp.SelectBehavior.Select } + + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = cmp.mapping.preset.insert({ + ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select), + ['<C-n>'] = cmp.mapping.select_next_item(cmp_select), + ['<C-y>'] = cmp.mapping.confirm({ select = true }), + ["<C-Space>"] = cmp.mapping.complete(), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, + }) + }) + + vim.diagnostic.config({ + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + }) + end +} |