-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
99 lines (93 loc) · 2.26 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
local vimrc = vim.fn.stdpath("config") .. "/.vimrc"
vim.cmd.source(vimrc)
require("paq")({
"savq/paq-nvim",
-- vimscript
"tpope/vim-sleuth",
"unblevable/quick-scope",
"tpope/vim-surround",
"tpope/vim-obsession",
"christoomey/vim-tmux-navigator",
"mbbill/undotree",
"tpope/vim-fugitive",
-- lua
"neovim/nvim-lspconfig",
"stevearc/conform.nvim",
})
-- LSP setup
local lspconfig = require("lspconfig")
local lsps = {
"lua_ls",
"basedpyright",
"ruff",
"ts_ls",
"sqlls",
"emmet_language_server",
}
for _, lsp in pairs(lsps) do
local setup = {}
if lsp == "basedpyright" then
setup = {
settings = {
[lsp] = {
analysis = {
diagnosticMode = "workspace",
typeCheckingMode = "off",
diagnosticSeverityOverrides = {
reportCallIssue = "warning",
},
},
},
},
}
end
lspconfig[lsp].setup(setup)
end
-- Completions
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
if client:supports_method("textDocument/completion") then
vim.lsp.completion.enable(true, client.id, args.buf)
end
end,
})
-- Formatting
require("conform").setup({
formatters_by_ft = {
sh = { "beautysh" },
terraform = { "terraform_fmt" },
lua = { "stylua" },
-- "ruff_fix" removes unused imports
python = { "ruff_fix", "ruff_organize_imports", "ruff_format" },
typescript = { "prettier" },
css = { "prettier" },
html = { "prettier" },
javascript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
json = { "prettier" },
scss = { "prettier" },
yaml = { "prettier" },
},
format_after_save = {}, -- TODO: remove
})
-- Options
vim.diagnostic.config({
severity_sort = true,
virtual_text = {
severity = vim.diagnostic.severity.ERROR,
},
})
-- Mappings
vim.keymap.set("n", "<F3>", require("conform").format)
vim.keymap.set("n", "]D", function()
vim.diagnostic.jump({ count = 1, severity = vim.diagnostic.severity.ERROR })
end)
vim.keymap.set("n", "[D", function()
vim.diagnostic.jump({ count = -1, severity = vim.diagnostic.severity.ERROR })
end)
vim.keymap.set("n", "gl", vim.diagnostic.open_float)
vim.keymap.set("n", "gL", function()
vim.diagnostic.setloclist({ severity = vim.diagnostic.severity.ERROR })
end)