Set up LSP, completion, etc; adjust a few other small settings
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
-- TODO: set this up
|
||||
return {
|
||||
-- 'stevearc/conform.nvim',
|
||||
-- opts = {},
|
||||
-- config = function()
|
||||
-- require("conform").setup({
|
||||
-- formatters_by_ft = {
|
||||
-- lua = { "stylua" },
|
||||
-- go = { "gofmt" },
|
||||
-- javascript = { "prettier" },
|
||||
-- typescript = { "prettier" },
|
||||
-- elixir = { "mix" }
|
||||
-- }
|
||||
-- })
|
||||
-- end
|
||||
'stevearc/conform.nvim',
|
||||
opts = {},
|
||||
config = function()
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
-- c = { "fill-in" },
|
||||
-- cpp = { "fill-in" },
|
||||
go = { "gofmt" },
|
||||
lua = { "stylua" },
|
||||
ruby = { "standardrb" },
|
||||
python = { "black" },
|
||||
javascript = { "prettier" },
|
||||
}
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
|
138
src_files/.config/nvim/lua/david_standard/plugins_lazy/lsp.lua
Normal file
138
src_files/.config/nvim/lua/david_standard/plugins_lazy/lsp.lua
Normal file
@@ -0,0 +1,138 @@
|
||||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"stevearc/conform.nvim",
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/nvim-cmp",
|
||||
-- snippets, using luasnip for now
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
|
||||
config = function()
|
||||
require("conform").setup({ formatters_by_ft = {} })
|
||||
local cmp = require('cmp')
|
||||
local cmp_lsp = require("cmp_nvim_lsp")
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
cmp_lsp.default_capabilities()
|
||||
)
|
||||
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
-- "gopls",
|
||||
"ruby_lsp",
|
||||
-- "tailwindcss",
|
||||
},
|
||||
handlers = {
|
||||
function(server_name) -- default
|
||||
require("lspconfig")[server_name].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
end,
|
||||
|
||||
["lua_ls"] = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
format = {
|
||||
enable = true,
|
||||
defaultConfig = { -- NOTE: string values only
|
||||
indent_style = "space",
|
||||
indent_size = "2",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
})
|
||||
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
cmp.setup({
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
}),
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
-- vim.snippet.expand(args.body) -- TODO: native option, maybe try
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
})
|
||||
|
||||
-- `/` cmdline setup.
|
||||
cmp.setup.cmdline('/', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- `:` cmdline setup.
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
}),
|
||||
matching = { disallow_symbol_nonprefix_matching = false }
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vim.diagnostic.config({
|
||||
-- update_in_insert = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
|
||||
end
|
||||
}
|
@@ -57,7 +57,7 @@ return {
|
||||
"nvim-treesitter/nvim-treesitter-context",
|
||||
after = "nvim-treesitter",
|
||||
opts = {
|
||||
enable = true, -- can enable/disable via manual command
|
||||
enable = false, -- can enable/disable via manual command
|
||||
multiwindow = false,
|
||||
max_lines = 0, -- lines the window should span; x <= 0 means no limit
|
||||
min_window_height = 10, -- min window height to enable; x <= 0 means no limit
|
||||
|
Reference in New Issue
Block a user