Skip to content

Commit

Permalink
add go
Browse files Browse the repository at this point in the history
  • Loading branch information
Cassin01 committed Mar 30, 2024
1 parent cbbddba commit 94c9858
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 18 deletions.
48 changes: 45 additions & 3 deletions after_opt/lsp_conf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local vim = vim
local lspconfig = require("lspconfig")
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = { "sumneko_lua" },
ensure_installed = { },
})

-- local default_on_attach = function(client)
Expand Down Expand Up @@ -42,8 +42,8 @@ local setup_handlers = {
function(server_name)
lspconfig[server_name].setup({})
end,
["sumneko_lua"] = function()
lspconfig.sumneko_lua.setup({
["lua_ls"] = function()
lspconfig.lua_ls.setup({
on_attach = default_on_attach,
settings = {
Lua = {
Expand All @@ -54,6 +54,7 @@ local setup_handlers = {
globals = { "vim", "use", "require" },
},
workspace = {
checkThirdParty = false, -- Stop ask to configure my work environment.
library = vim.api.nvim_get_runtime_file("", true),
},
telemetry = {
Expand Down Expand Up @@ -104,6 +105,47 @@ local setup_handlers = {
},
})
end,
["gopls"] = function()
lspconfig.gopls.setup({
on_attach = default_on_attach,
settings = {
gopls = {
analyses = {
unusedparams = true,
},
staticcheck = true,
gofumpt = true,
},
},
})
end,
["pylsp"] = function()
lspconfig.pylsp.setup({
on_attach = default_on_attach,
-- https://github.com/python-rope/rope/wiki/Rope-in-Vim-or-Neovim
cmd = { "pylsp" },
settings = {
pylsp = {
configurationSources = { "flake8" },
plugins = {
-- https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
jedi_symbols = {
enabled = true,
all_scopes = true,
include_import_symbols = true,
},
-- jedi_definition.enabled = true,
jedi_hover = {
enabled = true,
},
rope_completion = {
enabled = true,
},
}
}
}
})
end,
}

local ok, secret = pcall(require, "secret")
Expand Down
52 changes: 38 additions & 14 deletions fnl/core/au/init.fnl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(import-macros {: epi} :util.macros)
(import-macros {: epi : when-let : def} :util.macros)
(import-macros {: au! : la : plug : async-do!} :kaza.macros)
(local {: concat-with} (require :util.list))
(local {: hi-clear} (require :kaza.hi))
(local {: hi-clear : get-hl} (require :kaza.hi))
(local {: syntax} (require :kaza.cmd))
(local vf vim.fn)
(local va vim.api)
Expand Down Expand Up @@ -62,7 +62,7 @@
; (link :Comment {:fg (blightness (get-hl :Comment :fg) 0.8)})
]
[:CommentHead (link :Comment {:fg :#727ca7})]
[:VertSplit (link :NonText {})]
[:VertSplit (link :LineNr {})]
[:StatusLine (link :NonText {})]
; [:StatusLine (link :NonText {:fg (get-hl :StatusLine :fg)})]
; [:BufferLineFill (link :NonText {:fg (get-hl :BufferLineFill :fg)})]
Expand Down Expand Up @@ -117,7 +117,10 @@
(= vim.bo.filetype "lua")
(= vim.bo.filetype "rust")
(= vim.bo.filetype "tex")
))
(= vim.bo.filetype "python")
(= vim.bo.filetype "htmldjango")
(= vim.bo.filetype "javascript")
(= vim.bo.filetype "go")))
(when res
(tset vim.wo :winbar "%{%v:lua.require'lua.winbar'.exec()%}"))))
{:pattern :*})
Expand Down Expand Up @@ -147,7 +150,7 @@
:/*
:<kDivide><kMultiply><space><space><kMultiply><kDivide><left><left><left>
{:noremap true}))
:pattern [:*.c :*.h :*.cpp :*.rs]
:pattern [:*.c :*.h :*.cpp :*.rs :*.go]
:group pattern})
(create_autocmd
[:BufRead :BufNewFile]
Expand Down Expand Up @@ -181,20 +184,27 @@
(vim.fn.setcellwidths
[[0x9789 0x9789 2]
[0x978B 0x978B 2]])

(fn todo []
;; https://gist.github.com/huytd/668fc018b019fbc49fa1c09101363397
(vf.matchadd :Conceal "^\\s*- \\[\\s\\]" 1 -1 {:conceal :})
(vf.matchadd :Conceal "^\\s*- \\[x\\]" 1 -1 {:conceal :})
(vf.matchadd :Conceal "\\(^\\s*\\)\\@<=- \\[\\s\\]" 1 -1 {:conceal :})
(vf.matchadd :Conceal "\\(^\\s*\\)\\@<=- \\[x\\]" 1 -1 {:conceal :})
; (vf.matchadd :Comment "^---" 1 -1 {:conceal "• "})
(vf.matchadd :Conceal "^\\s*-\\(\\s\\)\\@=" 0 -1 {:conceal "• "})
(vf.matchadd :Conceal "\\(^\\s*\\)\\@<=-\\(\\s\\)\\@=" 0 -1 {:conceal "• "})
(vf.matchadd :Conceal "^#\\(\\s\\)\\@=" 0 -1 {:conceal "◉"})
(vf.matchadd :Conceal "^##\\(\\s\\)\\@=" 0 -1 {:conceal "○" })
(vf.matchadd :Conceal "^###\\(\\s\\)\\@=" 0 -1 {:conceal "✹" })
; (syntax "syntax match todoCheckbox \\\'\\v(\\s+)?(-|\\*)\\s\\[-\\]\\\'hs=e-4 conceal cchar=☒")
; (syntax "syntax match todoCheckbox \'\\\[x\\\]\' conceal cchar=☒")
(vim.cmd "hi def link todoCheckbox Todo")
(vim.cmd "setlocal cole=1")
(buf_set_keymap 0 :n "<localleader>td" "a- [ ] <esc>" {:noremap true}))
(vim.cmd "setlocal comments=nb:>,b:-\\ [\\ ],b:-\\ [x],b:-")
(local indent 2)
(vim.cmd "setlocal formatoptions-=c formatoptions+=jro")
(vim.cmd (string.format "setlocal shiftwidth=%d" 2))
(vim.cmd (string.format "setlocal tabstop=%d" 2))
(vim.cmd (string.format "setlocal softtabstop=%d" 2))
(buf_set_keymap 0 :n "<localleader>td" "a- [ ] " {:noremap true :desc "markdown add checkbox"}))
(create_autocmd
[:BufRead :BufNewFile]
{:callback (λ []
Expand Down Expand Up @@ -276,11 +286,11 @@
; :syntax {:month "'^\\(\\d\\|\\d\\d\\)月'"}})

;; packer
(create_autocmd
:BufWritePost
{:command :PackerCompile
:pattern :plugs.fnl
:group (create_augroup :packer-compile {:clear true})})
; (create_autocmd
; :BufWritePost
; {:command :PackerCompile
; :pattern :plugs.fnl
; :group (create_augroup :packer-compile {:clear true})})

;; ref-view
(au! :ref-view
Expand All @@ -296,3 +306,17 @@
; (au! :reload-copilot
; :VimEnter
; (vim.cmd "Copilot restart"))


;; bufferline
(au! :reload-devicon
; [:BufWinEnter :BufWinLeave :BufReadPost]
; [:BufWinEnter :TabEnter :WinEnter]
[:BufEnter :BufLeave :WinEnter :WinLeave :TabEnter :TabLeave :BufWinEnter :BufWinLeave :BufReadPost :BufReadPre]
(do
(when-let fg (get-hl :Comment :fg)
(local cs (vim.api.nvim_get_hl 0 {}))
(each [hi-name _ (pairs cs)]
(when (not= (hi-name:match "^BufferLineDevIcon.*Inactive$") nil)
(vim.cmd (.. "hi " hi-name " guifg=" fg))))))
{})
2 changes: 1 addition & 1 deletion fnl/core/lsp.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

;; aus(group, arguments that will be unpacked)
(aus :lsp-diagnostic
[[:CursorHold (la (vim.diagnostic.setloclist {:open false})) {:pattern [:*.rs :*.ts :*.tex]}]
[[:CursorHold (la (vim.diagnostic.setloclist {:open false})) {:pattern [:*.rs :*.ts :*.tex :*.py :*.go]}]
[:FileType (la (let [line_num (vim.fn.line :$)]
; (tset _G.__kaza.v :diagnostic_master_buf (vim.api.nvim_get_current_buf))
(tset vim.wo :wrap true)
Expand Down

0 comments on commit 94c9858

Please sign in to comment.