we import neovim config from there yea yea

This commit is contained in:
Sakooooo 2023-07-03 02:27:02 +04:00
parent d805358f60
commit bb242e11c8
Signed by: sako
GPG key ID: 3FD715D87D7725E0
18 changed files with 422 additions and 4 deletions

3
config/neovim/README.md Normal file
View file

@ -0,0 +1,3 @@
# Neovim Config
## This used to be Sakooooo/nvimconf
but now its in Sakooooo/nixos

View file

@ -0,0 +1,3 @@
require("core.keymaps")
require("core.plugins")
require("core.plugin_config")

View file

@ -0,0 +1,54 @@
local opts = { noremap = true, silent = true }
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.opt.backspace = "2"
vim.opt.showcmd = true
vim.opt.laststatus = 2
vim.opt.autowrite = true
vim.opt.cursorline = true
vim.opt.autoread = true
-- spaces for tabs
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.shiftround = true
vim.opt.expandtab = true
-- split position
vim.opt.splitbelow = true
vim.opt.splitright = true
-- :terminal shell
if (vim.loop.os_uname().sysname == "Linux")
then
vim.opt.shell = "bash"
else
vim.opt.shell = "pwsh"
end
-- nvimtree
vim.keymap.set("n", "<leader>e", ":NvimTreeFindFileToggle<CR>", opts)
-- splits
vim.keymap.set("n", "<c-k>", ":wincmd k<CR>", opts)
vim.keymap.set("n", "<c-j>", ":wincmd j<CR>", opts)
vim.keymap.set("n", "<c-h>", ":wincmd h<CR>", opts)
vim.keymap.set("n", "<c-l>", ":wincmd l<CR>", opts)
-- resize split
vim.keymap.set("n", "<Left>", ":vertical resize +1<CR>", opts)
vim.keymap.set("n", "<Right>", ":vertical resize -1<CR>", opts)
vim.keymap.set("n", "<Up>", ":resize -1<CR>", opts)
vim.keymap.set("n", "<Down>", ":resize +1<CR>", opts)
-- make split
vim.keymap.set("n", "nsv", ":vsplit<CR>", opts)
vim.keymap.set("n", "nsh", ":split<CR>", opts)
-- terminal
vim.keymap.set("n", "<leader>t", ":split<CR> <BAR> :terminal<CR>")
-- exit terminal with esc
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>", opts)

View file

@ -0,0 +1,17 @@
local autopairs_setup, autopairs = pcall(require, "nvim-autopairs")
autopairs.setup({
check_ts = true,
ts_config = {
lua = {'string'},-- it will not add a pair on that treesitter node
javascript = {'template_string'},
java = false,-- don't check treesitter on java
}
})
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)

View file

@ -0,0 +1,27 @@
local cmp = require'cmp'
cmp.setup({
snippet= {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
["<C-e>"] = cmp.mapping.abort(), -- close completion window
["<CR>"] = cmp.mapping.confirm({ select = false }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = 'luasnip' },
{ name = "buffer" },
{ name = "path" },
})
})

View file

@ -0,0 +1,3 @@
local gitsigns = require("gitsigns")
gitsigns.setup()

View file

@ -0,0 +1,12 @@
require("core.plugin_config.lualine")
require("core.plugin_config.nvim-tree")
require("core.plugin_config.telescope")
require("core.plugin_config.treesitter")
require("core.plugin_config.lsp_config")
require("core.plugin_config.cmp_config")
require("core.plugin_config.autopairs")
require("core.plugin_config.gitsigns")
require("core.plugin_config.precense")
require("core.plugin_config.null_ls")
require("core.plugin_config.kanagawa")
require("core.plugin_config.liveserver")

View file

@ -0,0 +1,30 @@
-- Default options:
require("kanagawa").setup({
compile = false, -- enable compiling the colorscheme
undercurl = true, -- enable undercurls
commentStyle = { italic = true },
functionStyle = {},
keywordStyle = { italic = true },
statementStyle = { bold = true },
typeStyle = {},
transparent = false, -- do not set background color
dimInactive = false, -- dim inactive window `:h hl-NormalNC`
terminalColors = true, -- define vim.g.terminal_color_{0,17}
colors = {
-- add/modify theme and palette colors
palette = {},
theme = { wave = {}, lotus = {}, dragon = {}, all = {} },
},
overrides = function(colors) -- add/modify highlights
return {}
end,
theme = "dragon", -- Load "wave" theme when 'background' option is not set
background = {
-- map the value of 'background' option to a theme
dark = "dragon", -- try "dragon" !
light = "lotus",
},
})
-- setup must be called before loading
vim.cmd("colorscheme kanagawa")

View file

@ -0,0 +1,12 @@
local status_ok, live_server = pcall(require, "live_server")
if not status_ok then
return
end
live_server.setup({
port = 8080,
browser_command = "", -- Empty string starts up with default browser
quiet = false,
no_css_inject = false, -- Disables css injection if true, might be useful when testing out tailwindcss
install_path = vim.fn.stdpath("config") .. "/live-server/",
})

View file

