nvim: move vim opts to separate file

This commit is contained in:
David Senoner 2024-11-01 23:15:13 +01:00
parent f141c8937a
commit 8197dd257d
2 changed files with 16 additions and 79 deletions

View file

@ -1,11 +1,4 @@
vim.opt.number = true
vim.opt.expandtab = true
vim.opt.number = true
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.title = true
vim.opt.whichwrap = "<,>,[,]"
require("vim-options")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
@ -18,77 +11,9 @@ if not vim.loop.fs_stat(lazypath) then
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local plugins = {
{ "rebelot/kanagawa.nvim", name = "kanagawa", priority = 1000 },
{
"nvim-telescope/telescope.nvim", tag = "0.1.8",
dependencies = { "nvim-lua/plenary.nvim" }
},
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
{ "williamboman/mason.nvim" },
{ "williamboman/mason-lspconfig.nvim" },
{ "neovim/nvim-lspconfig" },
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-nvim-lsp" },
}
require("lazy").setup(plugins, {})
vim.cmd.colorscheme "kanagawa-dragon"
local builtin = require("telescope.builtin")
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = { "asm", "c", "javascript", "latex", "lua", "matlab", "meson", "sql", "toml", "typescript", "verilog", "vue" },
highlight = { enable = true },
indent = { enable = true }
require("lazy").setup({
spec = "plugins"
})
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = { "clangd", "texlab", "lua_ls", "matlab_ls", "mesonlsp", "sqlls", "svlangserver", "ts_ls", "volar" }
})
local lspconfig = require("lspconfig")
lspconfig.clangd.setup({
cmd = { "clangd", "-header-insertion=never" },
})
lspconfig.lua_ls.setup({})
lspconfig.matlab_ls.setup({})
lspconfig.mesonlsp.setup({})
lspconfig.sqlls.setup({})
lspconfig.svlangserver.setup({})
lspconfig.texlab.setup({})
lspconfig.ts_ls.setup({})
lspconfig.volar.setup({})
local cmp = require("cmp")
cmp.setup({
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
}),
})
vim.keymap.set("n", "T", function() vim.lsp.buf.definition() end, {})
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, {})
vim.keymap.set("n", "J", function() vim.lsp.buf.type_definition() end, {})
vim.keymap.set("n", "C", function() vim.lsp.buf.code_action() end, {})
vim.keymap.set("n", "<C-p>", builtin.find_files, {})
vim.keymap.set("n", "<C-f>", builtin.live_grep, {})

12
lua/vim-options.lua Normal file
View file

@ -0,0 +1,12 @@
vim.cmd("set number")
vim.cmd("set expandtab")
vim.cmd("set tabstop=2")
vim.cmd("set softtabstop=2")
vim.cmd("set shiftwidth=2")
vim.cmd("set title")
vim.keymap.set("n", "T", function() vim.lsp.buf.definition() end, {})
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, {})
vim.keymap.set("n", "J", function() vim.lsp.buf.type_definition() end, {})
vim.keymap.set("n", "C", function() vim.lsp.buf.code_action() end, {})