this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at aa7d3e2508c2fbf7a9ee53ba8891f3dd81ba3dcf 211 lines 6.3 kB view raw
1return { 2 { "b0o/schemastore.nvim" }, 3 { 4 "neovim/nvim-lspconfig", 5 dependencies = { 6 "mason-org/mason.nvim", 7 "klen/nvim-config-local", 8 }, 9 config = function() 10 local lspc = require("lspconfig") 11 local lspconfig_defaults = lspc.util.default_config 12 lspconfig_defaults.capabilities = 13 vim.tbl_deep_extend("force", lspconfig_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities()) 14 end, 15 }, 16 { 17 "mason-org/mason-lspconfig.nvim", 18 dependencies = { 19 "neovim/nvim-lspconfig", 20 "mason-org/mason.nvim", 21 "klen/nvim-config-local", 22 }, 23 config = function() 24 local function not_deno(bufn, on_dir) 25 local util = require("lspconfig.util") 26 if util.root_pattern("deno.json", "deno.jsonc")(bufn) then 27 return nil 28 end 29 on_dir(util.root_pattern("package.json", "tsconfig.json", ".git")(bufn)) 30 end 31 32 require("mason").setup({}) 33 require("mason-lspconfig").setup({ 34 automatic_enable = true, 35 automatic_installation = true, 36 ensure_installed = { 37 "efm", -- general purpose language server 38 "lua_ls", 39 "jsonls", 40 "vtsls", 41 "eslint", 42 "oxlint", 43 "bashls", 44 "gopls", 45 "goimports", 46 "rust_analyzer", 47 "pyright", 48 "yamlls", 49 "denols", 50 "marksman", 51 }, 52 }) 53 54 LangServers.lua_ls = { 55 settings = { 56 Lua = { diagnostics = { globals = { "LangServers" } } }, 57 }, 58 } 59 LangServers.vtsls = { 60 root_dir = not_deno, 61 single_file_support = false, 62 settings = { 63 -- Formatting handled by efm 64 javascript = { format = { enable = false } }, 65 typescript = { format = { enable = false } }, 66 } 67 } 68 LangServers.eslint = { 69 single_file_support = false, 70 } 71 LangServers.denols = { 72 root_dir = function(bufn, on_dir) 73 local util = require("lspconfig.util") 74 if util.root_pattern("deno.json", "deno.jsonc")(bufn) then 75 on_dir(util.root_pattern("deno.json", "deno.jsonc")(bufn)) 76 end 77 end 78 } 79 LangServers.yamlls = { 80 settings = { 81 yaml = { 82 -- Disable built in schema store stuff in favor of `schemastore` plugin 83 schemaStore = { enable = false, url = "" }, 84 schemas = require("schemastore").yaml.schemas(), 85 86 validate = true, 87 completion = true, 88 hover = true, 89 }, 90 }, 91 } 92 LangServers.jsonls = { 93 filetypes = { "json", "json5", "jsonc" }, 94 settings = { 95 json = { 96 schemas = require("schemastore").json.schemas(), 97 validate = { enable = true }, 98 format = { enable = false }, 99 }, 100 } 101 } 102 LangServers.bashls = { 103 filetypes = { "sh", "bash", "zsh" }, 104 } 105 LangServers.efm = { 106 filetypes = { "sh", "bash", "zsh", "javascript", "typescript", "javascriptreact", "typescriptreact", "json", "css", "scss", "html", "markdown" }, 107 init_options = { 108 documentFormatting = true, 109 documentRangeFormatting = true, 110 }, 111 settings = { 112 rootMarkers = { ".git/" }, 113 languages = (function() 114 local prettier_config = { formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true } 115 local shfmt_config = { formatCommand = "shfmt -ci", formatStdin = true } 116 -- Use a shell script to detect biome config and use appropriate formatter 117 local js_formatter = { 118 formatCommand = [[sh -c ' 119 dir="$(dirname "${INPUT}")" 120 while [ "$dir" != "/" ]; do 121 if [ -f "$dir/biome.json" ] || [ -f "$dir/biome.jsonc" ]; then 122 biome format --stdin-file-path "${INPUT}" 123 exit 0 124 fi 125 dir="$(dirname "$dir")" 126 done 127 prettier --stdin-filepath "${INPUT}" 128 ']], 129 formatStdin = true 130 } 131 132 return { 133 sh = { shfmt_config }, 134 bash = { shfmt_config }, 135 zsh = { shfmt_config }, 136 javascript = { js_formatter }, 137 typescript = { js_formatter }, 138 javascriptreact = { js_formatter }, 139 typescriptreact = { js_formatter }, 140 json = { js_formatter }, 141 css = { prettier_config }, 142 scss = { prettier_config }, 143 html = { prettier_config }, 144 markdown = { prettier_config }, 145 } 146 end)(), 147 }, 148 } 149 LangServers.gopls = { 150 cmd = { "gopls" }, 151 filetypes = { "go", "gomod", "gowork", "gotmpl" }, 152 } 153 LangServers.pyright = {} 154 155 function SetupLspHandlers() 156 for server_name, server_config in pairs(LangServers) do 157 if server_config == false then 158 return 159 end 160 vim.lsp.config(server_name, server_config or {}) 161 vim.lsp.enable(server_name) 162 end 163 end 164 165 -- Call this after loading local configs so the `LangServers` global 166 -- can be modified in those configs as needed first. 167 vim.api.nvim_create_autocmd("User", { 168 pattern = "ConfigLocalFinished", 169 callback = SetupLspHandlers, 170 }) 171 vim.api.nvim_create_autocmd("BufWritePre", { 172 callback = function() 173 if vim.bo.filetype ~= "markdown" then 174 vim.lsp.buf.format() 175 end 176 end, 177 }) 178 end, 179 }, 180 { 181 "folke/lazydev.nvim", 182 ft = "lua", -- only load on lua files 183 opts = {}, 184 }, 185 { 186 "folke/trouble.nvim", 187 opts = { 188 icons = {}, 189 modes = { 190 symbols = { 191 win = { 192 wo = { foldlevel = 0 }, 193 size = 50, 194 }, 195 format = "{kind_icon} {symbol.name} {pos}", 196 }, 197 }, 198 }, 199 cmd = "Trouble", 200 }, 201 { 202 "antosha417/nvim-lsp-file-operations", 203 dependencies = { 204 "nvim-lua/plenary.nvim", 205 "nvim-neo-tree/neo-tree.nvim", 206 }, 207 config = function() 208 require("lsp-file-operations").setup() 209 end, 210 }, 211}