mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
ref: formatting
This commit is contained in:
parent
718ddbf69d
commit
2e7d1cc976
5 changed files with 165 additions and 168 deletions
|
|
@ -1,14 +1,14 @@
|
|||
require("fidget").setup({
|
||||
text = {
|
||||
spinner = "dots",
|
||||
-- done = "[Ok]",
|
||||
},
|
||||
text = {
|
||||
spinner = "dots",
|
||||
-- done = "[Ok]",
|
||||
},
|
||||
})
|
||||
|
||||
require "mason".setup()
|
||||
require "mason-lspconfig".setup {
|
||||
ensure_installed = {},
|
||||
automatic_installation = false
|
||||
ensure_installed = {},
|
||||
automatic_installation = false
|
||||
}
|
||||
require "neodev".setup()
|
||||
|
||||
|
|
@ -17,25 +17,25 @@ vim.keymap.set('n', '<leader>pe', vim.diagnostic.goto_prev, { desc = "goto [P]re
|
|||
vim.keymap.set('n', '<leader>ne', vim.diagnostic.goto_next, { desc = "goto [N]ext [E]rror" })
|
||||
|
||||
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')
|
||||
|
||||
-- See `:help vim.lsp.*`
|
||||
local ts = require "telescope.builtin"
|
||||
-- See `:help vim.lsp.*`
|
||||
local ts = require "telescope.builtin"
|
||||
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "LSP Hover", buffer = bufnr })
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, { desc = "LSP Signature help", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { desc = "LSP Declaration", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = "LSP Definitions", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gtd', vim.lsp.buf.type_definition, { desc = "LSP Type definitions", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = "LSP Implementations", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gu', ts.lsp_references, { desc = "LSP Usages (Telescope)", buffer = bufnr })
|
||||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, { desc = "Code action", buffer = bufnr })
|
||||
vim.keymap.set('n', '<leader>cl', vim.lsp.codelens.run, { desc = "Code lens", buffer = bufnr })
|
||||
vim.keymap.set('n', '<leader>f',
|
||||
function() vim.lsp.buf.format { async = true } end,
|
||||
{ desc = "LSP format", buffer = bufnr }
|
||||
)
|
||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = "LSP Rename symbol", buffer = bufnr })
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "LSP Hover", buffer = bufnr })
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, { desc = "LSP Signature help", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { desc = "LSP Declaration", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = "LSP Definitions", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gtd', vim.lsp.buf.type_definition, { desc = "LSP Type definitions", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = "LSP Implementations", buffer = bufnr })
|
||||
vim.keymap.set('n', 'gu', ts.lsp_references, { desc = "LSP Usages (Telescope)", buffer = bufnr })
|
||||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, { desc = "Code action", buffer = bufnr })
|
||||
vim.keymap.set('n', '<leader>cl', vim.lsp.codelens.run, { desc = "Code lens", buffer = bufnr })
|
||||
vim.keymap.set('n', '<leader>f',
|
||||
function() vim.lsp.buf.format { async = true } end,
|
||||
{ desc = "LSP format", buffer = bufnr }
|
||||
)
|
||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = "LSP Rename symbol", buffer = bufnr })
|
||||
end
|
||||
|
||||
-- Gutter symbols setup
|
||||
|
|
@ -47,20 +47,20 @@ vim.fn.sign_define("DiagnosticSignInfo", { text = '·', texthl = "DiagnosticSign
|
|||
|
||||
-- Border setup
|
||||
local border = {
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
{ " ", "FloatBorder" },
|
||||
}
|
||||
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||
opts = opts or {}
|
||||
opts.border = opts.border or border
|
||||
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
||||
opts = opts or {}
|
||||
opts.border = opts.border or border
|
||||
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
||||
end
|
||||
|
||||
-- Language servers
|
||||
|
|
@ -68,163 +68,164 @@ local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|||
capabilities = require "cmp_nvim_lsp".default_capabilities(capabilities)
|
||||
-- Spell check
|
||||
local common_dictionary = {
|
||||
-- Me stuff
|
||||
"Yu", "Hui", "Léana", "Chiang", "CHIANG",
|
||||
"ISTIC",
|
||||
-- LaTeX
|
||||
"compat",
|
||||
-- Tech terms
|
||||
"Vec", "VecDeque", "array", "stack", "queue", "deque", "string", "cursor", "matched",
|
||||
"HashMap", "HashSet", "dédupliquer",
|
||||
-- Rapport BIO
|
||||
"dédupliquer", "read", "reads", "contig", "Debruijn", "mer",
|
||||
-- Me stuff
|
||||
"Yu", "Hui", "Léana", "Chiang", "CHIANG",
|
||||
"ISTIC",
|
||||
-- LaTeX
|
||||
"compat",
|
||||
-- Tech terms
|
||||
"Vec", "VecDeque", "array", "stack", "queue", "deque", "string", "cursor", "matched",
|
||||
"HashMap", "HashSet", "dédupliquer",
|
||||
-- Rapport BIO
|
||||
"dédupliquer", "read", "reads", "contig", "Debruijn", "mer",
|
||||
}
|
||||
require "lspconfig".ltex.setup {
|
||||
on_attach = on_attach,
|
||||
cmd = { "ltex-ls" },
|
||||
filetypes = { "markdown", "text", "gitcommit", "tex" },
|
||||
settings = {
|
||||
ltex = {
|
||||
language = "auto",
|
||||
additionalRules = {
|
||||
motherTongue = "en-US"
|
||||
},
|
||||
trace = { server = "verbose" },
|
||||
dictionary = {
|
||||
["en-US"] = common_dictionary,
|
||||
["fr"] = common_dictionary
|
||||
},
|
||||
},
|
||||
},
|
||||
flags = { debounce_text_changes = 10000 },
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
cmd = { "ltex-ls" },
|
||||
filetypes = { "markdown", "text", "gitcommit", "tex" },
|
||||
settings = {
|
||||
ltex = {
|
||||
language = "auto",
|
||||
additionalRules = {
|
||||
motherTongue = "en-US"
|
||||
},
|
||||
trace = { server = "verbose" },
|
||||
dictionary = {
|
||||
["en-US"] = common_dictionary,
|
||||
["fr"] = common_dictionary
|
||||
},
|
||||
},
|
||||
},
|
||||
flags = { debounce_text_changes = 10000 },
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- JSON
|
||||
require "lspconfig".jsonls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- XML
|
||||
require "lspconfig".lemminx.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- CSS
|
||||
require "lspconfig".cssls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- Lua
|
||||
require "lspconfig".lua_ls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
lua = {
|
||||
format = {
|
||||
enable = true,
|
||||
defaultConfig = {
|
||||
-- tab
|
||||
indent_style = "tab",
|
||||
tab_width = "2",
|
||||
-- alignment
|
||||
align_call_args = "true",
|
||||
align_function_params = "true",
|
||||
align_continuous_assign_statement = "true",
|
||||
align_continuous_rect_table_field = "true",
|
||||
align_continuous_line_space = "2",
|
||||
align_if_branch = "true",
|
||||
align_array_table = "true",
|
||||
align_continuous_similar_call_args = "true",
|
||||
align_continuous_inline_comment = "true",
|
||||
align_chain_expr = "only_call_stmt",
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
lua = {
|
||||
format = {
|
||||
enable = true,
|
||||
defaultConfig = {
|
||||
-- tab
|
||||
indent_style = "tab",
|
||||
tab_width = "2",
|
||||
-- alignment
|
||||
align_call_args = "true",
|
||||
align_function_params = "true",
|
||||
align_continuous_assign_statement = "true",
|
||||
align_continuous_rect_table_field = "true",
|
||||
align_continuous_line_space = "2",
|
||||
align_if_branch = "true",
|
||||
align_array_table = "true",
|
||||
align_continuous_similar_call_args = "true",
|
||||
align_continuous_inline_comment = "true",
|
||||
align_chain_expr = "only_call_stmt",
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
-- Go
|
||||
require "lspconfig".gopls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- Rust
|
||||
require "rust-tools".setup {
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
cmd = { "rustup", "run", "stable", "rust-analyzer" }
|
||||
}
|
||||
server = {
|
||||
on_attach = on_attach,
|
||||
cmd = { "rustup", "run", "stable", "rust-analyzer" }
|
||||
}
|
||||
}
|
||||
-- tex
|
||||
require "lspconfig".texlab.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- Markdown
|
||||
require "lspconfig".marksman.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- TOML
|
||||
require "lspconfig".taplo.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- Java
|
||||
require "lspconfig".jdtls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- Scala
|
||||
require "lspconfig".metals.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
-- Haskell
|
||||
-- -- `haskell-tools` needs to be in `ftplugin`.
|
||||
-- -- To simplify the setup, we create an autocmd instead.
|
||||
local setup_ht = function()
|
||||
local ht = require("haskell-tools")
|
||||
ht.start_or_attach {
|
||||
tools = {
|
||||
hover = {
|
||||
border = border,
|
||||
stylize_markdown = true,
|
||||
}
|
||||
},
|
||||
hls = {
|
||||
on_attach = function(client, bufnr)
|
||||
on_attach(client, bufnr)
|
||||
vim.keymap.set('n', '<space>hs', ht.hoogle.hoogle_signature,
|
||||
{ desc = "Hoogle signature", buffer = bufnr })
|
||||
vim.keymap.set('n', '<space>ea', ht.lsp.buf_eval_all, { desc = "Evaluate all", buffer = bufnr })
|
||||
end,
|
||||
default_settings = {
|
||||
haskell = {
|
||||
formattingProvider = "stylish-haskell"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
local ht = require("haskell-tools")
|
||||
ht.start_or_attach {
|
||||
tools = {
|
||||
hover = {
|
||||
border = border,
|
||||
stylize_markdown = true,
|
||||
}
|
||||
},
|
||||
hls = {
|
||||
on_attach = function(client, bufnr)
|
||||
on_attach(client, bufnr)
|
||||
vim.keymap.set('n', '<space>hs', ht.hoogle.hoogle_signature,
|
||||
{ desc = "Hoogle signature", buffer = bufnr })
|
||||
vim.keymap.set('n', '<space>he', ht.lsp.buf_eval_all, { desc = "Evaluate all", buffer = bufnr })
|
||||
end,
|
||||
default_settings = {
|
||||
haskell = {
|
||||
-- formattingProvider = "stylish-haskell"
|
||||
formattingProvider = "ormolu"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "haskell",
|
||||
callback = setup_ht
|
||||
pattern = { "haskell", "cabal" },
|
||||
callback = setup_ht,
|
||||
})
|
||||
|
||||
-- Python
|
||||
require "lspconfig".pylsp.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- C
|
||||
require "lspconfig".clangd.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
-- HTML
|
||||
require "lspconfig".html.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = { "html", "xhtml" },
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
filetypes = { "html", "xhtml" },
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue