remember to enable lsp
This commit is contained in:
@@ -5,28 +5,29 @@ require("neodev").setup()
|
||||
|
||||
require("fidget").setup({
|
||||
notification = {
|
||||
redirect = -- Conditionally redirect notifications to another backend
|
||||
function(msg, level, opts)
|
||||
if opts and opts.on_open then
|
||||
return require("fidget.integration.nvim-notify").delegate(msg, level, opts)
|
||||
end
|
||||
end,
|
||||
redirect = -- Conditionally redirect notifications to another backend
|
||||
function(msg, level, opts)
|
||||
if opts and opts.on_open then
|
||||
return require("fidget.integration.nvim-notify").delegate(msg, level, opts)
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = {'bashls', 'clangd', 'marksman', 'pylsp', 'ruff', 'texlab'},
|
||||
ensure_installed = { 'bashls', 'clangd', 'lua_ls', 'marksman', 'pylsp', 'ruff', 'texlab' },
|
||||
automatic_enable = false,
|
||||
})
|
||||
require('mason-nvim-dap').setup({
|
||||
ensure_installed = {'bash', 'cppdbg', 'python'},
|
||||
ensure_installed = { 'bash', 'cppdbg', 'python' },
|
||||
})
|
||||
require('dap-python').setup("python")
|
||||
|
||||
local servers = {
|
||||
bashls = {},
|
||||
clangd = {},
|
||||
lua_ls = {},
|
||||
marksman = {},
|
||||
pylsp = {
|
||||
settings = {
|
||||
@@ -49,19 +50,19 @@ local servers = {
|
||||
filetypes = { "python" },
|
||||
init_options = {
|
||||
settings = {
|
||||
configuration = "~/.local/share/nvim/ruff.toml", -- Custom config for ruff to use
|
||||
exclude = { "__about__.py" }, -- Files to be excluded by ruff checking
|
||||
lineLength = 160, -- Line length to pass to ruff checking and formatting
|
||||
configuration = "~/.local/share/nvim/ruff.toml", -- Custom config for ruff to use
|
||||
exclude = { "__about__.py" }, -- Files to be excluded by ruff checking
|
||||
lineLength = 160, -- Line length to pass to ruff checking and formatting
|
||||
organizeImports = true,
|
||||
format = {
|
||||
preview = false, -- Whether to enable the preview style linting and formatting.
|
||||
preview = false, -- Whether to enable the preview style linting and formatting.
|
||||
},
|
||||
lint = {
|
||||
enable = true, -- Enable linting
|
||||
enable = true, -- Enable linting
|
||||
-- select = { "F" }, -- Rules to be enabled by ruff
|
||||
extendSelect = { "F", "I" }, -- Rules that are additionally used by ruff
|
||||
ignore = { "D210", "E741", "E743" }, -- Rules to be ignored by ruff
|
||||
extendIgnore = { "C90" }, -- Rules that are additionally ignored by ruff
|
||||
extendSelect = { "F", "I" }, -- Rules that are additionally used by ruff
|
||||
ignore = { "D210", "E741", "E743" }, -- Rules to be ignored by ruff
|
||||
extendIgnore = { "C90" }, -- Rules that are additionally ignored by ruff
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -87,7 +88,7 @@ local servers = {
|
||||
ignoredPatterns = {
|
||||
"Unused label",
|
||||
-- "Unused entry",
|
||||
},
|
||||
},
|
||||
},
|
||||
formatterLineLength = -1,
|
||||
latexFormatter = "latexindent",
|
||||
@@ -96,7 +97,7 @@ local servers = {
|
||||
},
|
||||
forwardSearch = {
|
||||
executable = "zathura",
|
||||
args = { "--synctex-forward", "%l:1:%f", "%p"}
|
||||
args = { "--synctex-forward", "%l:1:%f", "%p" }
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -124,13 +125,15 @@ local on_attach = function(_client, buffer_number)
|
||||
-- Use Prettier to format TS/JS if it's available
|
||||
return format_client.name ~= "tsserver" or not null_ls.is_registered("prettier")
|
||||
end,
|
||||
async = false,
|
||||
timeout_ms = 10000,
|
||||
})
|
||||
end, { desc = "LSP: Format current buffer with LSP" })
|
||||
end
|
||||
|
||||
-- Iterate over our servers and set them up
|
||||
for name, config in pairs(servers) do
|
||||
vim.lsp.config(name,{
|
||||
vim.lsp.config(name, {
|
||||
capabilities = default_capabilities,
|
||||
filetypes = config.filetypes,
|
||||
handlers = vim.tbl_deep_extend("force", {}, default_handlers, config.handlers or {}),
|
||||
@@ -138,6 +141,7 @@ for name, config in pairs(servers) do
|
||||
settings = config.settings,
|
||||
init_options = config.init_options,
|
||||
})
|
||||
vim.lsp.enable(name)
|
||||
end
|
||||
|
||||
vim.diagnostic.config({
|
||||
@@ -156,48 +160,48 @@ vim.diagnostic.config({
|
||||
})
|
||||
|
||||
-- Autoformat on save
|
||||
local fmt_group = vim.api.nvim_create_augroup('autoformat_cmds', {clear = true})
|
||||
local fmt_group = vim.api.nvim_create_augroup('autoformat_cmds', { clear = true })
|
||||
|
||||
local function setup_autoformat(event)
|
||||
local id = vim.tbl_get(event, 'data', 'client_id')
|
||||
local client = id and vim.lsp.get_client_by_id(id)
|
||||
if client == nil then
|
||||
return
|
||||
end
|
||||
local id = vim.tbl_get(event, 'data', 'client_id')
|
||||
local client = id and vim.lsp.get_client_by_id(id)
|
||||
if client == nil then
|
||||
return
|
||||
end
|
||||
|
||||
vim.api.nvim_clear_autocmds({group = fmt_group, buffer = event.buf})
|
||||
vim.api.nvim_clear_autocmds({ group = fmt_group, buffer = event.buf })
|
||||
|
||||
local buf_format = function(e)
|
||||
vim.lsp.buf.format({
|
||||
bufnr = e.buf,
|
||||
async = false,
|
||||
timeout_ms = 10000,
|
||||
local buf_format = function(e)
|
||||
vim.lsp.buf.format({
|
||||
bufnr = e.buf,
|
||||
async = false,
|
||||
timeout_ms = 10000,
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = event.buf,
|
||||
group = fmt_group,
|
||||
desc = 'Format current buffer',
|
||||
callback = buf_format,
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
buffer = event.buf,
|
||||
group = fmt_group,
|
||||
desc = 'Format current buffer',
|
||||
callback = buf_format,
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
desc = 'Setup format on save',
|
||||
callback = setup_autoformat,
|
||||
desc = 'Setup format on save',
|
||||
callback = setup_autoformat,
|
||||
})
|
||||
|
||||
-- Enable inlay hints
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
desc = 'Enable inlay hints',
|
||||
callback = function(event)
|
||||
local id = vim.tbl_get(event, 'data', 'client_id')
|
||||
local client = id and vim.lsp.get_client_by_id(id)
|
||||
if client == nil or not client:supports_method('textDocument/inlayHint') then
|
||||
return
|
||||
end
|
||||
desc = 'Enable inlay hints',
|
||||
callback = function(event)
|
||||
local id = vim.tbl_get(event, 'data', 'client_id')
|
||||
local client = id and vim.lsp.get_client_by_id(id)
|
||||
if client == nil or not client:supports_method('textDocument/inlayHint') then
|
||||
return
|
||||
end
|
||||
|
||||
vim.lsp.inlay_hint.enable(true, {bufnr = event.buf})
|
||||
end,
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = event.buf })
|
||||
end,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user