diff --git a/home-manager/cli/default.nix b/home-manager/cli/default.nix index 233cf63..1eb4ae3 100644 --- a/home-manager/cli/default.nix +++ b/home-manager/cli/default.nix @@ -5,7 +5,7 @@ ./git.nix ./pass.nix ./gnupg.nix - ./neovim.nix + ./neovim ./vifm ./bat.nix ./eza.nix diff --git a/home-manager/cli/neovim.nix b/home-manager/cli/neovim.nix deleted file mode 100644 index c617286..0000000 --- a/home-manager/cli/neovim.nix +++ /dev/null @@ -1,397 +0,0 @@ -{ pkgs, config, ... }: -let - nvim-spell-fr-utf8-dictionary = builtins.fetchurl { - url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.spl"; - sha256 = "abfb9702b98d887c175ace58f1ab39733dc08d03b674d914f56344ef86e63b61"; - }; - - nvim-spell-fr-utf8-suggestions = builtins.fetchurl { - url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug"; - sha256 = "0294bc32b42c90bbb286a89e23ca3773b7ef50eff1ab523b1513d6a25c6b3f58"; - }; -in -{ - - home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.spl".source = nvim-spell-fr-utf8-dictionary; - home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.sug".source = nvim-spell-fr-utf8-suggestions; - programs.neovim = { - enable = true; - defaultEditor = true; - vimAlias = true; - withNodeJs = true; - withPython3 = true; - extraLuaConfig = '' - -- General Option - vim.g.mapleader = " " - vim.g.maplocalleader = " " - - vim.opt.autoindent = true - vim.opt.background = 'dark' - vim.opt.backupdir = os.getenv("HOME") .. '/.local/tmp/nvim' - vim.opt.clipboard = 'unnamedplus' --Use system clipboard - vim.opt.colorcolumn = '80' - vim.opt.directory = os.getenv("HOME") .. '/.local/tmp/nvim' - vim.opt.expandtab = true - vim.opt.foldmethod = 'syntax' - vim.opt.gdefault = true -- search: all occurrences by default - vim.opt.hlsearch = true -- search: hightlight terms - vim.opt.ignorecase = true - vim.opt.incsearch = true - vim.opt.laststatus = 1 - -- show special character - vim.opt.listchars = {tab = '→ ', trail = '␣', eol = '', extends = '…' } - - vim.opt.signcolumn = "yes" -- alway show sign column - vim.opt.number = true - vim.opt.relativenumber = true - vim.opt.cursorline = true -- highlight current line - vim.opt.shiftwidth = 4 - vim.opt.showmatch = true - vim.opt.smartcase = true -- search: try :to be smart about cases - vim.opt.smartindent = true - vim.opt.tabstop = 4 - vim.opt.termguicolors = true -- 24 bits color support - vim.opt.wildmenu = true -- activate enhanced user menu - vim.opt.wildmode = 'lastused:full,list' -- enhance menu - vim.opt.pumheight = 10 - vim.opt.pumwidth = 50 - vim.opt.pumblend = 10 - - -- Options than need vim.cmd - -- vim.cmd('syntax on') - - -- -- Code Fold - -- "Load and save view atomatocally (save and restore fold) - vim.cmd('au BufWinLeave *.* mkview') - vim.cmd('au BufWinEnter *.* silent! loadview') - - - -- Diagnostic settings - -- - -- diagnostic windows must be float - vim.diagnostic.config { - virtual_text = false, - signs = true, - underline = true, - } - - local signs = { Error = "", Warn = "", Hint = "󰌶", Info = "" } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) - end - - -- You will likely want to reduce updatetime which affects CursorHold - -- note: this setting is global and should be set only once - vim.o.updatetime = 250 - vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {scope='cursor', header = "", prefix = "", focus=false})]] - - -- Autotype - vim.cmd('au BufRead,BufNewFile *.md setlocal textwidth=80') - vim.cmd('au BufRead,BufNewFile *.tex setlocal textwidth=80') - vim.cmd('au BufRead,BufNewFile *.nix setlocal tabstop=2 shiftwidth=2 ') - vim.cmd('au BufNewFile,BufRead /tmp/neomutt* set tw=72 fo=awq comments+=nb:> noautoindent filetype=mail') - - -- Ignore these filenames during enhanced command line completion. - vim.opt.wildignore = { - '*.bak', - '*.class', - '*.aux', - '*.out', - '*.toc', - '*.jpg', - '*.bmp', - '*.gif', - '*.png', - '*.luac', - '*.o', - '*.obj', - '*.exe', - '*.dll', - '*.manifest', - '*.pyc', - '*.spl', - '*.sw?' - } - - -- Key biding - -- " ---------- - local opts = { noremap = true, silent = true} - - vim.api.nvim_set_keymap('n', '/', ':nohlsearch', opts) - - -- Move tabs with \[ and \] - vim.api.nvim_set_keymap('n', ']', ':tabnext', opts) - vim.api.nvim_set_keymap('n', '[', ':tabprev', opts) - vim.api.nvim_set_keymap('n', 'l', ':set list!', {silent = true}) - ''; - plugins = with pkgs.vimPlugins; [ - { - plugin = nvim-autopairs; - type = "lua"; - config = '' - local autopair = require("nvim-autopairs").setup {} - ''; - } - { - plugin = nvim-base16; - type = "lua"; - config = '' - vim.cmd.colorscheme 'base16-default-dark' - ''; - } - { - plugin = nvim-cmp; - type = "lua"; - config = '' - local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines( - 0, - line - 1, - line, - true - )[1]:sub(col, col):match('%s') == nil - end - -- Add additional capabilities supported by nvim-cmp - local capabilities = require('cmp_nvim_lsp').default_capabilities() - local luasnip = require("luasnip") - local kind_icons = { - Text = "", - Method = "󰆧", - Function = "󰊕", - Constructor = "", - Field = "󰇽", - Variable = "󰂡", - Class = "󰠱", - Interface = "", - Module = "", - Property = "󰜢", - Unit = "", - Value = "󰎠", - Enum = "", - Keyword = "󰌋", - Snippet = "", - Color = "󰏘", - File = "󰈙", - Reference = "", - Folder = "󰉋", - EnumMember = "", - Constant = "󰏿", - Struct = "", - Event = "", - Operator = "󰆕", - TypeParameter = "󰅲", - } - -- nvim-cmp setup - local cmp = require 'cmp' - cmp.setup { - mapping = { - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() - -- they way you will only jump inside the snippet region - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }, - formatting = { - format = function(_, vim_item) - vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) - return vim_item - end, - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - { name = 'buffer' }, - }, - } - ''; - } - cmp-buffer - cmp-nvim-lsp - cmp-path - cmp-cmdline - cmp_luasnip - { - plugin = gitsigns-nvim; - type = "lua"; - config = '' - require('gitsigns').setup { - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map('n', 'gn', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '' - end, {expr=true}) - - map('n', 'gN', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '' - end, {expr=true}) - - map('n', 'gs', gs.stage_hunk) - map('n', 'gr', gs.reset_hunk) - map('n', 'gd', gs.diffthis) - map('n', 'gd', function() gs.diffthis('~') end) - end - } - ''; - } - indent-blankline-nvim - { - plugin = nvim-lspconfig; - type = "lua"; - config = '' - local lspconfig = require('lspconfig') - ''; - } - { - plugin = lualine-nvim; - type = "lua"; - config = '' - - require('lualine').setup { - options = { - icons_enabled = true, - theme = 'base16', - component_separators = { left = '|', right = '|'}, - section_separators = { left = "", right = ""}, - disabled_filetypes = {}, - always_divide_middle = true, - globalstatus = true, - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = {} - } - ''; - } - luasnip - mason-lspconfig-nvim - { - plugin = mason-nvim; - type = "lua"; - config = '' - local mason = require("mason").setup{ - ensure_installed= { - 'shellcheck', - 'shfmt' - } - } - local mason_lspconfig = require("mason-lspconfig").setup{ - ensure_installed={ - 'ansiblels', - 'bashls' - } - } - require("mason-lspconfig").setup_handlers({ - -- The first entry (without a key) will be the default handler - -- and will be called for each installed server that doesn't have - -- a dedicated handler. - function (server_name) -- default handler (optional) - require("lspconfig")[server_name].setup {} - end, - -- Next, you can provide targeted overrides for specific servers. - }) - ''; - } - { - plugin = neo-tree-nvim; - type = "lua"; - config = '' - local neotree = require 'neo-tree' - neotree.setup({ - event_handlers = { - { - event = "file_opened", - handler = function(file_path) - -- auto close - require("neo-tree.command").execute({action = "close"}) - end - }, - } - }) - vim.api.nvim_set_keymap('n', 'fm', - ':Neotree toggle', - { table.unpack(opts), desc = 'Toggle NeoTree' } - ) - ''; - } - nui-nvim - plenary-nvim - { - plugin = (nvim-treesitter.withPlugins (p: [ - p.bash p.c p.cmake p.dockerfile p.latex p.lua p.markdown - p.markdown_inline p.python p.vim p.yaml - ]) - ); - type = "lua"; - config = '' - -- Tree sitter - local ts = require 'nvim-treesitter.configs' - - ts.setup { - sync_install = false, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - } - } - ''; - } - { - plugin = which-key-nvim; - type = "lua"; - config = '' - local wk = require 'which-key' - wk.register() - ''; - } - ]; - }; -} diff --git a/home-manager/cli/neovim/default.nix b/home-manager/cli/neovim/default.nix new file mode 100644 index 0000000..dc5d86c --- /dev/null +++ b/home-manager/cli/neovim/default.nix @@ -0,0 +1,113 @@ +{ pkgs, config, ... }: +let + nvim-spell-fr-utf8-dictionary = builtins.fetchurl { + url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.spl"; + sha256 = "abfb9702b98d887c175ace58f1ab39733dc08d03b674d914f56344ef86e63b61"; + }; + + nvim-spell-fr-utf8-suggestions = builtins.fetchurl { + url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug"; + sha256 = "0294bc32b42c90bbb286a89e23ca3773b7ef50eff1ab523b1513d6a25c6b3f58"; + }; +in +{ + home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.spl".source = nvim-spell-fr-utf8-dictionary; + home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.sug".source = nvim-spell-fr-utf8-suggestions; + programs.neovim = { + enable = true; + defaultEditor = true; + vimAlias = true; + withNodeJs = true; + withPython3 = true; + extraPackages = with pkgs; [ + # LSP Servers + clang-tools + lua-language-server + marksman + nil + nodePackages.bash-language-server + rnix-lsp + shellcheck + + # Formatters + nixfmt + shfmt + ]; + extraLuaConfig = (builtins.readFile ./files/options.lua); + plugins = with pkgs.vimPlugins; [ + { + plugin = nvim-autopairs; + type = "lua"; + config = '' + local autopair = require("nvim-autopairs").setup {} + ''; + } + { + plugin = nvim-base16; + type = "lua"; + config = '' + vim.cmd.colorscheme 'base16-default-dark' + ''; + } + { + plugin = nvim-cmp; + type = "lua"; + config = (builtins.readFile ./files/cmp.lua); + } + cmp-buffer + cmp-nvim-lsp + cmp-path + cmp-cmdline + cmp_luasnip + { + plugin = gitsigns-nvim; + type = "lua"; + config = (builtins.readFile ./files/luasnip.lua); + } + indent-blankline-nvim + { + plugin = nvim-lspconfig; + type = "lua"; + config = (builtins.readFile ./files/lspconfig.lua); + } + { + plugin = lualine-nvim; + type = "lua"; + config = (builtins.readFile ./files/lualine.lua); + } + luasnip + { + plugin = neo-tree-nvim; + type = "lua"; + config = (builtins.readFile ./files/neotree.lua); + } + nui-nvim + plenary-nvim + { + plugin = (nvim-treesitter.withPlugins (p: [ + p.bash + p.c + p.cpp + p.cmake + p.dockerfile + p.latex + p.lua + p.llvm + p.markdown + p.markdown_inline + p.python + p.vim + p.yaml + ]) + ); + type = "lua"; + config = ( builtins.readFile ./files/treesitter.lua); + } + { + plugin = which-key-nvim; + type = "lua"; + config = ( builtins.readFile ./files/whichkey.lua ); + } + ]; + }; +} diff --git a/home-manager/cli/neovim/files/cmp.lua b/home-manager/cli/neovim/files/cmp.lua new file mode 100644 index 0000000..dfbc0ff --- /dev/null +++ b/home-manager/cli/neovim/files/cmp.lua @@ -0,0 +1,98 @@ +local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines( + 0, + line - 1, + line, + true + )[1]:sub(col, col):match('%s') == nil +end + +local get_ws = function (max, len) + return (" "):rep(max - len) +end + +-- Add additional capabilities supported by nvim-cmp +local capabilities = require('cmp_nvim_lsp').default_capabilities() +local luasnip = require("luasnip") +local kind_icons = { + Text = "", + Method = "󰆧", + Function = "󰊕", + Constructor = "", + Field = "󰇽", + Variable = "󰂡", + Class = "󰠱", + Interface = "", + Module = "", + Property = "󰜢", + Unit = "", + Value = "󰎠", + Enum = "", + Keyword = "󰌋", + Snippet = "", + Color = "󰏘", + File = "󰈙", + Reference = "", + Folder = "󰉋", + EnumMember = "", + Constant = "󰏿", + Struct = "", + Event = "", + Operator = "󰆕", + TypeParameter = "󰅲", +} +-- nvim-cmp setup +local cmp = require 'cmp' +cmp.setup { + mapping = { + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}), + [""] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}), + [""] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}), + [""] = cmp.mapping({ i = cmp.mapping.close(), c = cmp.mapping.close() }), + }, + formatting = { + format = function(_, vim_item) + vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) + + local content = vim_item.abbr + if #content > 25 then + vim_item.abbr = vim.fn.strcharpart(content, 0, 25) .. "…" + else + vim_item.abbr = content .. get_ws(25, #content) + end + + return vim_item + end, + }, + sources = { + {name = 'path'}, + {name = 'nvim_lsp', keyword_length = 1}, + {name = 'buffer', keyword_length = 3}, + {name = 'luasnip', keyword_length = 2}, + }, +} diff --git a/home-manager/cli/neovim/files/lspconfig.lua b/home-manager/cli/neovim/files/lspconfig.lua new file mode 100644 index 0000000..21e542a --- /dev/null +++ b/home-manager/cli/neovim/files/lspconfig.lua @@ -0,0 +1,67 @@ +local lspconfig = require('lspconfig') +local lsp_defaults = lspconfig.util.default_config + +lsp_defaults.capabilities = vim.tbl_deep_extend( + 'force', + lsp_defaults.capabilities, + vim.lsp.protocol.make_client_capabilities(), + require('cmp_nvim_lsp').default_capabilities(), + { workspace = { didChangeWatchedFiles = { dynamicRegistration = true }}} +) + +lspconfig.bashls.setup {} +lspconfig.clangd.setup {} +lspconfig.lua_ls.setup { + single_file_support = true, + flags = { + debounce_text_changes = 150, + } +} +lspconfig.nil_ls.setup {} + +vim.api.nvim_create_autocmd('LspAttach', { + desc = 'LSP actions', + callback = function() + local bufmap = function(mode, lhs, rhs) + local opts = {buffer = true} + vim.keymap.set(mode, lhs, rhs, opts) + end + + -- Displays hover information about the symbol under the cursor + bufmap('n', 'K', 'lua vim.lsp.buf.hover()') + + -- Jump to the definition + bufmap('n', 'gd', 'lua vim.lsp.buf.definition()') + + -- Jump to declaration + bufmap('n', 'gD', 'lua vim.lsp.buf.declaration()') + + -- Lists all the implementations for the symbol under the cursor + bufmap('n', 'gi', 'lua vim.lsp.buf.implementation()') + + -- Jumps to the definition of the type symbol + bufmap('n', 'go', 'lua vim.lsp.buf.type_definition()') + + -- Lists all the references + bufmap('n', 'gr', 'lua vim.lsp.buf.references()') + + -- Displays a function's signature information + bufmap('n', 'gs', 'lua vim.lsp.buf.signature_help()') + + -- Renames all references to the symbol under the cursor + bufmap('n', '', 'lua vim.lsp.buf.rename()') + + -- Selects a code action available at the current cursor position + bufmap('n', '', 'lua vim.lsp.buf.code_action()') + bufmap('x', '', 'lua vim.lsp.buf.range_code_action()') + + -- Show diagnostics in a floating window + bufmap('n', 'gl', 'lua vim.diagnostic.open_float()') + + -- Move to the previous diagnostic + bufmap('n', '[d', 'lua vim.diagnostic.goto_prev()') + + -- Move to the next diagnostic + bufmap('n', ']d', 'lua vim.diagnostic.goto_next()') + end +}) diff --git a/home-manager/cli/neovim/files/lualine.lua b/home-manager/cli/neovim/files/lualine.lua new file mode 100644 index 0000000..8d7fe8a --- /dev/null +++ b/home-manager/cli/neovim/files/lualine.lua @@ -0,0 +1,29 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'base16', + component_separators = { left = '|', right = '|'}, + section_separators = { left = "", right = ""}, + disabled_filetypes = {}, + always_divide_middle = true, + globalstatus = true, + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {} +} diff --git a/home-manager/cli/neovim/files/luasnip.lua b/home-manager/cli/neovim/files/luasnip.lua new file mode 100644 index 0000000..bfb6ee7 --- /dev/null +++ b/home-manager/cli/neovim/files/luasnip.lua @@ -0,0 +1,29 @@ +require('gitsigns').setup { + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', 'gn', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, {expr=true}) + + map('n', 'gN', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, {expr=true}) + + map('n', 'gs', gs.stage_hunk) + map('n', 'gr', gs.reset_hunk) + map('n', 'gd', gs.diffthis) + map('n', 'gd', function() gs.diffthis('~') end) + end +} diff --git a/home-manager/cli/neovim/files/neotree.lua b/home-manager/cli/neovim/files/neotree.lua new file mode 100644 index 0000000..34d1ddc --- /dev/null +++ b/home-manager/cli/neovim/files/neotree.lua @@ -0,0 +1,16 @@ +local neotree = require 'neo-tree' +neotree.setup({ + event_handlers = { + { + event = "file_opened", + handler = function(file_path) + -- auto close + require("neo-tree.command").execute({action = "close"}) + end + }, + } +}) +vim.api.nvim_set_keymap('n', 'fm', +':Neotree toggle', +{ table.unpack(opts), desc = 'Toggle NeoTree' } +) diff --git a/home-manager/cli/neovim/files/options.lua b/home-manager/cli/neovim/files/options.lua new file mode 100644 index 0000000..0fe083d --- /dev/null +++ b/home-manager/cli/neovim/files/options.lua @@ -0,0 +1,102 @@ +-- General Option +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +vim.opt.autoindent = true +vim.opt.background = 'dark' +vim.opt.backupdir = os.getenv("HOME") .. '/.local/tmp/nvim' +vim.opt.clipboard = 'unnamedplus' --Use system clipboard +vim.opt.colorcolumn = '80' +vim.opt.directory = os.getenv("HOME") .. '/.local/tmp/nvim' +vim.opt.expandtab = true +vim.opt.foldmethod = 'syntax' +vim.opt.gdefault = true -- search: all occurrences by default +vim.opt.hlsearch = true -- search: hightlight terms +vim.opt.ignorecase = true +vim.opt.incsearch = true +vim.opt.laststatus = 1 +-- show special character +vim.opt.listchars = {tab = '→ ', trail = '␣', eol = '', extends = '…' } + +vim.opt.signcolumn = "yes" -- alway show sign column +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.cursorline = true -- highlight current line +vim.opt.shiftwidth = 4 +vim.opt.showmatch = true +vim.opt.smartcase = true -- search: try :to be smart about cases +vim.opt.smartindent = true +vim.opt.tabstop = 4 +vim.opt.termguicolors = true -- 24 bits color support +vim.opt.wildmenu = true -- activate enhanced user menu +vim.opt.wildmode = 'lastused:full,list' -- enhance menu +vim.opt.pumheight = 10 +vim.opt.pumwidth = 50 +vim.opt.pumblend = 10 + +-- need to activate this for cmp +vim.opt.completeopt = {'menu', 'menuone', 'noselect'} +-- -- Code Fold +-- "Load and save view atomatocally (save and restore fold) +vim.cmd('au BufWinLeave *.* mkview') +vim.cmd('au BufWinEnter *.* silent! loadview') + + +-- Diagnostic settings +-- +-- diagnostic windows must be float +vim.diagnostic.config { + virtual_text = false, + signs = true, + underline = true, +} + +local signs = { Error = "", Warn = "", Hint = "󰌶", Info = "" } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) +end + +-- You will likely want to reduce updatetime which affects CursorHold +-- note: this setting is global and should be set only once +vim.o.updatetime = 250 +vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {scope='cursor', header = "", prefix = "", focus=false})]] + +-- Autotype +vim.cmd('au BufRead,BufNewFile *.md setlocal textwidth=80') +vim.cmd('au BufRead,BufNewFile *.tex setlocal textwidth=80') +vim.cmd('au BufRead,BufNewFile *.nix setlocal tabstop=2 shiftwidth=2 ') +vim.cmd('au BufNewFile,BufRead /tmp/neomutt* set tw=72 fo=awq comments+=nb:> noautoindent filetype=mail') + +-- Ignore these filenames during enhanced command line completion. +vim.opt.wildignore = { + '*.bak', + '*.class', + '*.aux', + '*.out', + '*.toc', + '*.jpg', + '*.bmp', + '*.gif', + '*.png', + '*.luac', + '*.o', + '*.obj', + '*.exe', + '*.dll', + '*.manifest', + '*.pyc', + '*.spl', + '*.sw?' +} + +-- Key biding +-- " ---------- +local opts = { noremap = true, silent = true} + +vim.api.nvim_set_keymap('n', '/', ':nohlsearch', opts) + +-- Move tabs with \[ and \] +vim.api.nvim_set_keymap('n', ']', ':tabnext', opts) +vim.api.nvim_set_keymap('n', '[', ':tabprev', opts) +vim.api.nvim_set_keymap('n', 'l', ':set list!', {silent = true}) diff --git a/home-manager/cli/neovim/files/treesitter.lua b/home-manager/cli/neovim/files/treesitter.lua new file mode 100644 index 0000000..d61725b --- /dev/null +++ b/home-manager/cli/neovim/files/treesitter.lua @@ -0,0 +1,11 @@ +-- Tree sitter +-- +local ts = require 'nvim-treesitter.configs' + +ts.setup { + sync_install = false, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + } +} diff --git a/home-manager/cli/neovim/files/whichkey.lua b/home-manager/cli/neovim/files/whichkey.lua new file mode 100644 index 0000000..0b51321 --- /dev/null +++ b/home-manager/cli/neovim/files/whichkey.lua @@ -0,0 +1,4 @@ +-- Which-key +-- +local wk = require 'which-key' +wk.register()