this repo has no description
0
fork

Configure Feed

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

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