initial configuration
This commit is contained in:
11
modules/home/programs/neovim/autocmd.lua
Normal file
11
modules/home/programs/neovim/autocmd.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
local api = vim.api
|
||||
|
||||
api.nvim_create_autocmd(
|
||||
"FileType",
|
||||
{ pattern = "markdown", command = "setlocal spell" }
|
||||
)
|
||||
|
||||
api.nvim_create_autocmd(
|
||||
"FileType",
|
||||
{ pattern = "markdown", command = "setlocal complete+=kspell" }
|
||||
)
|
4
modules/home/programs/neovim/colorscheme.lua
Normal file
4
modules/home/programs/neovim/colorscheme.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
require('onedark').setup {
|
||||
style = 'deep'
|
||||
}
|
||||
require('onedark').load()
|
126
modules/home/programs/neovim/default.nix
Normal file
126
modules/home/programs/neovim/default.nix
Normal file
@@ -0,0 +1,126 @@
|
||||
{
|
||||
inputs,
|
||||
outputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
home.packages = with pkgs; [
|
||||
ripgrep
|
||||
marksman
|
||||
wl-clipboard
|
||||
];
|
||||
|
||||
programs.neovim =
|
||||
let
|
||||
toLua = str: "lua << EOF\n${str}\nEOF\n";
|
||||
toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n";
|
||||
in
|
||||
{
|
||||
enable = true;
|
||||
coc = {
|
||||
enable = false;
|
||||
settings = {
|
||||
languageserver = {
|
||||
arduino = {
|
||||
command = ["steam-run" "arduino-language-server"];
|
||||
rootPatterns = ["*.ino"];
|
||||
filetypes = ["arduino"];
|
||||
args = ["-cli" "steam-run" "arduino-cli" "-clangd" "steam-run" "clangd" "-cli-config" "/home/xeovalyte/.arduino15/arduino-cli.yaml"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
vimdiffAlias = true;
|
||||
|
||||
extraLuaConfig = ''
|
||||
${builtins.readFile ./options.lua}
|
||||
${builtins.readFile ./keymaps.lua}
|
||||
${builtins.readFile ./autocmd.lua}
|
||||
'';
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
nvim-web-devicons
|
||||
|
||||
{
|
||||
plugin = nvim-autopairs;
|
||||
config = toLua "require(\"nvim-autopairs\").setup{}";
|
||||
}
|
||||
|
||||
{
|
||||
plugin = telescope-nvim;
|
||||
}
|
||||
plenary-nvim
|
||||
|
||||
{
|
||||
plugin = nvim-lspconfig;
|
||||
config = toLuaFile ./plugins/lsp.lua;
|
||||
}
|
||||
neodev-nvim
|
||||
mason-nvim
|
||||
mason-lspconfig-nvim
|
||||
which-key-nvim
|
||||
rustaceanvim
|
||||
lsp-inlayhints-nvim
|
||||
nvim-dap
|
||||
|
||||
{
|
||||
plugin = markdown-preview-nvim;
|
||||
config = toLuaFile ./plugins/markdown-preview.lua;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = nvim-cmp;
|
||||
config = toLuaFile ./plugins/cmp.lua;
|
||||
}
|
||||
cmp_luasnip
|
||||
cmp-nvim-lsp
|
||||
luasnip
|
||||
friendly-snippets
|
||||
|
||||
{
|
||||
plugin = nvim-tree-lua;
|
||||
config = toLuaFile ./plugins/nvim-tree.lua;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = toggleterm-nvim;
|
||||
config = toLuaFile ./plugins/toggleterm.lua;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = (nvim-treesitter.withPlugins (p: [
|
||||
p.tree-sitter-nix
|
||||
p.tree-sitter-bash
|
||||
p.tree-sitter-json
|
||||
p.tree-sitter-rust
|
||||
p.tree-sitter-vue
|
||||
p.tree-sitter-arduino
|
||||
p.tree-sitter-html
|
||||
p.tree-sitter-css
|
||||
p.tree-sitter-javascript
|
||||
]));
|
||||
config = toLuaFile ./plugins/treesitter.lua;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = onedark-nvim;
|
||||
config = toLuaFile ./colorscheme.lua;
|
||||
}
|
||||
|
||||
{
|
||||
plugin = presence-nvim;
|
||||
config = toLua "require(\"presence\").setup()";
|
||||
}
|
||||
|
||||
{
|
||||
plugin = bufferline-nvim;
|
||||
config = toLuaFile ./plugins/bufferline.lua;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
90
modules/home/programs/neovim/keymaps.lua
Normal file
90
modules/home/programs/neovim/keymaps.lua
Normal file
@@ -0,0 +1,90 @@
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
opts = opts or {}
|
||||
opts.silent = opts.silent ~= false
|
||||
if opts.remap and not vim.g.vscode then
|
||||
opts.remap = nil
|
||||
end
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
|
||||
-- better up/down
|
||||
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||
map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||
|
||||
-- Move to window using the <ctrl> hjkl keys
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window", remap = true })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window", remap = true })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window", remap = true })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window", remap = true })
|
||||
|
||||
-- Resize window using <ctrl> arrow keys
|
||||
map("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
|
||||
map("n", "<C-Down>", "<cmd>resize -2<cr>", { desc = "Decrease window height" })
|
||||
map("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "Decrease window width" })
|
||||
map("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Increase window width" })
|
||||
|
||||
-- Move Lines
|
||||
map("n", "<A-j>", "<cmd>m .+1<cr>==", { desc = "Move down" })
|
||||
map("n", "<A-k>", "<cmd>m .-2<cr>==", { desc = "Move up" })
|
||||
map("i", "<A-j>", "<esc><cmd>m .+1<cr>==gi", { desc = "Move down" })
|
||||
map("i", "<A-k>", "<esc><cmd>m .-2<cr>==gi", { desc = "Move up" })
|
||||
map("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move down" })
|
||||
map("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move up" })
|
||||
|
||||
-- Clear search with <esc>
|
||||
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
|
||||
|
||||
-- Clear search, diff update and redraw
|
||||
-- taken from runtime/lua/_editor.lua
|
||||
map(
|
||||
"n",
|
||||
"<leader>ur",
|
||||
"<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>",
|
||||
{ desc = "Redraw / clear hlsearch / diff update" }
|
||||
)
|
||||
|
||||
-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n
|
||||
map("n", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
||||
map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
||||
map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
|
||||
map("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
||||
map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
||||
map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
|
||||
|
||||
-- Add undo break-points
|
||||
map("i", ",", ",<c-g>u")
|
||||
map("i", ".", ".<c-g>u")
|
||||
map("i", ";", ";<c-g>u")
|
||||
|
||||
-- save file
|
||||
map({ "i", "x", "n", "s" }, "<C-s>", "<cmd>w<cr><esc>", { desc = "Save file" })
|
||||
|
||||
--keywordprg
|
||||
map("n", "<leader>K", "<cmd>norm! K<cr>", { desc = "Keywordprg" })
|
||||
|
||||
-- better indenting
|
||||
map("v", "<", "<gv")
|
||||
map("v", ">", ">gv")
|
||||
|
||||
-- new file
|
||||
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
|
||||
|
||||
-- Toggle NeoTree
|
||||
map("n", "<leader>e", "<cmd>NvimTreeToggle<cr>", { desc = "Toggle file explorer" })
|
||||
|
||||
-- Telescope
|
||||
map("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Telescope find files" })
|
||||
map("n", "<leader>fg", "<cmd>Telescope live_grep<cr>", { desc = "Telescope find files" })
|
||||
map("n", "<leader>fb", "<cmd>Telescope buffers<cr>", { desc = "Telescope find files" })
|
||||
|
||||
-- LSP
|
||||
map("n", "gl", "<cmd>lua vim.diagnostic.open_float()<cr>", { desc = "Show diagnostics" })
|
||||
map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<cr>", { desc = "Show diagnostics" })
|
||||
map("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<cr>", { desc = "Show diagnostics" })
|
||||
map("n", "K", "<cmd>lua vim.lsp.buf.hover()<cr>", { desc = "Show diagnostics" })
|
||||
|
||||
-- Buffers
|
||||
map("n", "<Tab>", "<cmd>bn<cr>", { desc = "Cycle to next buffer" })
|
||||
map("n", "<S-Tab>", "<cmd>bp<cr>", { desc = "Cycle to previous buffer" })
|
||||
map("n", "bq", "<cmd>b#|bd#<cr>", { desc = "Close current buffer" })
|
||||
map("n", "<leader>bq", "<cmd>BufferLineCloseOthers<cr>", { desc = "Close all other buffers" })
|
57
modules/home/programs/neovim/options.lua
Normal file
57
modules/home/programs/neovim/options.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
|
||||
local opt = vim.opt
|
||||
|
||||
opt.autowrite = true -- Enable auto write
|
||||
opt.clipboard = "unnamedplus" -- Sync with system clipboard
|
||||
opt.completeopt = "menu,menuone,noselect"
|
||||
opt.conceallevel = 3 -- Hide * markup for bold and italic
|
||||
opt.confirm = true -- Confirm to save changes before exiting modified buffer
|
||||
opt.cursorline = true -- Enable highlighting of the current line
|
||||
opt.expandtab = true -- Use spaces instead of tabs
|
||||
opt.formatoptions = "jcroqlnt" -- tcqj
|
||||
opt.grepformat = "%f:%l:%c:%m"
|
||||
opt.grepprg = "rg --vimgrep"
|
||||
opt.ignorecase = true -- Ignore case
|
||||
opt.inccommand = "nosplit" -- preview incremental substitute
|
||||
opt.laststatus = 0
|
||||
opt.list = true -- Show some invisible characters (tabs...
|
||||
opt.mouse = "a" -- Enable mouse mode
|
||||
opt.number = true -- Print line number
|
||||
opt.pumblend = 10 -- Popup blend
|
||||
opt.pumheight = 10 -- Maximum number of entries in a popup
|
||||
opt.relativenumber = true -- Relative line numbers
|
||||
opt.scrolloff = 4 -- Lines of context
|
||||
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
|
||||
opt.shiftround = true -- Round indent
|
||||
opt.shiftwidth = 2 -- Size of an indent
|
||||
opt.shortmess:append({ W = true, I = true, c = true })
|
||||
opt.showmode = false -- Dont show mode since we have a statusline
|
||||
opt.sidescrolloff = 8 -- Columns of context
|
||||
opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
|
||||
opt.smartcase = true -- Don't ignore case with capitals
|
||||
opt.smartindent = true -- Insert indents automatically
|
||||
opt.spelllang = { "en", "nl" }
|
||||
opt.spell = false -- Enable spell
|
||||
opt.splitbelow = true -- Put new windows below current
|
||||
opt.splitright = true -- Put new windows right of current
|
||||
opt.tabstop = 2 -- Number of spaces tabs count for
|
||||
opt.termguicolors = true -- True color support
|
||||
opt.timeoutlen = 300
|
||||
opt.undofile = true
|
||||
opt.undolevels = 10000
|
||||
opt.updatetime = 200 -- Save swap file and trigger CursorHold
|
||||
opt.wildmode = "longest:full,full" -- Command-line completion mode
|
||||
opt.winminwidth = 5 -- Minimum window width
|
||||
opt.wrap = false -- Disable line wrap
|
||||
|
||||
if vim.fn.has("nvim-0.9.0") == 1 then
|
||||
opt.splitkeep = "screen"
|
||||
opt.shortmess:append({ C = true })
|
||||
end
|
||||
|
||||
-- Fix markdown indentation settings
|
||||
vim.g.markdown_recommended_style = 0
|
||||
|
||||
vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
|
12
modules/home/programs/neovim/plugins/bufferline.lua
Normal file
12
modules/home/programs/neovim/plugins/bufferline.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
require('bufferline').setup{
|
||||
options = {
|
||||
offsets = {
|
||||
{
|
||||
filetype = "NvimTree",
|
||||
text = "File Explorer",
|
||||
highlight = "Directory",
|
||||
separator = true -- use a "true" to enable the default, or set your own character
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
modules/home/programs/neovim/plugins/cmp.lua
Normal file
46
modules/home/programs/neovim/plugins/cmp.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
luasnip.config.setup {}
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete {},
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
},
|
||||
}
|
42
modules/home/programs/neovim/plugins/lsp.lua
Normal file
42
modules/home/programs/neovim/plugins/lsp.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
require("mason").setup{
|
||||
PATH = "append",
|
||||
}
|
||||
require("mason-lspconfig").setup()
|
||||
require('neodev').setup()
|
||||
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
vim.g.rustaceanvim = {
|
||||
inlay_hints = {
|
||||
highlight = "NonText",
|
||||
},
|
||||
tools = {
|
||||
hover_actions = {
|
||||
auto_focus = true,
|
||||
},
|
||||
},
|
||||
server = {
|
||||
on_attach = function(client, bufnr)
|
||||
require("lsp-inlayhints").on_attach(client, bufnr)
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
lspconfig.tsserver.setup{}
|
||||
|
||||
lspconfig.spyglassmc_language_server.setup{}
|
||||
|
||||
lspconfig.arduino_language_server.setup{
|
||||
cmd = {
|
||||
"steam-run","arduino-language-server",
|
||||
"-cli-config", "/home/xeovalyte/.arduino15/arduino-cli.yaml",
|
||||
"-cli", "/usr/bin/arduino-cli",
|
||||
"-clangd", "steam-run clangd"
|
||||
}
|
||||
}
|
||||
|
||||
lspconfig.tailwindcss.setup{}
|
||||
|
||||
lspconfig.volar.setup{}
|
||||
|
||||
lspconfig.marksman.setup{}
|
@@ -0,0 +1,2 @@
|
||||
vim.g.mkdp_auto_start = 0
|
||||
vim.g.mkdp_auto_close = 0
|
20
modules/home/programs/neovim/plugins/nvim-tree.lua
Normal file
20
modules/home/programs/neovim/plugins/nvim-tree.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
local function my_on_attach(bufnr)
|
||||
local api = require "nvim-tree.api"
|
||||
|
||||
local function opts(desc)
|
||||
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
|
||||
end
|
||||
|
||||
-- default mappings
|
||||
api.config.mappings.default_on_attach(bufnr)
|
||||
|
||||
-- custom mappings
|
||||
vim.keymap.set('n', '<C-t>', api.tree.change_root_to_parent, opts('Up'))
|
||||
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help'))
|
||||
vim.keymap.set('n', '.', api.tree.change_root_to_node, opts('CD'))
|
||||
end
|
||||
|
||||
-- pass to setup along with your other options
|
||||
require("nvim-tree").setup {
|
||||
on_attach = my_on_attach,
|
||||
}
|
7
modules/home/programs/neovim/plugins/toggleterm.lua
Normal file
7
modules/home/programs/neovim/plugins/toggleterm.lua
Normal file
@@ -0,0 +1,7 @@
|
||||
require("toggleterm").setup{
|
||||
open_mapping = [[<c-\>]],
|
||||
direction = 'float',
|
||||
float_opts = {
|
||||
border = 'curved'
|
||||
}
|
||||
}
|
9
modules/home/programs/neovim/plugins/treesitter.lua
Normal file
9
modules/home/programs/neovim/plugins/treesitter.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
require("nvim-treesitter.configs").setup{
|
||||
ensure_installed = {},
|
||||
|
||||
auto_install = false,
|
||||
|
||||
highlight = { enable = true },
|
||||
|
||||
indent = { enable = true },
|
||||
}
|
Reference in New Issue
Block a user