Try configuring language servers
This commit is contained in:
@@ -1,15 +1,64 @@
|
||||
-----------------------------------------------------------
|
||||
-- Conform.nvim Formatter Configuration
|
||||
-----------------------------------------------------------
|
||||
|
||||
local options = {
|
||||
-- Disable LSP formatting fallback
|
||||
lsp_fallback = false,
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Formatter Assignments by File Type
|
||||
-----------------------------------------------------------
|
||||
formatters_by_ft = {
|
||||
-- Lua
|
||||
lua = { "stylua" },
|
||||
-- css = { "prettier" },
|
||||
-- html = { "prettier" },
|
||||
|
||||
-- Web Development
|
||||
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
typescript = { "prettierd", "prettier", stop_after_first = true },
|
||||
typescriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||
astro = { "prettierd", "prettier", stop_after_first = true },
|
||||
svelte = { "prettierd", "prettier", stop_after_first = true },
|
||||
html = { "prettierd", "prettier", stop_after_first = true },
|
||||
css = { "prettierd", "prettier", stop_after_first = true },
|
||||
json = { "prettierd" },
|
||||
yml = { "prettierd", "prettier", stop_after_first = true },
|
||||
toml = { "prettierd", "prettier", stop_after_first = true },
|
||||
|
||||
-- Systems Programming
|
||||
rust = { "rustfmt" },
|
||||
c = { "clangformat" },
|
||||
cpp = { "clangformat" },
|
||||
|
||||
-- Shell and Configuration
|
||||
sh = { "shfmt" },
|
||||
nix = { "nixpkgsfmt" },
|
||||
},
|
||||
|
||||
-- format_on_save = {
|
||||
-- -- These options will be passed to conform.format()
|
||||
-- timeout_ms = 500,
|
||||
-- lsp_fallback = true,
|
||||
-- },
|
||||
-----------------------------------------------------------
|
||||
-- Custom Formatter Configurations
|
||||
-----------------------------------------------------------
|
||||
formatters = {
|
||||
-- Nix formatter configuration
|
||||
nixpkgsfmt = {
|
||||
command = "nixpkgs-fmt",
|
||||
args = {},
|
||||
},
|
||||
|
||||
-- C/C++ formatter configuration
|
||||
clangformat = {
|
||||
inherit = false,
|
||||
command = "clang-format",
|
||||
},
|
||||
},
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Format on Save Settings
|
||||
-----------------------------------------------------------
|
||||
format_on_save = {
|
||||
timeout_ms = 2500, -- Maximum time to wait for formatting
|
||||
lsp_fallback = false, -- Don't fallback to LSP formatting
|
||||
},
|
||||
}
|
||||
|
||||
return options
|
@@ -1,24 +1,101 @@
|
||||
-- load defaults i.e lua_lsp
|
||||
-----------------------------------------------------------
|
||||
-- LSP Configuration
|
||||
-----------------------------------------------------------
|
||||
|
||||
-- Load NvChad LSP defaults
|
||||
require("nvchad.configs.lspconfig").defaults()
|
||||
|
||||
local lspconfig = require "lspconfig"
|
||||
local lspconfig = require("lspconfig")
|
||||
local nvlsp = require("nvchad.configs.lspconfig")
|
||||
|
||||
-- EXAMPLE
|
||||
local servers = { "html", "cssls" }
|
||||
local nvlsp = require "nvchad.configs.lspconfig"
|
||||
-----------------------------------------------------------
|
||||
-- Language Server Configurations
|
||||
-----------------------------------------------------------
|
||||
|
||||
-- lsps with default config
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
on_attach = nvlsp.on_attach,
|
||||
on_init = nvlsp.on_init,
|
||||
capabilities = nvlsp.capabilities,
|
||||
}
|
||||
local servers = {
|
||||
-----------------------------------------------------------
|
||||
-- Web Development
|
||||
-----------------------------------------------------------
|
||||
-- HTML & CSS
|
||||
emmet_language_server = {},
|
||||
html = {},
|
||||
cssls = {},
|
||||
|
||||
-- JavaScript & Frameworks
|
||||
svelte = {},
|
||||
astro = {},
|
||||
|
||||
-- Tailwind CSS
|
||||
tailwindcss = {
|
||||
settings = {
|
||||
tailwindCSS = {
|
||||
experimental = {
|
||||
classRegex = {
|
||||
{ "cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]" },
|
||||
{ "cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)" },
|
||||
{ "cn\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- JSON & Linting
|
||||
jsonls = {},
|
||||
eslint = {},
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- DevOps & Infrastructure
|
||||
-----------------------------------------------------------
|
||||
-- Docker
|
||||
docker_compose_language_service = {},
|
||||
dockerls = {},
|
||||
|
||||
-- Server Configuration
|
||||
nginx_language_server = {},
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Systems Programming
|
||||
-----------------------------------------------------------
|
||||
-- Rust
|
||||
rust_analyzer = {},
|
||||
|
||||
-- C/C++
|
||||
clangd = {},
|
||||
|
||||
-- Go
|
||||
gopls = {},
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Scripting & Configuration
|
||||
-----------------------------------------------------------
|
||||
-- Lua
|
||||
lua_ls = {},
|
||||
|
||||
-- Nix
|
||||
nixd = {},
|
||||
|
||||
-- C# (currently disabled)
|
||||
-- csharp_ls = {},
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Database & Backend
|
||||
-----------------------------------------------------------
|
||||
-- SQL
|
||||
sqls = {},
|
||||
|
||||
-- PHP
|
||||
phpactor = {},
|
||||
}
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Apply Server Configurations
|
||||
-----------------------------------------------------------
|
||||
|
||||
-- Iterate through servers and apply common configuration
|
||||
for name, opts in pairs(servers) do
|
||||
opts.on_init = nvlsp.on_init
|
||||
opts.on_attach = nvlsp.on_attach
|
||||
opts.capabilities = nvlsp.capabilities
|
||||
lspconfig[name].setup(opts)
|
||||
end
|
||||
|
||||
-- configuring single server, example: typescript
|
||||
-- lspconfig.ts_ls.setup {
|
||||
-- on_attach = nvlsp.on_attach,
|
||||
-- on_init = nvlsp.on_init,
|
||||
-- capabilities = nvlsp.capabilities,
|
||||
-- }
|
||||
|
@@ -1,16 +1,9 @@
|
||||
return {
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
-- event = 'BufWritePre', -- uncomment for format on save
|
||||
opts = require "configs.conform",
|
||||
},
|
||||
|
||||
{
|
||||
"charludo/projectmgr.nvim",
|
||||
lazy = false, -- Required for proper functionality
|
||||
},
|
||||
|
||||
-- These are some examples, uncomment them if you want to see them work!
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
config = function()
|
||||
@@ -19,33 +12,9 @@ return {
|
||||
},
|
||||
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
-- Installer for language servers
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls", -- Lua
|
||||
"gopls", -- Go
|
||||
"tsserver", -- JavaScript/TypeScript
|
||||
},
|
||||
})
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- Lua Language Server
|
||||
lspconfig.lua_ls.setup {}
|
||||
|
||||
-- Go Language Server
|
||||
lspconfig.gopls.setup {}
|
||||
|
||||
-- JavaScript/TypeScript Language Server
|
||||
lspconfig.tsserver.setup {}
|
||||
end,
|
||||
"stevearc/conform.nvim",
|
||||
event = "BufWritePre",
|
||||
opts = require "configs.conform",
|
||||
},
|
||||
|
||||
-- Supermaven
|
||||
|
Reference in New Issue
Block a user