diff --git a/nix/neovim-overlay.nix b/nix/neovim-overlay.nix index 35cd41f..1be8739 100644 --- a/nix/neovim-overlay.nix +++ b/nix/neovim-overlay.nix @@ -103,7 +103,7 @@ with final.pkgs.lib; let lua-language-server clang-tools # provides clangd which is a c/c++ lsp jdt-language-server # java ls - nil # nix lsp + nixd # nix LSP rust-analyzer # rust LSP vscode-langservers-extracted # various web dev lsps from vscode typescript-language-server # css lsp thing @@ -116,10 +116,6 @@ with final.pkgs.lib; let rustfmt # rust formatter prettierd # typescript/javascript formatter # google-java-format # java formatter based off google guidelines - - # extra required packages - gcc - nodejs ]; in { # This is the neovim derivation diff --git a/nvim/ftplugin/nix.lua b/nvim/ftplugin/nix.lua index 0d4aac8..7fee20e 100644 --- a/nvim/ftplugin/nix.lua +++ b/nvim/ftplugin/nix.lua @@ -1,5 +1,5 @@ -- Exit if the language server isn't available -if vim.fn.executable('nil') ~= 1 then +if vim.fn.executable('nixd') ~= 1 then return end @@ -11,8 +11,8 @@ local root_files = { local lsp = require('user.lsp') vim.lsp.start { - name = 'nil', - cmd = { 'nil' }, + name = 'nixd', + cmd = { 'nixd' }, root_dir = vim.fs.dirname(vim.fs.find(root_files, { upward = true })[1]), capabilities = lsp.make_client_capabilities(), on_attach = lsp.on_attach, diff --git a/nvim/init.lua b/nvim/init.lua index 32d3e73..79b8c5a 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -22,7 +22,7 @@ end opt.path = vim.o.path .. '**' opt.number = true -opt.relativenumber = true +opt.relativenumber = false opt.cursorline = true opt.lazyredraw = true opt.showmatch = true -- Highlight matching parentheses, etc diff --git a/nvim/plugin/autocommands.lua b/nvim/plugin/autocommands.lua index 86c5238..cd8ceb6 100644 --- a/nvim/plugin/autocommands.lua +++ b/nvim/plugin/autocommands.lua @@ -89,6 +89,9 @@ vim.api.nvim_create_autocmd('LspAttach', { keymap.set('n', '', vim.lsp.codelens.run, desc('[lsp] run code lens')) keymap.set('n', 'cr', vim.lsp.codelens.refresh, desc('lsp [c]ode lenses [r]efresh')) keymap.set('n', 'gr', vim.lsp.buf.references, desc('lsp [g]et [r]eferences')) + keymap.set('n', 'f', function() + vim.lsp.buf.format { async = true } + end, desc('[lsp] [f]ormat buffer')) if client and client.server_capabilities.inlayHintProvider then keymap.set('n', 'h', function() local current_setting = vim.lsp.inlay_hint.is_enabled { bufnr = bufnr } diff --git a/nvim/plugin/conform.lua b/nvim/plugin/conform.lua index c604c44..af3e755 100644 --- a/nvim/plugin/conform.lua +++ b/nvim/plugin/conform.lua @@ -4,7 +4,6 @@ require('conform').setup { nix = { 'alejandra' }, rust = { 'rustfmt' }, typescript = { 'prettierd' }, - -- Conform will run multiple formatters sequentially -- python = { "isort", "black" }, -- You can customize some of the format options for the filetype (:help conform.format) @@ -12,14 +11,9 @@ require('conform').setup { -- Conform will run the first available formatter -- javascript = { "prettierd", "prettier", stop_after_first = true }, }, - format_on_save = nil, - -- format_on_save = { - -- -- These options will be passed to conform.format() - -- timeout_ms = 500, - -- lsp_format = 'fallback', - -- }, + format_on_save = { + -- These options will be passed to conform.format() + timeout_ms = 500, + lsp_format = 'fallback', + }, } - -vim.keymap.set('n', 'f', function() - require('conform').format { async = true, lsp_format = 'fallback' } -end, { desc = '[f]ormat buffer' }) diff --git a/nvim/plugin/telescope.lua b/nvim/plugin/telescope.lua index 6e248b4..490dd75 100644 --- a/nvim/plugin/telescope.lua +++ b/nvim/plugin/telescope.lua @@ -27,9 +27,14 @@ vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'se', builtin.diagnostics, { desc = '[S]earch [E]rrors' }) +vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', 'sd', ':Telescope file_browser', { desc = 'Search [D]irectory' }) +vim.keymap.set( + 'n', + 'fb', + ':Telescope file_browser', + { desc = '[F]ile [B]rowser', noremap = true, silent = true } +) telescope.setup { defaults = { @@ -52,7 +57,7 @@ telescope.setup { local multi = picker:get_multi_selection() actions.select_default(pb) -- the normal enter behaviour for _, j in pairs(multi) do - if j.path ~= nil then -- is it a file -> open it as well: + if j.path ~= nil then -- is it a file -> open it as well: vim.cmd(string.format('%s %s', 'edit', j.path)) end end diff --git a/nvim/plugin/which-key.lua b/nvim/plugin/which-key.lua index 26b8be2..08df1f4 100644 --- a/nvim/plugin/which-key.lua +++ b/nvim/plugin/which-key.lua @@ -11,7 +11,6 @@ wk.add { { 's', group = '[S]earch' }, { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, - { 'f', group = '[F]ormat' }, { 'g', group = '[G]it' }, { 'p', group = '[P]eek' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } },