diff options
author | Minijackson <minijackson@riseup.net> | 2021-05-12 20:54:32 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2021-05-12 20:56:46 +0200 |
commit | 13bbcd5a5feffa4a91f4e4068e68e9baf2f90223 (patch) | |
tree | 8d5937668be0f3b28c11f5ce3f35d2ad8fd85318 | |
parent | 829f633426f4a775dbb20c29d0bfbd791608cb6c (diff) | |
download | nixos-config-reborn-13bbcd5a5feffa4a91f4e4068e68e9baf2f90223.tar.gz nixos-config-reborn-13bbcd5a5feffa4a91f4e4068e68e9baf2f90223.zip |
vim: better config with lua, with some dev config
-rw-r--r-- | common/vim.nix | 206 | ||||
-rw-r--r-- | dotfiles/vim-dev.lua | 61 | ||||
-rw-r--r-- | dotfiles/vim.lua | 223 | ||||
-rw-r--r-- | dotfiles/vimrc.vim | 139 | ||||
-rw-r--r-- | flake.lock | 59 | ||||
-rw-r--r-- | flake.nix | 28 | ||||
-rw-r--r-- | profiles/desktop.nix | 8 | ||||
-rw-r--r-- | usecases/desktop/development.nix | 39 |
8 files changed, 513 insertions, 250 deletions
diff --git a/common/vim.nix b/common/vim.nix index aa74a39..ec43738 100644 --- a/common/vim.nix +++ b/common/vim.nix | |||
@@ -2,81 +2,108 @@ inputs: | |||
2 | 2 | ||
3 | { config, pkgs, lib, ... }: | 3 | { config, pkgs, lib, ... }: |
4 | 4 | ||
5 | let myNeovim = (pkgs.neovim.override { | 5 | let |
6 | configure = { | 6 | inherit (pkgs.unstable) vimPlugins wrapNeovim; |
7 | |||
8 | inherit (config.vim) beforePlugins; | ||
9 | |||
10 | customRC = with lib; | ||
11 | (concatStringsSep | ||
12 | "\n" | ||
13 | (mapAttrsToList | ||
14 | (variable: value: "let g:${variable} = ${value}") | ||
15 | config.vim.variables)) | ||
16 | + "\n" | ||
17 | + builtins.readFile ../dotfiles/vimrc.vim + config.vim.extraConfig; | ||
18 | |||
19 | vam = with pkgs; { | ||
20 | pluginDictionaries = [ | ||
21 | # UI | ||
22 | { name = "undotree"; } | ||
23 | { name = "gruvbox-community"; } | ||
24 | { name = "gitgutter"; } | ||
25 | { name = "lightline-vim"; } | ||
26 | { name = "vim-dirvish"; } | ||
27 | |||
28 | # Motions | ||
29 | { name = "camelcasemotion"; } | ||
30 | { name = "surround"; } | ||
31 | { name = "targets-vim"; } | ||
32 | |||
33 | # Frameworks | ||
34 | { name = "deoplete-nvim"; } | ||
35 | { name = "neosnippet"; } | ||
36 | { name = "neosnippet-snippets"; } | ||
37 | { name = "neoformat"; } | ||
38 | { name = "ctrlp"; } | ||
39 | # Syntax generic completion for deoplete | ||
40 | { name = "neco-syntax"; } | ||
41 | |||
42 | # Languages | ||
43 | { name = "vim-polyglot"; } | ||
44 | { name = "editorconfig-vim"; } | ||
45 | # Vim completion for deoplete | ||
46 | { name = "neco-vim"; } | ||
47 | { name = "deoplete-zsh"; } | ||
48 | { name = "vim-pandoc"; } | ||
49 | { name = "vim-pandoc-syntax"; } | ||
50 | |||
51 | # Languages (but not programming languages) | ||
52 | { name = "vim-grammarous"; } | ||
53 | |||
54 | # Other | ||
55 | { name = "tmux-complete-vim"; } | ||
56 | { name = "fugitive"; } | ||
57 | { name = "rhubarb"; } | ||
58 | { name = "repeat"; } | ||
59 | { name = "vim-unimpaired"; } | ||
60 | { name = "tabular"; } | ||
61 | { name = "vimwiki"; } | ||
62 | { name = "vim-abolish"; } | ||
63 | |||
64 | ] ++ config.vim.extraPlugins; | ||
65 | 7 | ||
66 | }; | 8 | neovim-unwrapped = inputs.neovim-master.defaultPackage.${config.nixpkgs.system}; |
9 | |||
10 | cfg = config.vim; | ||
11 | |||
12 | myConfigPackage = with lib; | ||
13 | pkgs.writeTextDir | ||
14 | "share/vim-plugins/myConfig/lua/myConfig.lua" | ||
15 | '' | ||
16 | -- Autogenerated variables from the NixOS configuration | ||
17 | |||
18 | ${(concatStringsSep | ||
19 | "\n" | ||
20 | (mapAttrsToList | ||
21 | (variable: value: "vim.g.${variable} = ${value}") | ||
22 | cfg.variables))} | ||
23 | |||
24 | -- vim.lua from the NixOS configuration | ||
25 | |||
26 | ${builtins.readFile ../dotfiles/vim.lua} | ||
27 | |||
28 | -- luaConfig from the NixOS configuration | ||
29 | |||
30 | ${cfg.luaConfig} | ||
31 | ''; | ||
32 | |||
33 | myNeovim = wrapNeovim neovim-unwrapped { | ||
34 | configure = { | ||
67 | 35 | ||
36 | inherit (config.vim) beforePlugins; | ||
37 | |||
38 | customRC = '' | ||
39 | autocmd VimEnter * lua require("myConfig") | ||
40 | |||
41 | ${cfg.extraConfig} | ||
42 | ''; | ||
43 | |||
44 | packages.myVimPackage = with vimPlugins; { | ||
45 | start = [ | ||
46 | myConfigPackage | ||
47 | |||
48 | # Dependencies | ||
49 | plenary-nvim | ||
50 | popup-nvim | ||
51 | |||
52 | # UI | ||
53 | undotree | ||
54 | gruvbox-community | ||
55 | lualine-nvim | ||
56 | gitsigns-nvim | ||
57 | vim-dirvish | ||
58 | lsp-status-nvim | ||
59 | |||
60 | completion-nvim | ||
61 | completion-buffers | ||
62 | snippets-nvim | ||
63 | |||
64 | telescope-nvim | ||
65 | |||
66 | # Treesitter | ||
67 | nvim-treesitter | ||
68 | completion-treesitter | ||
69 | nvim-treesitter-textobjects | ||
70 | nvim-treesitter-context | ||
71 | |||
72 | # Motions | ||
73 | camelcasemotion | ||
74 | surround | ||
75 | targets-vim | ||
76 | |||
77 | neoformat | ||
78 | |||
79 | # Languages | ||
80 | vim-polyglot | ||
81 | editorconfig-vim | ||
82 | vim-pandoc | ||
83 | vim-pandoc-syntax | ||
84 | |||
85 | # Languages (but not programming languages) | ||
86 | vim-grammarous | ||
87 | |||
88 | # Other | ||
89 | tmux-complete-vim | ||
90 | fugitive | ||
91 | rhubarb | ||
92 | repeat | ||
93 | vim-unimpaired | ||
94 | tabular | ||
95 | vim-abolish | ||
96 | ] ++ config.vim.extraPlugins; | ||
97 | }; | ||
98 | }; | ||
68 | }; | 99 | }; |
69 | }); | 100 | in |
70 | in { | 101 | { |
71 | options.vim = with lib; { | 102 | options.vim = with lib; { |
72 | 103 | ||
73 | variables = mkOption { | 104 | variables = mkOption { |
74 | type = types.attrsOf types.str; | 105 | type = types.attrsOf types.str; |
75 | default = { | 106 | default = {}; |
76 | dominant_color = "'${config.theme.colors.dominant}'"; | ||
77 | ripgrep_path = "'${pkgs.ripgrep}/bin/rg'"; | ||
78 | fd_path = "'${pkgs.fd}/bin/fd'"; | ||
79 | }; | ||
80 | description = '' | 107 | description = '' |
81 | Extra global variables to add at the beginning of the vim configuration. | 108 | Extra global variables to add at the beginning of the vim configuration. |
82 | 109 | ||
@@ -85,17 +112,11 @@ in { | |||
85 | }; | 112 | }; |
86 | 113 | ||
87 | extraPlugins = mkOption { | 114 | extraPlugins = mkOption { |
88 | type = types.listOf (types.attrsOf types.str); | 115 | type = with types; listOf package; |
89 | default = []; | 116 | default = [ ]; |
90 | description = "Names of extra plugins to add"; | 117 | description = "Names of extra plugins to add"; |
91 | }; | 118 | }; |
92 | 119 | ||
93 | extraRepoPlugins = mkOption { | ||
94 | type = types.listOf (types.attrsOf types.str); | ||
95 | default = []; | ||
96 | description = "Names of extra plugins to add that are present in the local repository"; | ||
97 | }; | ||
98 | |||
99 | beforePlugins = mkOption { | 120 | beforePlugins = mkOption { |
100 | type = types.lines; | 121 | type = types.lines; |
101 | default = ""; | 122 | default = ""; |
@@ -107,9 +128,30 @@ in { | |||
107 | default = ""; | 128 | default = ""; |
108 | description = "Extra lines to add at the end of the vim configuration"; | 129 | description = "Extra lines to add at the end of the vim configuration"; |
109 | }; | 130 | }; |
131 | |||
132 | luaConfig = mkOption { | ||
133 | type = types.lines; | ||
134 | default = ""; | ||
135 | description = "Lua Neovim configuration"; | ||
136 | }; | ||
137 | |||
138 | wrappedPackage = mkOption { | ||
139 | type = types.package; | ||
140 | description = "Resulting wrapped Neovim package"; | ||
141 | readOnly = true; | ||
142 | }; | ||
110 | }; | 143 | }; |
111 | 144 | ||
112 | config = { | 145 | config = { |
146 | vim = { | ||
147 | wrappedPackage = myNeovim; | ||
148 | variables = { | ||
149 | dominant_color = "'${config.theme.colors.dominant}'"; | ||
150 | ripgrep_path = "'${pkgs.ripgrep}/bin/rg'"; | ||
151 | fd_path = "'${pkgs.fd}/bin/fd'"; | ||
152 | }; | ||
153 | }; | ||
154 | |||
113 | environment.systemPackages = with pkgs; [ | 155 | environment.systemPackages = with pkgs; [ |
114 | myNeovim | 156 | myNeovim |
115 | ]; | 157 | ]; |
@@ -119,13 +161,13 @@ in { | |||
119 | }; | 161 | }; |
120 | 162 | ||
121 | home-manager.users.minijackson = { ... }: | 163 | home-manager.users.minijackson = { ... }: |
122 | { | 164 | { |
123 | xdg.dataFile."nvim/backup/.keep".text = ""; | 165 | xdg.dataFile."nvim/backup/.keep".text = ""; |
124 | }; | 166 | }; |
125 | 167 | ||
126 | home-manager.users.root = { ... }: | 168 | home-manager.users.root = { ... }: |
127 | { | 169 | { |
128 | xdg.dataFile."nvim/backup/.keep".text = ""; | 170 | xdg.dataFile."nvim/backup/.keep".text = ""; |
129 | }; | 171 | }; |
130 | }; | 172 | }; |
131 | } | 173 | } |
diff --git a/dotfiles/vim-dev.lua b/dotfiles/vim-dev.lua new file mode 100644 index 0000000..6b78022 --- /dev/null +++ b/dotfiles/vim-dev.lua | |||
@@ -0,0 +1,61 @@ | |||
1 | local lspconfig = require("lspconfig") | ||
2 | |||
3 | function on_attach(client, bufnr) | ||
4 | local function buf_set_keymap(...) | ||
5 | vim.api.nvim_buf_set_keymap(bufnr, ...) | ||
6 | end | ||
7 | |||
8 | local opts = { noremap = true, silent = true } | ||
9 | |||
10 | buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts) | ||
11 | buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts) | ||
12 | buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts) | ||
13 | |||
14 | buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) | ||
15 | |||
16 | buf_set_keymap('n', '<leader>sa', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) | ||
17 | buf_set_keymap('n', '<leader>se', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts) | ||
18 | buf_set_keymap('n', '<leader>sl', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts) | ||
19 | buf_set_keymap('n', '<leader>sr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) | ||
20 | |||
21 | buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) | ||
22 | buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) | ||
23 | |||
24 | -- Capability specific | ||
25 | |||
26 | -- print(vim.inspect(client.resolved_capabilities)) | ||
27 | |||
28 | if client.resolved_capabilities.document_formatting then | ||
29 | buf_set_keymap("n", "<leader>sf", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts) | ||
30 | end | ||
31 | if client.resolved_capabilities.document_range_formatting then | ||
32 | buf_set_keymap("v", "<leader>sf", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts) | ||
33 | end | ||
34 | |||
35 | -- Rust specific | ||
36 | buf_set_keymap("n", "<leader>sh", "<cmd>RustToggleInlayHints<CR>", opts) | ||
37 | |||
38 | require("completion").on_attach() | ||
39 | end | ||
40 | |||
41 | function setup_lsp_with(servers) | ||
42 | for _, server in ipairs(servers) do | ||
43 | lspconfig[server].setup { | ||
44 | cmd = { vim.g[server .. "_path"] }, | ||
45 | on_attach = on_attach, | ||
46 | } | ||
47 | end | ||
48 | end | ||
49 | |||
50 | setup_lsp_with { | ||
51 | "clangd", | ||
52 | "elixirls", | ||
53 | "pyls", | ||
54 | } | ||
55 | |||
56 | require("rust-tools").setup { | ||
57 | server = { | ||
58 | cmd = { vim.g.rust_analyzer_path }, | ||
59 | on_attach = on_attach, | ||
60 | } | ||
61 | } | ||
diff --git a/dotfiles/vim.lua b/dotfiles/vim.lua new file mode 100644 index 0000000..1acff0d --- /dev/null +++ b/dotfiles/vim.lua | |||
@@ -0,0 +1,223 @@ | |||
1 | -- Options | ||
2 | ---------- | ||
3 | |||
4 | vim.o.undofile = true | ||
5 | vim.o.backup = true | ||
6 | vim.cmd "set backupdir-=." | ||
7 | |||
8 | vim.o.mouse = "a" | ||
9 | |||
10 | vim.o.ignorecase = true | ||
11 | vim.o.smartcase = true | ||
12 | |||
13 | vim.o.smartindent = true | ||
14 | |||
15 | vim.o.tabstop = 4 | ||
16 | vim.o.shiftwidth = 4 | ||
17 | |||
18 | vim.o.inccommand = "split" | ||
19 | |||
20 | vim.o.scrolloff = 1 | ||
21 | vim.o.sidescrolloff = 5 | ||
22 | |||
23 | vim.o.colorcolumn = "80" | ||
24 | vim.o.cursorline = true | ||
25 | |||
26 | vim.o.title = true | ||
27 | |||
28 | vim.o.wildmode = "longest:full,full" | ||
29 | vim.o.completeopt = "menu,menuone,preview,noinsert,noselect" | ||
30 | |||
31 | -- Use ripgrep | ||
32 | vim.o.grepprg = vim.g.ripgrep_path .. " --vimgrep --smart-case" | ||
33 | vim.o.grepformat = "%f:%l:%c:%m" .. vim.o.grepformat | ||
34 | |||
35 | vim.o.termguicolors = true | ||
36 | vim.o.background = "dark" | ||
37 | |||
38 | -- Mode already shown by the status line | ||
39 | vim.o.showmode = false | ||
40 | |||
41 | -- Do not set "trail:-" because it messes up the highlighting | ||
42 | vim.o.listchars = "tab:│ ,extends:>,precedes:<,nbsp:+" | ||
43 | vim.wo.list = true | ||
44 | vim.o.fillchars = "fold:─,vert:│" | ||
45 | |||
46 | -- Leaders | ||
47 | ---------- | ||
48 | |||
49 | vim.g.maplocalleader = "," | ||
50 | vim.g.mapleader = ";" | ||
51 | |||
52 | -- Misc | ||
53 | ------- | ||
54 | |||
55 | -- From neovim#14420 | ||
56 | -- Restores the position of previously opened files | ||
57 | vim.cmd [[ | ||
58 | augroup LastCursorPos | ||
59 | autocmd! | ||
60 | autocmd BufReadPost * if @% !~# "\.git[\/\\]COMMIT_EDITMSG$" && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif | ||
61 | augroup end | ||
62 | ]] | ||
63 | |||
64 | -- Highlight yanked text | ||
65 | vim.cmd "autocmd TextYankPost * silent! lua vim.highlight.on_yank()" | ||
66 | |||
67 | vim.g.tex_flavor = "latex" | ||
68 | |||
69 | vim.cmd "colorscheme gruvbox" | ||
70 | |||
71 | -- Mappings | ||
72 | ----------- | ||
73 | |||
74 | local map = vim.api.nvim_set_keymap | ||
75 | local mapopts = { noremap = true, silent = true } | ||
76 | |||
77 | vim.fn["camelcasemotion#CreateMotionMappings"] "<LocalLeader>" | ||
78 | |||
79 | map("n", "=of", [[:set <C-R>=(&formatoptions =~ "a") ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>]], mapopts) | ||
80 | |||
81 | -- Plugins | ||
82 | ---------- | ||
83 | |||
84 | -- Gitsigns | ||
85 | |||
86 | require('gitsigns').setup { | ||
87 | keymaps = { | ||
88 | noremap = true, | ||
89 | buffer = true, | ||
90 | silent = true, | ||
91 | |||
92 | ['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns\".next_hunk()<CR>'"}, | ||
93 | ['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns\".prev_hunk()<CR>'"}, | ||
94 | |||
95 | ['n <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>', | ||
96 | ['n <leader>hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>', | ||
97 | ['n <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>', | ||
98 | ['n <leader>hR'] = '<cmd>lua require"gitsigns".reset_buffer()<CR>', | ||
99 | ['n <leader>hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>', | ||
100 | ['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line()<CR>', | ||
101 | |||
102 | -- Text objects | ||
103 | ['o ih'] = ':<C-U>lua require"gitsigns".select_hunk()<CR>', | ||
104 | ['x ih'] = ':<C-U>lua require"gitsigns".select_hunk()<CR>', | ||
105 | } | ||
106 | } | ||
107 | |||
108 | -- Treesitter | ||
109 | |||
110 | require('nvim-treesitter.configs').setup { | ||
111 | highlight = { | ||
112 | enable = true, | ||
113 | }, | ||
114 | incremental_selection = { | ||
115 | enable = true, | ||
116 | keymaps = { | ||
117 | init_selection = "gnn", | ||
118 | node_incremental = "grn", | ||
119 | scope_incremental = "grc", | ||
120 | node_decremental = "grm", | ||
121 | }, | ||
122 | }, | ||
123 | indent = { | ||
124 | enable = true, | ||
125 | }, | ||
126 | matchup = { | ||
127 | enable = true, | ||
128 | }, | ||
129 | textobjects = { | ||
130 | select = { | ||
131 | enable = true, | ||
132 | keymaps = { | ||
133 | -- You can use the capture groups defined in textobjects.scm | ||
134 | ["af"] = "@function.outer", | ||
135 | ["if"] = "@function.inner", | ||
136 | ["ac"] = "@class.outer", | ||
137 | ["ic"] = "@class.inner", | ||
138 | }, | ||
139 | }, | ||
140 | |||
141 | move = { | ||
142 | enable = true, | ||
143 | goto_next_start = { | ||
144 | ["]m"] = "@function.outer", | ||
145 | ["]]"] = "@class.outer", | ||
146 | }, | ||
147 | goto_next_end = { | ||
148 | ["]M"] = "@function.outer", | ||
149 | ["]["] = "@class.outer", | ||
150 | }, | ||
151 | goto_previous_start = { | ||
152 | ["[m"] = "@function.outer", | ||
153 | ["[["] = "@class.outer", | ||
154 | }, | ||
155 | goto_previous_end = { | ||
156 | ["[M"] = "@function.outer", | ||
157 | ["[]"] = "@class.outer", | ||
158 | }, | ||
159 | }, | ||
160 | }, | ||
161 | } | ||
162 | |||
163 | vim.o.foldmethod = 'expr' | ||
164 | vim.o.foldexpr = 'nvim_treesitter#foldexpr()' | ||
165 | |||
166 | -- Completion-nvim | ||
167 | |||
168 | vim.g.completion_chain_complete_list = { | ||
169 | default = { | ||
170 | { | ||
171 | complete_items = { 'lsp', 'ts', 'path', 'snippet', 'buffers', 'tmux', }, | ||
172 | } | ||
173 | }, | ||
174 | } | ||
175 | |||
176 | vim.cmd [[autocmd BufEnter * lua require'completion'.on_attach()]] | ||
177 | |||
178 | local map = vim.api.nvim_set_keymap | ||
179 | |||
180 | vim.g.completion_enable_snippet = "snippets.nvim" | ||
181 | |||
182 | -- Telescope | ||
183 | |||
184 | map("n", "<leader>fb", "<cmd>Telescope buffers<cr>", mapopts) | ||
185 | map("n", "<leader>ff", "<cmd>Telescope find_files<cr>", mapopts) | ||
186 | map("n", "<leader>fg", "<cmd>Telescope live_grep<cr>", mapopts) | ||
187 | map("n", "<leader>fh", "<cmd>Telescope help_tags<cr>", mapopts) | ||
188 | map("n", "<leader>ft", "<cmd>Telescope treesitter<cr>", mapopts) | ||
189 | |||
190 | -- Lualine | ||
191 | |||
192 | local lsp_status = require('lsp-status') | ||
193 | lsp_status.config { | ||
194 | indicator_errors = "err:", | ||
195 | indicator_hint = "hint:", | ||
196 | indicator_info = "info:", | ||
197 | indicator_ok = "ok", | ||
198 | indicator_warnings = "warn:", | ||
199 | spinner_frames = {""}, | ||
200 | status_symbol = "lsp:", | ||
201 | } | ||
202 | lsp_status.register_progress() | ||
203 | |||
204 | function LspStatus() | ||
205 | if #vim.lsp.buf_get_clients() < 1 then return "" end | ||
206 | |||
207 | return lsp_status.status() | ||
208 | end | ||
209 | |||
210 | require("lualine").setup { | ||
211 | options = { | ||
212 | component_separators = "", | ||
213 | icons_enabled = false, | ||
214 | section_separators = "", | ||
215 | }, | ||
216 | sections = { | ||
217 | lualine_c = {'filename', LspStatus}, | ||
218 | }, | ||
219 | } | ||
220 | |||
221 | -- Snippets.nvim | ||
222 | |||
223 | require("snippets").use_suggested_mappings() | ||
diff --git a/dotfiles/vimrc.vim b/dotfiles/vimrc.vim deleted file mode 100644 index a0451c6..0000000 --- a/dotfiles/vimrc.vim +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
1 | " Some global variables are defined in ../vim.nix | ||
2 | |||
3 | " Better default options {{{ | ||
4 | |||
5 | set undofile | ||
6 | set backup | ||
7 | set backupdir-=. | ||
8 | |||
9 | set mouse=a | ||
10 | |||
11 | set ignorecase | ||
12 | set smartcase | ||
13 | |||
14 | set smartindent | ||
15 | set tabstop=4 | ||
16 | set shiftwidth=4 | ||
17 | |||
18 | set inccommand=split | ||
19 | |||
20 | set scrolloff=1 | ||
21 | set sidescrolloff=5 | ||
22 | |||
23 | set colorcolumn=80 | ||
24 | set cursorline | ||
25 | |||
26 | set modeline | ||
27 | |||
28 | set title | ||
29 | |||
30 | set wildmode=longest:full,full | ||
31 | |||
32 | let g:maplocalleader = ',' | ||
33 | let g:mapleader = ';' | ||
34 | |||
35 | " If previously opened jump to the last position in the file | ||
36 | au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | ||
37 | |||
38 | let &grepprg = g:ripgrep_path . ' --vimgrep $*' | ||
39 | let &grepformat = '%f:%l:%c:%m,' . &grepformat | ||
40 | |||
41 | let g:tex_flavor = 'latex' | ||
42 | |||
43 | " }}} | ||
44 | |||
45 | " Colors, Statusline, Tabline, Code display {{{ | ||
46 | |||
47 | set termguicolors | ||
48 | let g:gruvbox_contrast_dark = 'soft' | ||
49 | let g:gruvbox_italic = 1 | ||
50 | set background=dark | ||
51 | colorscheme gruvbox | ||
52 | |||
53 | " Doesn't do anything because the tabline gets overwritten by lightline | ||
54 | "exe 'hi! TabLineSel guifg=' . g:dominant_color | ||
55 | |||
56 | let g:lightline = { | ||
57 | \ 'colorscheme': 'gruvbox', | ||
58 | \ 'subseparator': { 'left': '|', 'right': '|' }, | ||
59 | \ 'tab_linesubseparator': { 'left': '|', 'right': '|' }, | ||
60 | \ } | ||
61 | |||
62 | set noshowmode | ||
63 | |||
64 | " Do not set "trail:-" because it messes up the highlighting | ||
65 | set listchars=tab:│\ ,extends:>,precedes:<,nbsp:+ | ||
66 | set list | ||
67 | |||
68 | set fillchars=fold:─,vert:│ | ||
69 | |||
70 | highlight ExtraWhitespace term=inverse cterm=inverse gui=inverse | ||
71 | " Show trailing whitespace and spaces before tabs: | ||
72 | autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL | ||
73 | |||
74 | " }}} | ||
75 | |||
76 | " Mappings {{{ | ||
77 | |||
78 | call camelcasemotion#CreateMotionMappings(g:maplocalleader) | ||
79 | |||
80 | nmap =of :set <C-R>=(&formatoptions =~ "a") ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR> | ||
81 | |||
82 | " }}} | ||
83 | |||
84 | set completefunc=syntaxcomplete#Complete | ||
85 | set completeopt+=noinsert,noselect | ||
86 | |||
87 | " Deoplete {{{ | ||
88 | |||
89 | let g:deoplete#enable_at_startup = 1 | ||
90 | |||
91 | " }}} | ||
92 | |||
93 | " Neosnippets {{{ | ||
94 | |||
95 | imap <C-k> <Plug>(neosnippet_expand_or_jump) | ||
96 | smap <C-k> <Plug>(neosnippet_expand_or_jump) | ||
97 | xmap <C-k> <Plug>(neosnippet_expand_target) | ||
98 | |||
99 | set conceallevel=2 | ||
100 | set concealcursor=nv | ||
101 | |||
102 | " }}} | ||
103 | |||
104 | " CtrlP {{{ | ||
105 | let g:ctrlp_user_command = g:fd_path . ' --type f --color never "" %s' | ||
106 | let g:ctrlp_use_caching = 0 | ||
107 | " }}} | ||
108 | |||
109 | " LanguageClient {{{ | ||
110 | let g:LanguageClient_loggingFile = stdpath('data') . '/LanguageClient.log' | ||
111 | let g:LanguageClient_serverStderr = stdpath('data') . '/LanguageServer.log' | ||
112 | " }}} | ||
113 | |||
114 | " VimWiki {{{ | ||
115 | " {'path': '~/Documents/Wiki', 'path_html': '~/Documents/Wiki/html'} \ | ||
116 | let g:vimwiki_list = [ | ||
117 | \ {'path': '~/Documents/Wiki/personal', | ||
118 | \ 'path_html': '~/Documents/Wiki/personal/html', | ||
119 | \ 'auto_tags': 1}, | ||
120 | \ {'path': '~/Documents/Wiki/science', 'path_html': '~/Documents/Wiki/science/html', 'auto_tags': 1}, | ||
121 | \ {'path': '~/Documents/Wiki/work', 'path_html': '~/Documents/Wiki/work/html', 'auto_tags': 1}, | ||
122 | \ ] | ||
123 | |||
124 | let g:vimwiki_global_ext = 0 | ||
125 | |||
126 | let g:vimwiki_auto_header = 1 | ||
127 | let g:vimwiki_hl_headers = 1 | ||
128 | let g:vimwiki_hl_cb_checked = 1 | ||
129 | let g:vimwiki_html_header_numbering = 2 | ||
130 | let g:vimwiki_html_header_numbering_sym = '.' | ||
131 | |||
132 | let g:vimwiki_links_header_level = 2 | ||
133 | let g:vimwiki_tags_header_level = 2 | ||
134 | let g:vimwiki_toc_header_level = 2 | ||
135 | |||
136 | call deoplete#custom#var('omni', 'input_patterns', { 'vimwiki': '\[\[\w*|\:\w+' }) | ||
137 | " }}} | ||
138 | |||
139 | " vim: fdm=marker | ||
@@ -2,11 +2,26 @@ | |||
2 | "nodes": { | 2 | "nodes": { |
3 | "flake-utils": { | 3 | "flake-utils": { |
4 | "locked": { | 4 | "locked": { |
5 | "lastModified": 1618217525, | 5 | "lastModified": 1620759905, |
6 | "narHash": "sha256-WGrhVczjXTiswQaoxQ+0PTfbLNeOQM6M36zvLn78AYg=", | 6 | "narHash": "sha256-WiyWawrgmyN0EdmiHyG2V+fqReiVi8bM9cRdMaKQOFg=", |
7 | "owner": "numtide", | 7 | "owner": "numtide", |
8 | "repo": "flake-utils", | 8 | "repo": "flake-utils", |
9 | "rev": "c6169a2772643c4a93a0b5ac1c61e296cba68544", | 9 | "rev": "b543720b25df6ffdfcf9227afafc5b8c1fabfae8", |
10 | "type": "github" | ||
11 | }, | ||
12 | "original": { | ||
13 | "owner": "numtide", | ||
14 | "repo": "flake-utils", | ||
15 | "type": "github" | ||
16 | } | ||
17 | }, | ||
18 | "flake-utils_2": { | ||
19 | "locked": { | ||
20 | "lastModified": 1610051610, | ||
21 | "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=", | ||
22 | "owner": "numtide", | ||
23 | "repo": "flake-utils", | ||
24 | "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc", | ||
10 | "type": "github" | 25 | "type": "github" |
11 | }, | 26 | }, |
12 | "original": { | 27 | "original": { |
@@ -36,13 +51,36 @@ | |||
36 | "type": "github" | 51 | "type": "github" |
37 | } | 52 | } |
38 | }, | 53 | }, |
54 | "neovim-master": { | ||
55 | "inputs": { | ||
56 | "flake-utils": "flake-utils_2", | ||
57 | "nixpkgs": [ | ||
58 | "nixpkgs-unstable" | ||
59 | ] | ||
60 | }, | ||
61 | "locked": { | ||
62 | "dir": "contrib", | ||
63 | "lastModified": 1620779525, | ||
64 | "narHash": "sha256-k4ePrffhuZoSDqZMOMHx1Rb/ehd6cjvJvc/Wh9Wr8Rg=", | ||
65 | "owner": "neovim", | ||
66 | "repo": "neovim", | ||
67 | "rev": "61aefaf2993c0b55f6123ba4b0bd41b1caf1fcd3", | ||
68 | "type": "github" | ||
69 | }, | ||
70 | "original": { | ||
71 | "dir": "contrib", | ||
72 | "owner": "neovim", | ||
73 | "repo": "neovim", | ||
74 | "type": "github" | ||
75 | } | ||
76 | }, | ||
39 | "nixpkgs": { | 77 | "nixpkgs": { |
40 | "locked": { | 78 | "locked": { |
41 | "lastModified": 1618750622, | 79 | "lastModified": 1620808985, |
42 | "narHash": "sha256-AfRXbXH1t7WgDiHt+CWofoLuy12nfFTY4pZoGfPueQo=", | 80 | "narHash": "sha256-cf/+g1RVawT0rcKmfh2nf/lgnSrj9YZS+1PkCFmoeJQ=", |
43 | "owner": "NixOS", | 81 | "owner": "NixOS", |
44 | "repo": "nixpkgs", | 82 | "repo": "nixpkgs", |
45 | "rev": "b2a189a8618fc1ba61593016fe5699b38971b89f", | 83 | "rev": "327368f98c6a927a84aed3c2f2fd1a7f6983e855", |
46 | "type": "github" | 84 | "type": "github" |
47 | }, | 85 | }, |
48 | "original": { | 86 | "original": { |
@@ -54,16 +92,16 @@ | |||
54 | }, | 92 | }, |
55 | "nixpkgs-unstable": { | 93 | "nixpkgs-unstable": { |
56 | "locked": { | 94 | "locked": { |
57 | "lastModified": 1618755104, | 95 | "lastModified": 1620741912, |
58 | "narHash": "sha256-boqugaFW1nRuyu0w774WGgaaCEfCxn0Nf8z8GJziVmU=", | 96 | "narHash": "sha256-TvAEtovofPE7CQiRt2+LNmn2qeCMF1gLXAfs34a0zqA=", |
59 | "owner": "NixOS", | 97 | "owner": "NixOS", |
60 | "repo": "nixpkgs", | 98 | "repo": "nixpkgs", |
61 | "rev": "5a333c5f091b88007caf1041bbb651867a449c5a", | 99 | "rev": "ca26ea50d66737922d0edfaaf07449576ece7f8c", |
62 | "type": "github" | 100 | "type": "github" |
63 | }, | 101 | }, |
64 | "original": { | 102 | "original": { |
65 | "owner": "NixOS", | 103 | "owner": "NixOS", |
66 | "ref": "master", | 104 | "ref": "nixos-unstable", |
67 | "repo": "nixpkgs", | 105 | "repo": "nixpkgs", |
68 | "type": "github" | 106 | "type": "github" |
69 | } | 107 | } |
@@ -72,6 +110,7 @@ | |||
72 | "inputs": { | 110 | "inputs": { |
73 | "flake-utils": "flake-utils", | 111 | "flake-utils": "flake-utils", |
74 | "home-manager": "home-manager", | 112 | "home-manager": "home-manager", |
113 | "neovim-master": "neovim-master", | ||
75 | "nixpkgs": "nixpkgs", | 114 | "nixpkgs": "nixpkgs", |
76 | "nixpkgs-unstable": "nixpkgs-unstable" | 115 | "nixpkgs-unstable": "nixpkgs-unstable" |
77 | } | 116 | } |
@@ -2,14 +2,18 @@ | |||
2 | description = "My NixOS configurations"; | 2 | description = "My NixOS configurations"; |
3 | 3 | ||
4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-20.09"; | 4 | inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-20.09"; |
5 | inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/master"; | 5 | inputs.nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; |
6 | inputs.flake-utils.url = "github:numtide/flake-utils"; | 6 | inputs.flake-utils.url = "github:numtide/flake-utils"; |
7 | inputs.home-manager = { | 7 | inputs.home-manager = { |
8 | url = "github:nix-community/home-manager/release-20.09"; | 8 | url = "github:nix-community/home-manager/release-20.09"; |
9 | inputs.nixpkgs.follows = "nixpkgs"; | 9 | inputs.nixpkgs.follows = "nixpkgs"; |
10 | }; | 10 | }; |
11 | inputs.neovim-master = { | ||
12 | url = "github:neovim/neovim?dir=contrib"; | ||
13 | inputs.nixpkgs.follows = "nixpkgs-unstable"; | ||
14 | }; | ||
11 | 15 | ||
12 | outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, flake-utils, home-manager }: { | 16 | outputs = inputs @ { self, nixpkgs, home-manager, ... }: { |
13 | 17 | ||
14 | nixosModules = { | 18 | nixosModules = { |
15 | default = { ... }: { | 19 | default = { ... }: { |
@@ -59,6 +63,7 @@ | |||
59 | 63 | ||
60 | usecases.desktop = { | 64 | usecases.desktop = { |
61 | default = (import ./usecases/desktop/default.nix inputs); | 65 | default = (import ./usecases/desktop/default.nix inputs); |
66 | development = (import ./usecases/desktop/development.nix inputs); | ||
62 | networkManager = (import ./usecases/desktop/networking/network-manager.nix inputs); | 67 | networkManager = (import ./usecases/desktop/networking/network-manager.nix inputs); |
63 | }; | 68 | }; |
64 | 69 | ||
@@ -82,19 +87,20 @@ | |||
82 | ]; | 87 | ]; |
83 | }; | 88 | }; |
84 | 89 | ||
85 | testDesktop = nixpkgs.lib.nixosSystem { | 90 | testPlainDesktop = nixpkgs.lib.nixosSystem { |
91 | system = "x86_64-linux"; | ||
92 | modules = [ | ||
93 | self.nixosModules.test | ||
94 | self.nixosModules.profiles.desktop | ||
95 | ]; | ||
96 | }; | ||
97 | |||
98 | testDevDesktop = nixpkgs.lib.nixosSystem { | ||
86 | system = "x86_64-linux"; | 99 | system = "x86_64-linux"; |
87 | modules = [ | 100 | modules = [ |
88 | self.nixosModules.test | 101 | self.nixosModules.test |
89 | self.nixosModules.profiles.desktop | 102 | self.nixosModules.profiles.desktop |
90 | ({ modulesPath, ... }: { | 103 | self.nixosModules.usecases.desktop.development |
91 | imports = [ (modulesPath + "/virtualisation/qemu-vm.nix") ]; | ||
92 | |||
93 | virtualisation = { | ||
94 | memorySize = 2048; | ||
95 | cores = 3; | ||
96 | }; | ||
97 | }) | ||
98 | ]; | 104 | ]; |
99 | }; | 105 | }; |
100 | 106 | ||
diff --git a/profiles/desktop.nix b/profiles/desktop.nix index 2546b76..0498aaf 100644 --- a/profiles/desktop.nix +++ b/profiles/desktop.nix | |||
@@ -18,14 +18,6 @@ inputs: | |||
18 | pavucontrol | 18 | pavucontrol |
19 | pandoc | 19 | pandoc |
20 | poppler_utils | 20 | poppler_utils |
21 | # TODO: on development workstation | ||
22 | /* | ||
23 | rr | ||
24 | rtags | ||
25 | gcc | ||
26 | clang | ||
27 | clang-tools | ||
28 | */ | ||
29 | aspell | 21 | aspell |
30 | aspellDicts.en | 22 | aspellDicts.en |
31 | aspellDicts.en-computers | 23 | aspellDicts.en-computers |
diff --git a/usecases/desktop/development.nix b/usecases/desktop/development.nix new file mode 100644 index 0000000..022482d --- /dev/null +++ b/usecases/desktop/development.nix | |||
@@ -0,0 +1,39 @@ | |||
1 | inputs: | ||
2 | |||
3 | { config, pkgs, ... }: | ||
4 | |||
5 | let | ||
6 | inherit (pkgs.unstable) | ||
7 | clang-tools | ||
8 | elixir_ls | ||
9 | rust-analyzer-unwrapped | ||
10 | |||
11 | vimPlugins; | ||
12 | |||
13 | inherit (pkgs.unstable.python3Packages) python-language-server; | ||
14 | |||
15 | in | ||
16 | { | ||
17 | users.extraUsers.minijackson.packages = with pkgs; [ | ||
18 | rr | ||
19 | rtags | ||
20 | gcc | ||
21 | clang | ||
22 | clang-tools | ||
23 | ]; | ||
24 | |||
25 | vim = { | ||
26 | extraPlugins = with vimPlugins; [ | ||
27 | nvim-lspconfig | ||
28 | rust-tools-nvim | ||
29 | ]; | ||
30 | luaConfig = builtins.readFile ../../dotfiles/vim-dev.lua; | ||
31 | |||
32 | variables = { | ||
33 | clangd_path = "'${clang-tools}/bin/clangd'"; | ||
34 | elixirls_path = "'${elixir_ls}/bin/elixir-ls'"; | ||
35 | pyls_path = "'${python-language-server}/bin/pyls'"; | ||
36 | rust_analyzer_path = "'${rust-analyzer-unwrapped}/bin/rust-analyzer'"; | ||
37 | }; | ||
38 | }; | ||
39 | } | ||