This repository has been archived on 2024-07-10. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles-nix/nix/home/neovim/neovim.nix

122 lines
2.8 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ config, pkgs, ... }:
{
# neovim
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
# neovim config
extraConfig = ''
" Use tab for trigger completion with characters ahead and navigate.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" clipboard
set clipboard+=unnamedplus
" cursor
set guicursor=a:hor20-Cursor
set guicursor=v:block-Cursor
" terminal title
set title
" auto-complete
set completeopt=menu,menuone,longest
" show number
set number
'';
# lua config
extraLuaConfig = ''
-- set mapleader
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- set vim options
vim.opt.backspace = '2'
vim.opt.laststatus = 2
vim.opt.cursorline = true
-- set scrolloff
vim.opt.scrolloff = 10
-- indentation
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.smartindent = true
-- load plugins
require("neo-tree").setup({
filesystem = {
filtered_items = {
hide_dotfiles = false,
hide_gitignored = false,
},
},
window = {
position = "left",
width = 36,
},
})
require("neo-tree.sources.manager").show("filesystem")
-- function for new line
_G.add_new_line = function()
local n_lines = vim.api.nvim_buf_line_count(0)
local last_nonblank = vim.fn.prevnonblank(n_lines)
if last_nonblank <= n_lines then vim.api.nvim_buf_set_lines(0, last_nonblank, n_lines, true, { ''' }) end
end
vim.cmd([[
augroup AddNewlineOnSave
autocmd!
autocmd BufWritePre * lua _G.add_new_line()
augroup END
]])
'';
# auto-complete
coc = {
enable = true;
settings = {
"suggest.noselect" = true;
"suggest.enablePreview" = true;
"suggest.enablePreselect" = true;
"suggest.disableKind" = true;
"diagnostic.errorSign" = "";
"diagnostic.infoSign" = "";
"diagnostic.hintSign" = "";
};
};
# plugins
plugins = with pkgs.vimPlugins; [
neo-tree-nvim
];
};
}