Initial LSP setup with formatting and autocompletion
This commit is contained in:
1
lua/colorscheme.lua
Normal file
1
lua/colorscheme.lua
Normal file
@@ -0,0 +1 @@
|
||||
require("rose-pine").setup()
|
||||
14
lua/completion.lua
Normal file
14
lua/completion.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
---@type blink.cmp.API
|
||||
local cmp = require("blink.cmp")
|
||||
|
||||
cmp.build():pwait()
|
||||
|
||||
---@type blink.cmp.Config
|
||||
local cmp_options = {
|
||||
keymap = { preset = "default" },
|
||||
completion = { menu = { auto_show = true }, documentation = { auto_show = true } },
|
||||
sources = { default = { "lsp", "path", "snippets", "buffer" } },
|
||||
fuzzy = { implementation = "rust" },
|
||||
}
|
||||
|
||||
cmp.setup(cmp_options)
|
||||
21
lua/formatting.lua
Normal file
21
lua/formatting.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
local conform = require("conform")
|
||||
|
||||
---@type conform.setupOpts
|
||||
local options = {
|
||||
formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
},
|
||||
format_on_save = {
|
||||
timeout_ms = 500,
|
||||
lsp_format = "fallback",
|
||||
},
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*",
|
||||
callback = function(args)
|
||||
conform.format({ bufnr = args.buf })
|
||||
end,
|
||||
})
|
||||
|
||||
conform.setup(options)
|
||||
7
lua/lsp.lua
Normal file
7
lua/lsp.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
require("mason").setup({})
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"lua_ls",
|
||||
"stylua",
|
||||
},
|
||||
})
|
||||
34
lua/plugins.lua
Normal file
34
lua/plugins.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
vim.pack.add({
|
||||
-- Common dependencies
|
||||
{ src = "https://github.com/nvim-lua/plenary.nvim" },
|
||||
|
||||
-- Automatically install language servers
|
||||
{ src = "https://github.com/mason-org/mason.nvim" },
|
||||
|
||||
-- Predefined configs for language servers
|
||||
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
||||
|
||||
-- Automatically enable installed language servers
|
||||
{ src = "https://github.com/mason-org/mason-lspconfig.nvim" },
|
||||
|
||||
-- All-in-one completions engine
|
||||
{ src = "https://github.com/saghen/blink.lib" },
|
||||
{ src = "https://github.com/saghen/blink.cmp" },
|
||||
|
||||
-- Code formatting
|
||||
{ src = "https://github.com/stevearc/conform.nvim" },
|
||||
|
||||
-- Appearance
|
||||
{ src = "https://github.com/rose-pine/neovim", name = "rose-pine" },
|
||||
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
|
||||
|
||||
-- Fuzzy finder
|
||||
{ src = "https://github.com/nvim-telescope/telescope.nvim" },
|
||||
{ src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" },
|
||||
|
||||
-- Miscellaneous
|
||||
{ src = "https://github.com/windwp/nvim-autopairs" },
|
||||
|
||||
-- WoW Addon API
|
||||
{ src = "https://github.com/Tyrannican/warcraft-api.nvim" },
|
||||
})
|
||||
28
lua/utils.lua
Normal file
28
lua/utils.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
local M = {}
|
||||
|
||||
function M.map(mode, keys, func, desc, opts)
|
||||
vim.keymap.set(
|
||||
mode,
|
||||
keys,
|
||||
func,
|
||||
vim.tbl_extend("force", {
|
||||
desc = desc,
|
||||
noremap = true,
|
||||
silent = true,
|
||||
}, opts or {})
|
||||
)
|
||||
end
|
||||
|
||||
function M.nmap(keys, func, desc, opts)
|
||||
M.map("n", keys, func, desc, opts)
|
||||
end
|
||||
|
||||
function M.vmap(keys, func, desc, opts)
|
||||
M.map("v", keys, func, desc, opts)
|
||||
end
|
||||
|
||||
function M.imap(keys, func, desc, opts)
|
||||
M.map("i", keys, func, desc, opts)
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user