summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lazy-lock.json12
-rw-r--r--lua/plugins/lsp.lua136
2 files changed, 148 insertions, 0 deletions
diff --git a/lazy-lock.json b/lazy-lock.json
index 8e33aad..a70961f 100644
--- a/lazy-lock.json
+++ b/lazy-lock.json
@@ -1,5 +1,17 @@
{
+ "LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" },
+ "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
+ "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
+ "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
+ "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
+ "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
+ "conform.nvim": { "branch": "master", "commit": "cde4da5c1083d3527776fee69536107d98dae6c9" },
+ "fidget.nvim": { "branch": "main", "commit": "e32b672d8fd343f9d6a76944fedb8c61d7d8111a" },
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
+ "mason-lspconfig.nvim": { "branch": "main", "commit": "b1d9a914b02ba5660f1e272a03314b31d4576fe2" },
+ "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" },
+ "nvim-cmp": { "branch": "main", "commit": "106c4bcc053a5da783bf4a9d907b6f22485c2ea0" },
+ "nvim-lspconfig": { "branch": "master", "commit": "c8503e63c6afab3ed34b49865a4a4edbb1ebf4a8" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-treesitter-context": { "branch": "master", "commit": "660861b1849256398f70450afdf93908d28dc945" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua
new file mode 100644
index 0000000..f106401
--- /dev/null
+++ b/lua/plugins/lsp.lua
@@ -0,0 +1,136 @@
+local root_files = {
+ '.luarc.json',
+ '.luarc.jsonc',
+ '.luacheckrc',
+ '.stylua.toml',
+ 'stylua.toml',
+ 'selene.toml',
+ 'selene.yml',
+ '.git',
+}
+
+return {
+ "neovim/nvim-lspconfig",
+ dependencies = {
+ "stevearc/conform.nvim",
+ "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()
+ require("conform").setup({
+ formatters_by_ft = {
+ }
+ })
+ 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 = {
+ "lua_ls",
+ "rust_analyzer",
+ "tailwindcss",
+ },
+ handlers = {
+ function(server_name) -- default handler (optional)
+ require("lspconfig")[server_name].setup {
+ capabilities = capabilities
+ }
+ end,
+
+ zls = function()
+ local lspconfig = require("lspconfig")
+ lspconfig.zls.setup({
+ root_dir = lspconfig.util.root_pattern(".git", "build.zig", "zls.json"),
+ settings = {
+ zls = {
+ enable_inlay_hints = true,
+ enable_snippets = true,
+ warn_style = true,
+ },
+ },
+ })
+ vim.g.zig_fmt_parse_errors = 0
+ vim.g.zig_fmt_autosave = 0
+
+ end,
+ ["lua_ls"] = function()
+ local lspconfig = require("lspconfig")
+ lspconfig.lua_ls.setup {
+ capabilities = capabilities,
+ settings = {
+ Lua = {
+ format = {
+ enable = true,
+ -- Put format options here
+ -- NOTE: the value should be STRING!!
+ defaultConfig = {
+ indent_style = "space",
+ indent_size = "2",
+ }
+ },
+ }
+ }
+ }
+ end,
+ ["tailwindcss"] = function()
+ local lspconfig = require("lspconfig")
+ lspconfig.tailwindcss.setup({
+ capabilities = capabilities,
+ filetypes = { "html", "css", "scss", "javascript", "javascriptreact", "typescript", "typescriptreact", "vue", "svelte", "heex" },
+ })
+ 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 = "copilot", group_index = 2 },
+ { name = 'nvim_lsp' },
+ { name = 'luasnip' }, -- For luasnip users.
+ }, {
+ { name = 'buffer' },
+ })
+ })
+
+ vim.diagnostic.config({
+ -- update_in_insert = true,
+ float = {
+ focusable = false,
+ style = "minimal",
+ border = "rounded",
+ source = "always",
+ header = "",
+ prefix = "",
+ },
+ })
+ end
+}