style(vim): add lua style and luacheck and format lsp config again
This commit is contained in:
parent
2670607006
commit
615413d6e2
3 changed files with 59 additions and 41 deletions
12
.luacheckrc
Normal file
12
.luacheckrc
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
-- Rerun tests only if their modification time changed.
|
||||||
|
cache = true
|
||||||
|
|
||||||
|
std = luajit
|
||||||
|
codes = true
|
||||||
|
|
||||||
|
self = false
|
||||||
|
|
||||||
|
-- Global objects defined by the C code
|
||||||
|
read_globals = {
|
||||||
|
"vim",
|
||||||
|
}
|
||||||
6
.stylua.toml
Normal file
6
.stylua.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
column_width = 120
|
||||||
|
line_endings = "Unix"
|
||||||
|
indent_type = "Spaces"
|
||||||
|
indent_width = 2
|
||||||
|
quote_style = "AutoPreferDouble"
|
||||||
|
call_parentheses = "None"
|
||||||
|
|
@ -1,57 +1,57 @@
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require "lspconfig"
|
||||||
|
|
||||||
local servers = {
|
local servers = {
|
||||||
-- Language servers for the day to day web development, could probably think
|
-- Language servers for the day to day web development, could probably think
|
||||||
-- about loosing the html and css one and living with typescript and emmet
|
-- about loosing the html and css one and living with typescript and emmet
|
||||||
tsserver = {},
|
tsserver = {},
|
||||||
html = {},
|
html = {},
|
||||||
cssls = {},
|
cssls = {},
|
||||||
emmet_ls = {
|
emmet_ls = {
|
||||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "scss", "eruby" },
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "scss", "eruby" },
|
||||||
},
|
},
|
||||||
-- Ruby
|
-- Ruby
|
||||||
solargraph = {},
|
solargraph = {},
|
||||||
-- Rust
|
-- Rust
|
||||||
rust_analyzer = {},
|
rust_analyzer = {},
|
||||||
-- Lua for the vim config and plugin dev
|
-- Lua for the vim config and plugin dev
|
||||||
sumneko_lua = {
|
sumneko_lua = {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = { version = "LuaJIT" },
|
runtime = { version = "LuaJIT" },
|
||||||
diagnostics = { globals = { "vim" } },
|
diagnostics = { globals = { "vim" } },
|
||||||
workspace = { library = vim.api.nvim_get_runtime_file("", true) },
|
workspace = { library = vim.api.nvim_get_runtime_file("", true) },
|
||||||
telemetry = { enable = false },
|
telemetry = { enable = false },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local on_attach = function(_, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||||
|
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
-- Mappings.
|
-- Mappings.
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
|
||||||
for lsp, config in pairs(servers) do
|
for lsp, config in pairs(servers) do
|
||||||
config["on_attach"] = on_attach
|
config["on_attach"] = on_attach
|
||||||
config["capabilities"] = capabilities
|
config["capabilities"] = capabilities
|
||||||
config["init_options"] = { usePlaceholders = true }
|
config["init_options"] = { usePlaceholders = true }
|
||||||
|
|
||||||
lspconfig[lsp].setup(config)
|
lspconfig[lsp].setup(config)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Change the diagnostic signs
|
-- Change the diagnostic signs
|
||||||
|
|
@ -59,6 +59,6 @@ vim.fn.sign_define("DiagnosticSignHint", { text = "➤", texthl = "DiagnosticSig
|
||||||
vim.fn.sign_define("DiagnosticSignInfo", { text = "ℹ", texthl = "DiagnosticSignInfo", numhl = "DiagnosticSignInfo" })
|
vim.fn.sign_define("DiagnosticSignInfo", { text = "ℹ", texthl = "DiagnosticSignInfo", numhl = "DiagnosticSignInfo" })
|
||||||
vim.fn.sign_define("DiagnosticSignWarn", { text = "⚠", texthl = "DiagnosticSignWarn", numhl = "DiagnosticSignWarn" })
|
vim.fn.sign_define("DiagnosticSignWarn", { text = "⚠", texthl = "DiagnosticSignWarn", numhl = "DiagnosticSignWarn" })
|
||||||
vim.fn.sign_define(
|
vim.fn.sign_define(
|
||||||
"DiagnosticSignError",
|
"DiagnosticSignError",
|
||||||
{ text = "✖", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" }
|
{ text = "✖", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" }
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue