mirror of
https://github.com/Nickiel12/nicks-nix-config.git
synced 2024-11-22 12:49:32 -08:00
added basic features for usable nvim
This commit is contained in:
parent
8e2e18eac9
commit
fafb89f62f
6 changed files with 265 additions and 118 deletions
|
@ -96,6 +96,7 @@
|
||||||
users.${user} = {
|
users.${user} = {
|
||||||
imports = [
|
imports = [
|
||||||
(import ./users/${user}.nix)
|
(import ./users/${user}.nix)
|
||||||
|
# Add nixvim to the homemanager
|
||||||
inputs.nixvim.homeManagerModules.nixvim
|
inputs.nixvim.homeManagerModules.nixvim
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,87 @@ in
|
||||||
enable = true;
|
enable = true;
|
||||||
viAlias = true;
|
viAlias = true;
|
||||||
vimAlias = true;
|
vimAlias = true;
|
||||||
#extraConfigVim = import ./../rsrcs/.vimrc;
|
|
||||||
|
globals = {
|
||||||
|
mapleader = " ";
|
||||||
|
};
|
||||||
|
|
||||||
|
options = {
|
||||||
|
autoindent = true;
|
||||||
|
expandtab = true;
|
||||||
|
foldlevel=20;
|
||||||
|
guifont = "MesloLGS\ NF\ 10";
|
||||||
|
number = true;
|
||||||
|
shiftwidth = 4;
|
||||||
|
tabstop = 4;
|
||||||
|
};
|
||||||
|
|
||||||
|
# https://github.com/pupbrained/nix-config/blob/29af4835f21940af51b86313c451fb572a29874a/pkgs/nixvim.nix#L8
|
||||||
|
# maps.
|
||||||
|
|
||||||
|
plugins = {
|
||||||
|
|
||||||
|
telescope = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
treesitter = {
|
||||||
|
enable = true;
|
||||||
|
folding = true;
|
||||||
|
indent = true;
|
||||||
|
ensureInstalled = [
|
||||||
|
"rust"
|
||||||
|
"toml"
|
||||||
|
"lua"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
treesitter-rainbow = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
treesitter-refactor = {
|
||||||
|
enable = true;
|
||||||
|
#highlightCurrentScope.enable = true;
|
||||||
|
navigation.enable = true;
|
||||||
|
smartRename.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
comment-nvim = {
|
||||||
|
enable = true;
|
||||||
|
toggler = {
|
||||||
|
line = "<C-/>";
|
||||||
|
block = "<C-'>";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
floaterm = {
|
||||||
|
enable = true;
|
||||||
|
position = "auto";
|
||||||
|
keymaps = {
|
||||||
|
toggle = "<leader>t";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
rust-tools.enable = true;
|
||||||
|
nvim-cmp.enable = true;
|
||||||
|
|
||||||
|
cmp-nvim-lsp.enable = true;
|
||||||
|
# Read settings here: https://github.com/mfussenegger/nvim-dap#Usage
|
||||||
|
# See :help dap.txt, :help dap-mapping and :help dap-api.
|
||||||
|
cmp-dap.enable = true;
|
||||||
|
|
||||||
|
cmp-vsnip.enable = true;
|
||||||
|
cmp-buffer.enable = true;
|
||||||
|
cmp-nvim-lsp-signature-help.enable = true;
|
||||||
|
cmp-nvim-lua.enable = true;
|
||||||
|
cmp-path.enable = true;
|
||||||
|
|
||||||
|
nix.enable = true;
|
||||||
|
airline = {
|
||||||
|
enable = true;
|
||||||
|
powerline = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
extraConfigLua = builtins.readFile ./../rsrcs/nvim.lua;
|
||||||
extraPlugins = with pkgs.vimPlugins;
|
extraPlugins = with pkgs.vimPlugins;
|
||||||
let
|
let
|
||||||
moonfly = pkgs.vimUtils.buildVimPlugin {
|
moonfly = pkgs.vimUtils.buildVimPlugin {
|
||||||
|
@ -20,26 +100,10 @@ in
|
||||||
};
|
};
|
||||||
in [
|
in [
|
||||||
# Themes and statusbar
|
# Themes and statusbar
|
||||||
# vim-airline
|
|
||||||
# vim-airline-themes
|
|
||||||
# moonfly
|
# moonfly
|
||||||
|
|
||||||
#QoL features
|
nvim-lspconfig
|
||||||
# telescope-nvim
|
hop-nvim
|
||||||
# nvim-treesitter
|
|
||||||
|
|
||||||
nvchad
|
|
||||||
nvchad-ui
|
|
||||||
|
|
||||||
# Rust
|
|
||||||
coc-rust-analyzer
|
|
||||||
coc-nvim
|
|
||||||
rust-vim
|
|
||||||
|
|
||||||
# Language support
|
|
||||||
vim-nix
|
|
||||||
typescript-vim
|
|
||||||
vim-javascript
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
49
modules/old-neovim.nix
Normal file
49
modules/old-neovim.nix
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
programs.neovim = {
|
||||||
|
enable = true;
|
||||||
|
vimAlias = true;
|
||||||
|
defaultEditor = true;
|
||||||
|
plugins = with pkgs.vimPlugins;
|
||||||
|
let
|
||||||
|
moonfly = pkgs.vimUtils.buildVimPlugin {
|
||||||
|
name = "moonfly";
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "bluz71";
|
||||||
|
repo = "vim-moonfly-colors";
|
||||||
|
rev = "d51e3ad78654aa479d59adb81a98f179d595bdee";
|
||||||
|
sha256 = "0uHEB8uNQeGpVWuZfyrVAWTyefJMCitTmNpHmKVFOaQ=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in [
|
||||||
|
# Themes and statusbar
|
||||||
|
# vim-airline
|
||||||
|
# vim-airline-themes
|
||||||
|
# moonfly
|
||||||
|
|
||||||
|
#QoL features
|
||||||
|
# telescope-nvim
|
||||||
|
# nvim-treesitter
|
||||||
|
|
||||||
|
nvchad
|
||||||
|
nvchad-ui
|
||||||
|
|
||||||
|
# Rust
|
||||||
|
coc-rust-analyzer
|
||||||
|
coc-nvim
|
||||||
|
rust-vim
|
||||||
|
|
||||||
|
# Language support
|
||||||
|
vim-nix
|
||||||
|
typescript-vim
|
||||||
|
vim-javascript
|
||||||
|
];
|
||||||
|
|
||||||
|
# extraConfig = builtins.readFile ../rsrcs/.vimrc;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
99
rsrcs/.vimrc
99
rsrcs/.vimrc
|
@ -1,99 +0,0 @@
|
||||||
set autoindent
|
|
||||||
set expandtab
|
|
||||||
set tabstop=4
|
|
||||||
set shiftwidth=4
|
|
||||||
set foldmethod=syntax
|
|
||||||
set foldlevel=20
|
|
||||||
set number
|
|
||||||
set guifont=MesloLGS\ NF\ 10
|
|
||||||
syntax on
|
|
||||||
syntax enable
|
|
||||||
filetype plugin indent on
|
|
||||||
|
|
||||||
|
|
||||||
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
|
||||||
" nvim-treesitter
|
|
||||||
" delays and poor user experience.
|
|
||||||
set updatetime=300
|
|
||||||
|
|
||||||
set signcolumn=number
|
|
||||||
|
|
||||||
let g:airline_powerline_fonts=1
|
|
||||||
let g:typescript_compiler_binary = 'npx tsc'
|
|
||||||
|
|
||||||
" Use tab for trigger completion with characters ahead and navigate.
|
|
||||||
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
|
||||||
" other plugin before putting this into your config.
|
|
||||||
inoremap <silent><expr> <TAB>
|
|
||||||
\ pumvisible() ? "\<C-n>" :
|
|
||||||
\ CheckBackspace() ? "\<TAB>" :
|
|
||||||
\ coc#refresh()
|
|
||||||
|
|
||||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
|
||||||
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
|
|
||||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
|
||||||
|
|
||||||
function! CheckBackspace() abort
|
|
||||||
let col = col('.') - 1
|
|
||||||
return !col || getline('.')[col - 1] =~# '\s'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Use <c-space> to trigger completion.
|
|
||||||
inoremap <silent><expr> <c-space> coc#refresh()
|
|
||||||
|
|
||||||
|
|
||||||
" Use `[g` and `]g` to navigate diagnostics
|
|
||||||
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
|
||||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
|
||||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
|
||||||
|
|
||||||
" GoTo code navigation.
|
|
||||||
nmap <silent> gd <Plug>(coc-definition)
|
|
||||||
nmap <silent> gy <Plug>(coc-type-definition)
|
|
||||||
nmap <silent> gi <Plug>(coc-implementation)
|
|
||||||
nmap <silent> gr <Plug>(coc-references)
|
|
||||||
|
|
||||||
" Use K to show documentation in preview window.
|
|
||||||
nnoremap <silent> K :call ShowDocumentation()<CR>
|
|
||||||
|
|
||||||
function! ShowDocumentation()
|
|
||||||
if CocAction('hasProvider', 'hover')
|
|
||||||
call CocActionAsync('doHover')
|
|
||||||
else
|
|
||||||
call feedkeys('K', 'in')
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Highlight the symbol and its references when holding the cursor.
|
|
||||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
|
||||||
|
|
||||||
" Symbol renaming.
|
|
||||||
nmap <leader>rn <Plug>(coc-rename)
|
|
||||||
|
|
||||||
" Formatting selected code.
|
|
||||||
xmap <leader>f <Plug>(coc-format-selected)
|
|
||||||
nmap <leader>f <Plug>(coc-format-selected)
|
|
||||||
let g:rustfmt_autosave = 1
|
|
||||||
|
|
||||||
" Add `:Format` command to format current buffer.
|
|
||||||
command! -nargs=0 Format :call CocActionAsync('format')
|
|
||||||
|
|
||||||
" Add `:Fold` command to fold current buffer.
|
|
||||||
command! -nargs=? Fold :call CocAction('fold', <f-args>)
|
|
||||||
|
|
||||||
" Add `:OR` command for organize imports of the current buffer.
|
|
||||||
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport')
|
|
||||||
|
|
||||||
" Add (Neo)Vim's native statusline support.
|
|
||||||
" NOTE: Please see `:h coc-status` for integrations with external plugins that
|
|
||||||
" provide custom statusline: lightline.vim, vim-airline.
|
|
||||||
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
|
|
||||||
|
|
||||||
|
|
||||||
" colorscheme moonfly
|
|
||||||
set number
|
|
||||||
|
|
||||||
" Remove moonfly's background color for the terminal color
|
|
||||||
" highlight Normal ctermbg=NONE
|
|
||||||
" highlight LineNr ctermbg=NONE
|
|
||||||
" highlight CocInlayHint ctermbg=NONE
|
|
130
rsrcs/nvim.lua
Normal file
130
rsrcs/nvim.lua
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
|
||||||
|
-- Attached rust-analyzer server
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- LSP Diagnostics Options Setup
|
||||||
|
local sign = function(opts)
|
||||||
|
vim.fn.sign_define(opts.name, {
|
||||||
|
texthl = opts.name,
|
||||||
|
text = opts.text,
|
||||||
|
numhl = ''
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
sign({name = 'DiagnosticSignError', text = ''})
|
||||||
|
sign({name = 'DiagnosticSignWarn', text = ''})
|
||||||
|
sign({name = 'DiagnosticSignHint', text = ''})
|
||||||
|
sign({name = 'DiagnosticSignInfo', text = ''})
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_text = false,
|
||||||
|
signs = true,
|
||||||
|
update_in_insert = true,
|
||||||
|
underline = true,
|
||||||
|
severity_sort = false,
|
||||||
|
float = {
|
||||||
|
border = 'rounded',
|
||||||
|
source = 'always',
|
||||||
|
header = '',
|
||||||
|
prefix = '',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.cmd([[
|
||||||
|
set signcolumn=yes
|
||||||
|
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
||||||
|
]])
|
||||||
|
|
||||||
|
|
||||||
|
--Set completeopt to have a better completion experience
|
||||||
|
-- :help completeopt
|
||||||
|
-- menuone: popup even when there's only one match
|
||||||
|
-- noinsert: Do not insert text until a selection is made
|
||||||
|
-- noselect: Do not select, force to select one from the menu
|
||||||
|
-- shortness: avoid showing extra messages when using completion
|
||||||
|
-- updatetime: set updatetime for CursorHold
|
||||||
|
vim.opt.shortmess = vim.opt.shortmess + { c = true}
|
||||||
|
vim.api.nvim_set_option('updatetime', 300)
|
||||||
|
|
||||||
|
-- Fixed column for diagnostics to appear
|
||||||
|
-- Show autodiagnostic popup on cursor hover_range
|
||||||
|
-- Goto previous / next diagnostic warning / error
|
||||||
|
-- Show inlay_hints more frequently
|
||||||
|
vim.cmd([[
|
||||||
|
set signcolumn=yes
|
||||||
|
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- Completion Plugin Setup
|
||||||
|
local cmp = require'cmp'
|
||||||
|
cmp.setup({
|
||||||
|
-- Enable LSP snippets
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
vim.fn["vsnip#anonymous"](args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
-- Add tab support
|
||||||
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.close(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({
|
||||||
|
behavior = cmp.ConfirmBehavior.Insert,
|
||||||
|
select = true,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
-- Installed sources:
|
||||||
|
sources = {
|
||||||
|
{ name = 'path' }, -- file paths
|
||||||
|
{ name = 'nvim_lsp', keyword_length = 3 }, -- from language server
|
||||||
|
{ name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
|
||||||
|
{ name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
|
||||||
|
{ name = 'buffer', keyword_length = 2 }, -- source current buffer
|
||||||
|
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
|
||||||
|
{ name = 'calc'}, -- source for math calculation
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
fields = {'menu', 'abbr', 'kind'},
|
||||||
|
format = function(entry, item)
|
||||||
|
local menu_icon ={
|
||||||
|
nvim_lsp = 'λ',
|
||||||
|
vsnip = '⋗',
|
||||||
|
buffer = 'Ω',
|
||||||
|
path = '🖫',
|
||||||
|
}
|
||||||
|
item.menu = menu_icon[entry.source.name]
|
||||||
|
return item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- https://github.com/phaazon/hop.nvim/wiki/Advanced-Hop
|
||||||
|
local hop = require('hop')
|
||||||
|
hop.setup {
|
||||||
|
keys = 'etovxqpdygfblzhckisuran',
|
||||||
|
}
|
||||||
|
local directions = require('hop.hint').HintDirection
|
||||||
|
vim.keymap.set('', '<C-f>', function()
|
||||||
|
hop.hint_patterns({ multi_windows = true, current_line_only = false })
|
||||||
|
end, {remap=true})
|
|
@ -12,6 +12,8 @@ in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
ruststable
|
ruststable
|
||||||
|
rust-analyzer
|
||||||
|
lldb
|
||||||
];
|
];
|
||||||
|
|
||||||
RUST_BACKTRACE = 1;
|
RUST_BACKTRACE = 1;
|
||||||
|
|
Loading…
Reference in a new issue