@ -0,0 +1,79 @@
require("cmp")
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = { "lua_ls", "omnisharp", "pyright", "clangd" },
})
local mason_null_ls = require("mason-null-ls")
-- vscode
local on_attach = function(client, bufnr)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, {})
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, {})
vim.keymap.set("n", "gd", vim.lsp.buf.definition, {})
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, {})
vim.keymap.set("n", "gr", require("telescope.builtin").lsp_references, {})
vim.keymap.set("n", "K", vim.lsp.buf.hover, {})
end
-- enable autocomplete
local capabilities = require("cmp_nvim_lsp").default_capabilities()
--format thing
mason_null_ls.setup({
ensure_installed = {
"stylua",
"csharpier",
"prettier",
},
})
-- funny lsp config stuff
require("lspconfig").lua_ls.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").omnisharp.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").cmake.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").clangd.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").tsserver.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").html.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").eslint.setup({
on_attach = function(client, bufnr)
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
command = "EslintFixAll",
})
end,
})
require("lspconfig").pyright.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").cssls.setup({
on_attach = on_attach,
capabilities = capabilities,
})

View file

@ -0,0 +1,14 @@
require("lualine").setup({
options = {
icons_enabled = true,
theme = "kanagawa",
},
sections = {
lualine_a = {
{
"filename",
path = 1,
},
},
},
})

View file

@ -0,0 +1,28 @@
local null_ls = require("null-ls")
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
null_ls.setup({
sources = {
formatting.prettier,
formatting.stylua,
formatting.csharpier,
formatting.clang_format,
diagnostics.cpplint,
},
on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ buffer })
end,
})
end
end,
})

View file

@ -0,0 +1,4 @@
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
require("nvim-tree").setup()

View file

@ -0,0 +1,22 @@
require("presence").setup({
-- options
auto_update = true,
neovim_image_text = "mama mia",
main_image = "neovim",
client_id = "793271441293967371",
log_level = nil,
debounce_timeout = 10,
enable_line_number = false,
blacklist = {},
file_assets = {},
show_time = true,
-- the text
editing_text = "editing %s",
file_explorer_text = "file explorer",
git_commit_text = "git comit",
plugin_manager_text = "adding bloatware",
reading_text = "reading %s",
workspace_text = "workspace: %s",
line_number_text = "line %s out of %s",
})

View file

@ -0,0 +1,6 @@
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<c-p>', builtin.find_files, {})
vim.keymap.set('n', '<Space><Space>', builtin.oldfiles, {})
vim.keymap.set('n', '<Space>fg', builtin.live_grep, {})
vim.keymap.set('n', '<Space>fh', builtin.help_tags, {})

View file

@ -0,0 +1,18 @@
require'nvim-treesitter.configs'.setup{
-- A list of parser names, or "all"
-- TODO: figure this out
ensure_installed = {"c",
"cpp",
"c_sharp",
"lua",
"python",
"vim"},
-- Install parsers synchronously (only applied to 'ensure_installed)
sync_install = false,
auto_install = true,
highlight = {
enable = true,
},
indent = { enable = true }
}

View file

@ -0,0 +1,81 @@
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
vim.cmd([[packadd packer.nvim]])
return true
end
return false
end
local packer_bootstrap = ensure_packer()
-- plugins go here
return require("packer").startup(function(use)
-- the package manager
use("wbthomason/packer.nvim")
-- whats an ide without a file explorer
use("nvim-tree/nvim-tree.lua")
use("nvim-tree/nvim-web-devicons")
-- default bar only looks good on linux
use("nvim-lualine/lualine.nvim")
-- colorschemes
use("rebelot/kanagawa.nvim")
-- syntax highlighting apparently
use("nvim-treesitter/nvim-treesitter")
-- like fzf but goofier
use({
"nvim-telescope/telescope.nvim",
tag = "0.1.1",
requires = { { "nvim-lua/plenary.nvim" } },
})
-- lsp stuff
use({
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"neovim/nvim-lspconfig",
})
-- le completion
use("hrsh7th/nvim-cmp")
use("hrsh7th/cmp-buffer")
use("hrsh7th/cmp-path")
use("hrsh7th/cmp-nvim-lsp")
use("onsails/lspkind.nvim")
-- snippet
use("L3MON4D3/LuaSnip")
use("saadparwaiz1/cmp_luasnip")
-- auto close to prevent carpal tunnel :)
use("windwp/nvim-autopairs")
-- git stuff lol
use("lewis6991/gitsigns.nvim")
-- linting
use("jose-elias-alvarez/null-ls.nvim")
use("jayp0521/mason-null-ls.nvim")
-- flex
use("andweeb/presence.nvim")
-- live server
use({
"aurum77/live-server.nvim",
run = function()
require("live_server.util").install()
end,
cmd = { "LiveServer", "LiveServerStart", "LiveServerStop" },
})
-- auto update just like vscode
if packer_bootstrap then
require("packer").sync()
end
end)

View file

@ -140,6 +140,8 @@
lutris
discord
networkmanagerapplet
gcc
python3
];
};
@ -158,10 +160,13 @@
userName = "Sakooooo";
userEmail = "78461130+Sakooooo@users.noreply.github.com";
};
programs.neovim = {
enable = true;
extraConfig = builtins.readFile config/neovim/init.lua;
};
xdg.configFile = {
nvim = {
source = config/neovim;
recursive = true;
};
};
};