Changed to nvchad

This commit is contained in:
Christoffer Martinsson 2023-06-08 16:31:50 +02:00
parent a12f9c63c4
commit 7064af4558
12 changed files with 354 additions and 24 deletions

View File

@ -0,0 +1,6 @@
---@type ChadrcConfig
local M = {}
M.ui = {theme = 'tomorrow_night'}
M.plugins = 'custom.plugins'
M.mappings = require "custom.mappings"
return M

View File

@ -0,0 +1,27 @@
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities
local lspconfig = require("lspconfig")
local util = require "lspconfig/util"
local servers = { "html", "cssls", "clangd", "pyright"}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end
lspconfig.rust_analyzer.setup({
on_attach = on_attach,
capabilities = capabilities,
filetypes = {"rust"},
root_dir = util.root_pattern("Cargo.toml"),
settings = {
['rust-analyzer'] = {
cargo = {
allFeatures = true,
},
},
},
})

View File

@ -0,0 +1,16 @@
local null_ls = require "null-ls"
local formatting = null_ls.builtins.formatting
local lint = null_ls.builtins.diagnostics
local sources = {
formatting.prettier,
formatting.stylua,
lint.shellcheck,
}
null_ls.setup {
debug = true,
sources = sources,
}

View File

@ -0,0 +1,68 @@
local M = {}
M.treesitter = {
ensure_installed = {
"vim",
"lua",
"html",
"css",
"javascript",
"typescript",
"tsx",
"c",
"cpp",
"rust",
"markdown",
"markdown_inline",
"python"
},
indent = {
enable = true,
-- disable = {
-- "python"
-- },
},
}
M.mason = {
ensure_installed = {
-- lua stuff
"lua-language-server",
"stylua",
-- web dev stuff
"css-lsp",
"html-lsp",
"typescript-language-server",
"deno",
"prettier",
-- c/cpp stuff
"clangd",
"clang-format",
-- rust
"rust-analyzer",
-- python
"pyright",
},
}
-- git support in nvimtree
M.nvimtree = {
git = {
enable = true,
},
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
},
},
}
return M

View File

@ -0,0 +1 @@
vim.g.dap_virtual_text = true

View File

@ -0,0 +1,30 @@
local M = {}
M.dap = {
plugin = true,
n = {
["<leader>db"] = { "<cmd> DapToggleBreakpoint <CR>" },
["<leader>dus"] = {
function ()
local widgets = require('dap.ui.widgets');
local sidebar = widgets.sidebar(widgets.scopes);
sidebar.open();
end,
"Open debugging sidebar"
}
}
}
M.crates = {
plugin = true,
n = {
["<leader>rcu"] = {
function ()
require('crates').upgrade_all_crates()
end,
"update crates"
}
}
}
return M

View File

@ -0,0 +1,161 @@
local overrides = require("custom.configs.overrides")
---@type NvPluginSpec[]
local plugins = {
-- Override plugin definition options
{
"neovim/nvim-lspconfig",
dependencies = {
"jose-elias-alvarez/null-ls.nvim",
config = function()
require "custom.configs.null-ls"
end,
},
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end,
},
-- override plugin configs
{
"williamboman/mason.nvim",
opts = overrides.mason
},
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
},
{
"nvim-tree/nvim-tree.lua",
opts = overrides.nvimtree,
},
-- Debugger
{
"mfussenegger/nvim-dap",
init = function()
require("core.utils").load_mappings("dap")
end
},
{
"theHamsta/nvim-dap-virtual-text",
lazy = false,
config = function(_, opts)
require("nvim-dap-virtual-text").setup()
end
},
-- Rust
-- {
-- "simrat39/rust-tools.nvim",
-- ft = "rust",
-- dependencies = "neovim/nvim-lspconfig",
-- opts = function ()
-- return require "custom.configs.rust-tools"
-- end,
-- config = function(_, opts)
-- require('rust-tools').setup(opts)
-- end
-- },
-- {
-- 'saecki/crates.nvim',
-- ft = {"rust", "toml"},
-- config = function(_, opts)
-- local crates = require('crates')
-- crates.setup(opts)
-- require('cmp').setup.buffer({
-- sources = { { name = "crates" }}
-- })
-- crates.show()
-- require("core.utils").load_mappings("crates")
-- end,
-- },
{
"rust-lang/rust.vim",
ft = "rust",
init = function ()
vim.g.rustfmt_autosave = 1
end
},
-- Better escape (jj/jk)
{
"max397574/better-escape.nvim",
event = "InsertEnter",
config = function()
require("better_escape").setup()
end,
},
-- Signatures plugin to show function signatures as you type them
{
"ray-x/lsp_signature.nvim",
event = "BufRead",
config = function()
require("lsp_signature").setup {
hint_enable = false,
}
end,
},
-- -- Rooter plugin to change directory to the project root
-- {
-- "notjedi/nvim-rooter.lua",
-- event = "UIEnter",
-- config = function()
-- require("nvim-rooter").setup {
-- rooter_patterns = { "Makefile", ".git", ".hg", ".svn" },
-- trigger_patterns = { "*" },
-- manual = false,
-- }
-- end,
-- },
-- Leap plugin to jump to any line in the file
{
"ggandor/leap.nvim",
event = "UIEnter",
config = function() require("leap").add_default_mappings() end,
},
-- Copilot plugin to autocomplete text
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup {
suggestion = { enabled = false },
panel = { enabled = false },
filetypes = { markdown = true },
}
end,
},
-- Copilot CMP plugin to autocomplete text in the completion menu
{
"zbirenbaum/copilot-cmp",
dependencies = "zbirenbaum/copilot.lua",
event = "InsertEnter",
config = function() require("copilot_cmp").setup() end,
},
-- {
-- "hrsh7th/nvim-cmp",
-- opts = function()
-- local M = require "plugins.configs.cmp"
-- M.completion.completeopt = "menu,menuone,noselect"
-- M.mapping["<CR>"] = cmp.mapping.confirm {
-- behavior = cmp.ConfirmBehavior.Insert,
-- select = false,
-- }
-- table.insert(M.sources, {name = "crates"})
-- return M
-- end,
-- }
}
return plugins

