-- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth',
+
-- NOTE: This is where your plugins related to LSP can be installed.
-- The configuration is done below. Search for lspconfig to find it below.
{
'hrsh7th/nvim-cmp',
dependencies = {
'hrsh7th/cmp-nvim-lsp',
- {'L3MON4D3/LuaSnip', version = "2.*", build = "make install_jsregexp"},
+ { 'L3MON4D3/LuaSnip', version = "2.*", build = "make install_jsregexp" },
'saadparwaiz1/cmp_luasnip',
'rafamadriz/friendly-snippets'
},
},
},
}
-
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<F8>', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
+
+vim.keymap.set("n", "<Leader>f", function()
+ vim.lsp.buf.format({ timeout = 10000, bufnr = vim.api.nvim_get_current_buf() })
+end)
-- LSP settings.
-- This function gets run when an LSP connects to a particular buffer.
-local on_attach = function(_, bufnr)
+local on_attach = function(client, bufnr)
-- NOTE: Remember that lua is a real programming language, and as such it is possible
-- to define small helper and utility functions so you don't have to repeat yourself
-- many times.
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
+ vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
+ else
+ vim.keymap.set('n', keys, func, { buffer = bufnr })
end
-
- vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
+
+
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- pyright = {},
-- rust_analyzer = {},
tsserver = {},
+ eslint = {},
+ tailwindcss = {},
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
}
-
-
-
local null_ls = require("null-ls")
local group = vim.api.nvim_create_augroup("lsp_format_on_save", { clear = false })
local async = event == "BufWritePost"
null_ls.setup({
- on_attach = function(client, bufnr)
- if client.supports_method("textDocument/formatting") then
- vim.keymap.set("n", "<Leader>f", function()
- vim.lsp.buf.format({ timeout = 10000, bufnr = vim.api.nvim_get_current_buf() })
- end, { buffer = bufnr, desc = "[lsp] format" })
-
- -- -- format on save
- -- vim.api.nvim_clear_autocmds({ buffer = bufnr, group = group })
- -- vim.api.nvim_create_autocmd(event, {
- -- buffer = bufnr,
- -- group = group,
- -- callback = function()
- -- vim.lsp.buf.format({ bufnr = bufnr, async = async })
- -- end,
- -- desc = "[lsp] format on save",
- -- })
- end
-
- if client.supports_method("textDocument/rangeFormatting") then
- vim.keymap.set("x", "<Leader>f", function()
- vim.lsp.buf.format({ bufnr = vim.api.nvim_get_current_buf() })
- end, { buffer = bufnr, desc = "[lsp] format" })
- end
- end,
+ timeout = 2000,
+ on_attach = on_attach
})