diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index d712835..e2efb97 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -64,7 +64,7 @@ vim.opt.splitbelow = true -- See `:help 'list'` -- and `:help 'listchars'` vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.opt.listchars = { tab = ' ', trail = '·', nbsp = '␣' } -- Preview substitutions live, as you type! vim.opt.inccommand = 'split' @@ -75,6 +75,14 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 +-- [[ Custom Filetypes ]] +vim.filetype.add { + extension = { + mlf = 'mlf', + sdl = 'graphql', + }, +} + -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -482,6 +490,7 @@ require('lazy').setup({ -- Execute a code action, usually your cursor needs to be on top of an error -- or a suggestion from your LSP for this to activate. map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) + map('', vim.lsp.buf.code_action, 'Code Action (Alt-Enter)', { 'n', 'x' }) -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header. @@ -493,7 +502,7 @@ require('lazy').setup({ -- -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, @@ -520,7 +529,7 @@ require('lazy').setup({ -- code, if the language server you are using supports them -- -- This may be unwanted, since they displace some of your code - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then + if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then map('th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') @@ -609,6 +618,8 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'csharpier', -- C# formatter (used by conform for cs files) + 'roslyn-language-server', -- C# language server (driven by roslyn.nvim) }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -667,6 +678,7 @@ require('lazy').setup({ -- You can use 'stop_after_first' to run the first available formatter from the list javascript = { 'prettierd', 'prettier', stop_after_first = true }, typescript = { 'prettierd', 'prettier', stop_after_first = true }, + cs = { 'csharpier' }, }, }, }, @@ -866,7 +878,6 @@ require('lazy').setup({ end, }, - { 'github/copilot.vim', config = function() end }, 'tpope/vim-fugitive', { @@ -922,7 +933,7 @@ require('lazy').setup({ opts = { auto_close = true, -- Auto-close when no items auto_preview = true, -- Auto-preview item under cursor - focus = true, -- Focus Trouble window when opened + focus = false, -- Focus Trouble window when opened follow = true, -- Follow current file in Trouble restore = true, -- Restore last Trouble window position modes = { @@ -996,21 +1007,76 @@ require('lazy').setup({ { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', + branch = 'main', + lazy = false, build = ':TSUpdate', -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, + config = function() + -- install() wipes the parsers table and fires User TSUpdate, so custom + -- parsers must be (re-)registered from this autocmd (see README) + local function register_custom_parsers() + require('nvim-treesitter.parsers').mlf = { + install_info = { + path = vim.fn.expand '~/.local/share/tree-sitter-parsers/tree-sitter-mlf', + }, + } + end + vim.api.nvim_create_autocmd('User', { + pattern = 'TSUpdate', + callback = register_custom_parsers, + }) + register_custom_parsers() + + local ts = require 'nvim-treesitter' + ts.install { + 'bash', + 'c', + 'c_sharp', + 'diff', + 'fsharp', + 'graphql', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'mlf', + 'query', + 'racket', + 'vim', + 'vimdoc', + 'xml', + } + + vim.api.nvim_create_autocmd('FileType', { + group = vim.api.nvim_create_augroup('treesitter-enable', { clear = true }), + callback = function(args) + local lang = vim.treesitter.language.get_lang(args.match) + if not lang then + return + end + + local function enable() + vim.treesitter.start(args.buf, lang) + vim.bo[args.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + + if vim.treesitter.language.add(lang) then + enable() + return + end + + -- auto-install parsers for filetypes opened for the first time + if vim.tbl_contains(ts.get_available(), lang) then + ts.install(lang):await(function() + if vim.api.nvim_buf_is_valid(args.buf) then + pcall(enable) + end + end) + end + end, + }) + end, -- There are additional nvim-treesitter modules that you can use to interact -- with nvim-treesitter. You should go explore a few and see what interests you: -- @@ -1034,6 +1100,14 @@ require('lazy').setup({ require 'kickstart.plugins.neo-tree', require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'custom.plugins.dotnet', -- C# / .NET: roslyn.nvim LSP + + require 'custom.plugins.racket', -- Racket: racket-langserver LSP, conjure REPL, paredit + + require 'custom.plugins.fsharp', -- F#: fsautocomplete LSP via native vim.lsp + + require 'custom.plugins.minuet', -- Copilot-style inline completion via DGX llama.cpp + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. --