View File

@ -1,16 +1,16 @@
return {
-- Configure AstroNvim updates
updater = {
remote = "origin", -- remote to use
channel = "stable", -- "stable" or "nightly"
version = "latest", -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY)
branch = "nightly", -- branch name (NIGHTLY ONLY)
commit = nil, -- commit hash (NIGHTLY ONLY)
pin_plugins = nil, -- nil, true, false (nil will pin plugins on stable only)
skip_prompts = false, -- skip prompts about breaking changes
remote = "origin", -- remote to use
channel = "stable", -- "stable" or "nightly"
version = "latest", -- "latest", tag name, or regex search like "v1.*" to only do updates before v2 (STABLE ONLY)
branch = "nightly", -- branch name (NIGHTLY ONLY)
commit = nil, -- commit hash (NIGHTLY ONLY)
pin_plugins = nil, -- nil, true, false (nil will pin plugins on stable only)
skip_prompts = false, -- skip prompts about breaking changes
show_changelog = true, -- show the changelog after performing an update
auto_quit = false, -- automatically quit the current session after a successful update
remotes = { -- easily add new remotes to track
auto_quit = false, -- automatically quit the current session after a successful update
remotes = { -- easily add new remotes to track
},
},
@ -18,17 +18,14 @@ return {
colorscheme = "astrodark",
-- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on
diagnostics = {
virtual_text = true,
underline = true,
},
diagnostics = { virtual_text = true, underline = true },
lsp = {
-- customize lsp formatting options
formatting = {
-- control auto formatting on save
format_on_save = {
enabled = false, -- enable or disable format on save globally
enabled = false, -- enable or disable format on save globally
allow_filetypes = { -- enable format on save for specified filetypes only
-- "go",
},
@ -57,7 +54,14 @@ return {
performance = {
rtp = {
-- customize default disabled vim plugins
disabled_plugins = { "tohtml", "gzip", "matchit", "zipPlugin", "netrwPlugin", "tarPlugin" },
disabled_plugins = {
"tohtml",
"gzip",
"matchit",
"zipPlugin",
"netrwPlugin",
"tarPlugin",
},
},
},
},
@ -66,6 +70,18 @@ return {
-- augroups/autocommands and custom filetypes also this just pure lua so
-- anything that doesn't fit in the normal config locations above can go here
polish = function()
local rt = require "rust-tools"
rt.setup {
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
end,
},
}
-- Set up custom filetypes
-- vim.filetype.add {
-- extension = {

View File

@ -35,7 +35,7 @@ return {
-- Format code
["<M-f>"] = { ":Format<cr>" },
["<leader>a"] = { ":lua require'rust-tools'.hover_actions.hover_actions()<cr>" },
-- Disable bindings
["<leader>n"] = false,
},

View File

@ -16,6 +16,7 @@ return {
"python",
"dockerfile",
"cpp",
"rust",
})
end,
}

View File

@ -50,4 +50,5 @@ return {
event = "InsertEnter",
config = function() require("copilot_cmp").setup() end,
},
'simrat39/rust-tools.nvim'
}

View File

@ -113,12 +113,20 @@ cd ~
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
# Install astronvim
printf -- '\033[33m Installing astronvim\n\033[37m'
# Install NvChad
printf -- '\033[33m Installing NvChad\n\033[37m'
if [ ! -d ~/.config/nvim ];
then git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim;
then git clone https://github.com/NvChad/NvChad ~/.config/nvim --depth 1
ln -sf ~/code_server/config/nvim/lua/custom ~/.config/nvim/lua/custom
fi
# Install astronvim
# printf -- '\033[33m Installing astronvim\n\033[37m'
# if [ ! -d ~/.config/nvim ];
# then git clone --depth 1 https://github.com/AstroNvim/AstroNvim ~/.config/nvim;
# ln -sf ~/code_server/config/nvim/lua/user ~/.config/nvim/lua/user
# fi
# Install platformio
printf -- '\033[33m Installing platformio\n\033[37m'
pip3 install platformio
@ -143,11 +151,6 @@ ln -sf ~/code_server/tmux.conf ~/.tmux.conf
printf -- '\033[33m Symlinking clang-format config\n\033[37m'
ln -sf ~/code_server/clang-format ~/.clang-format
# Symlink nvim user folder
printf -- '\033[33m Symlinking nvim user folder\n\033[37m'
if [ -L ~/.config/nvim/lua/user ]; then rm ~/.config/nvim/lua/user; fi
ln -s ~/code_server/config/nvim/lua/user ~/.config/nvim/lua/user
# Symlink lazygit config
printf -- '\033[33m Symlinking lazygit config\n\033[37m'
ln -sf ~/code_server/config/lazygit/config.yml ~/.config/lazygit/config.yml